crosswalk 官方:https://github.com/crosswalk-project
编译环境 Ubuntu 16.04
crosswalk 支持的Ubuntu版本 12.04 、14.04、14.10、15.04、15.10、16.04。
编译Android平台上的Crosswalk,你首先应该设置 XWALK_OS_ANDROID环境变量:
export XWALK_OS_ANDROID=1
创建一个源码目录:
mkdir crosswalk
cd crosswalk
如果没有安装 depot_tools 先安装、已安装跳过该步骤
//安装depot_tools:
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
//添加到环境变量里:
export PATH="$PATH:/xxx/xxx/depot_tools"
自动生成gclient的配置文件(.gclient):
gclient config --name src/xwalk https://github.com/crosswalk-project/crosswalk.git
在.gclient文件 下添加:
target_os = ['android']
在包含.gclient文件的目录下,获取源码:
gclient sync
gclient sync 如果报错(未找到解决办法):
//错误信息
root@md:~/crosswalk# gclient sync
Running depot tools as root is sad.
Syncing projects: 100% (1/1), done.
________ running 'vpython src/xwalk/tools/fetch_deps.py -v' in '/home/ws/crosswalk'
Traceback (most recent call last):
File "src/xwalk/tools/fetch_deps.py", line 86, in <module>
sys.exit(main())
File "src/xwalk/tools/fetch_deps.py", line 81, in main
deps_fetcher.DoGclientSyncForChromium()
File "src/xwalk/tools/fetch_deps.py", line 56, in DoGclientSyncForChromium
gclient_utils.CheckCallAndFilterAndHeader(gclient_cmd,
AttributeError: 'module' object has no attribute 'CheckCallAndFilterAndHeader'
Error: Command 'vpython src/xwalk/tools/fetch_deps.py -v' returned non-zero exit status 1 in /home/ws/crosswalk
Traceback (most recent call last):
File "src/xwalk/tools/fetch_deps.py", line 86, in <module>
sys.exit(main())
File "src/xwalk/tools/fetch_deps.py", line 81, in main
deps_fetcher.DoGclientSyncForChromium()
File "src/xwalk/tools/fetch_deps.py", line 56, in DoGclientSyncForChromium
gclient_utils.CheckCallAndFilterAndHeader(gclient_cmd,
AttributeError: 'module' object has no attribute 'CheckCallAndFilterAndHeader'
可以尝试下面这条命令:(非常的慢,还容易失败,失败了只能重新运行这个命令,看运气、网速)
记得给.gclient-xwalk添加:
target_os = ['android']
然后运行命令:
gclient sync --verbose --reset --force --with_branch_heads --delete_unversioned_trees --gclientfile=.gclient-xwalk
为Android平台的Crosswalk安装依赖关系:
cd src
./build/install-build-deps-android.sh
编译:
gn args out/Default
在弹出来的页面放入一下代码保存退出即可:
import("//xwalk/build/android.gni")
is_debug = false
target_os = "android"
ffmpeg_branding = "Chrome"
proprietary_codecs = true
rtc_initialize_ffmpeg = true
rtc_use_h264 = true
target_cpu = "arm"
enable_nacl = false
symbol_level = 0
remove_webcore_debug_symbols = true
use_aura = false
use_ozone = false
enable_plugins = false
disable_bundled_extensions = true
v8_use_snapshot = true
enable_webrtc = true
is_official_build = true
v8_enable_i18n_support = false
disable_ftp_support = true
disable_libfuzzer = true
如果报错:
../../third_party/android_tools/sdk/extras/google/google_play_services/libproject/google-play-services_lib/res does not exist
类似的文件找不到可以手动下载对应的文件然后放入对应的位置即可
wget https://dl-ssl.google.com/android/repository/google_play_services_8298000_r28.zip
//无报错则忽略。
通过工具和嵌入式库,编译Android版Crosswalk的主要部分,你可以运行:
ninja -C out/Default xwalk_core_library
这样将会在out/Default下创建一个名为xwalk_core_library的目录,目录中包含有特定平台(例如X86或者ARM版)的Crosswalk库,这些库可以将Crosswalk嵌入到项目中。
编译Crosswalk的运行时库(在Crosswalk共享模式下,一个可以作为应用的runtime的APK),运行:
ninja -C out/Default xwalk_runtime_lib_apk
这将会在out/Default/apks下生成一个名称为XWalkRuntimeLib.apk的APK。
为了构造一个简单的web应用APK(为了快速安装/目标测试),只要执行:
ninja -C out/Default xwalk_app_template_apk
这将会在out/Default/apks下生成一个名称为XWalkAppTemplate.apk的APK。