CrossWalk切换到chromium58的编译方法

未经许可请勿转载,转载请先联系我(hello@yeshen.org)取得授权

这里假设你已经按这篇文章实践过了一次chromium编译与支持H264编码支持(即环境那些都是OK的)。

基本要求:
50G以上的空间

拉取代码

export XWALK_OS_ANDROID=1
cd /path/to/crosswalk-checkout
gclient config --name src/xwalk https://github.com/ks32/crosswalk.git@origin/ks_chromium_58

Edit this newly-created .gclient file, and add the following to the bottom:

target_os = ['android']
gclient sync

(看网速)

如果sync失败,看看是不是缺少了依赖

sudo apt-get install bzip2

安装依赖

cd /path/to/crosswalk-checkout/src
./build/install-build-deps-android.sh

编译

cd /path/to/crosswalk-checkout/src
gn args out/Default

You can add other settings after this statement, such as is_debug = false for a release build or target_cpu = “x64” to create a 64-bit IA build. By default, target_cpu is set to arm, which creates a 32-bit ARM build.

Once you have done this once, you can later call gn gen out/Default to just regenerate the ninja files based on your existing settings if you need to (most of the time, this will be done automatically for you when building).

See Chromium’s page about GN for more information, including other common settings.

import("//xwalk/build/android.gni") 
is_debug = false 
target_os = "android" 
enable_nacl = false 
symbol_level = 0 
remove_webcore_debug_symbols = true 
target_cpu = "arm" 
use_aura=false 
use_ozone=false 
enable_plugins=false 
disable_bundled_extensions=true
ffmpeg_branding = "Chrome" #disable to reduce size 
proprietary_codecs=true #disable to reduce size 
v8_use_snapshot=true 
enable_webrtc=true #disable to reduce size 
pdf_enable_v8=false 
multidex_in_release=true 
is_official_build=true 
v8_enable_i18n_support=false 
disable_ftp_support=true 
disable_libfuzzer=true 
enable_basic_print_dialog=false
cd src
ninja -j8 -C out/Default xwalk_core_library

可选编译目标有:

  1. xwalk_core_library creates a directory called in YOUR-BUILD-DIR with an architecture-specific Crosswalk library for use when embedding Crosswalk in a project.

  2. xwalk_runtime_lib_apk will generate a file called XWalkRuntimeLib.apk in YOUR-BUILD-DIR/apks containing Crosswalk’s runtime library (which can act as the runtime for applications built using Crosswalk’s shared mode). *

  3. xwalk_app_template_apk creates a sample web app APK for testing. It is located in YOUR-BUID-DIR/apks/XWalkAppTemplate.apk

小结下

  1. 切换到 ks32/crosswalk.git@origin/ks_chromium_58 这条分支,获取了项目的代码
  2. 然后选择 xwalk_core_library 作为编译目标,编译输出了aar。

参考资料

  1. https://github.com/crosswalk-project/crosswalk-website
  2. https://github.com/ks32/crosswalk/tree/ks_chromium_58
  3. https://github.com/crosswalk-project/crosswalk/issues/4001
  4. https://github.com/ks32/CrosswalkNative/issues/1

玩~

2019/05/22 更新


如何打开debug模式

gn args out/Default
# is_debug = true

编译出来的内核,在为webrtc上播放我们的H264视频存在闪退问题,今天想看看日志,打开了debug开关,重新编译。

然后报这个错误。

FAILED: libxwalkcore.cr.so libxwalkcore.cr.so.TOC lib.unstripped/libxwalkcore.cr.so
python "/home/crosswalk/src/build/toolchain/gcc_solink_wrapper.py" --readelf="../../third_party/android_tools/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-readelf" --nm="../../third_party/android_tools/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-nm" --strip=../../third_party/android_tools/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-strip --sofile="./lib.unstripped/libxwalkcore.cr.so" --tocfile="./libxwalkcore.cr.so.TOC" --output="./libxwalkcore.cr.so"  -- ../../third_party/android_tools/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-g++ -shared -Wl,--fatal-warnings -fPIC -Wl,-z,noexecstack -Wl,-z,now -Wl,-z,relro -Wl,-z,defs -Wl,--as-needed -fuse-ld=gold -Wl,--icf=all -Wl,--build-id=sha1 -Wl,--no-undefined -Wl,--exclude-libs=libgcc.a -Wl,--exclude-libs=libc++_static.a -Wl,--exclude-libs=libvpx_assembly_arm.a -Werror -nostdlib -Wl,--warn-shared-textrel --sysroot=../../third_party/android_tools/ndk/platforms/android-16/arch-arm  -Wl,--version-script=/home/crosswalk/src/build/android/android_only_explicit_jni_exports.lst -Wl,-wrap,calloc -Wl,-wrap,free -Wl,-wrap,malloc -Wl,-wrap,memalign -Wl,-wrap,posix_memalign -Wl,-wrap,pvalloc -Wl,-wrap,realloc -Wl,-wrap,valloc -L../../third_party/android_tools/ndk/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a -o "./lib.unstripped/libxwalkcore.cr.so" -Wl,-soname="libxwalkcore.cr.so" @"./libxwalkcore.cr.so.rsp"
obj/xwalk/xwalk_runtime/xwalk_dev_tools_server.o:xwalk_dev_tools_server.cc:function xwalk::XWalkDevToolsServer::Stop(): error: undefined reference to 'content::DevToolsHttpHandler::~DevToolsHttpHandler()'
obj/xwalk/xwalk_runtime/xwalk_dev_tools_server.o:xwalk_dev_tools_server.cc:function xwalk::XWalkDevToolsServer::~XWalkDevToolsServer(): error: undefined reference to 'content::DevToolsHttpHandler::~DevToolsHttpHandler()'
obj/xwalk/xwalk_runtime/xwalk_dev_tools_server.o:xwalk_dev_tools_server.cc:function xwalk::XWalkDevToolsServer::Start(bool, bool): error: undefined reference to 'content::DevToolsHttpHandler::DevToolsHttpHandler(content::DevToolsManagerDelegate*, std::__ndk1::unique_ptr<content::DevToolsSocketFactory, std::__ndk1::default_delete<content::DevToolsSocketFactory> >, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&, base::FilePath const&, base::FilePath const&, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&)'
obj/xwalk/xwalk_runtime/xwalk_dev_tools_server.o:xwalk_dev_tools_server.cc:function xwalk::XWalkDevToolsServer::Start(bool, bool): error: undefined reference to 'content::DevToolsHttpHandler::~DevToolsHttpHandler()'
obj/xwalk/xwalk_runtime/remote_debugging_server.o:remote_debugging_server.cc:function xwalk::RemoteDebuggingServer::~RemoteDebuggingServer(): error: undefined reference to 'content::DevToolsHttpHandler::~DevToolsHttpHandler()'
obj/xwalk/xwalk_runtime/remote_debugging_server.o:remote_debugging_server.cc:function xwalk::RemoteDebuggingServer::RemoteDebuggingServer(xwalk::XWalkBrowserContext*, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&, int, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&): error: undefined reference to 'content::DevToolsHttpHandler::DevToolsHttpHandler(content::DevToolsManagerDelegate*, std::__ndk1::unique_ptr<content::DevToolsSocketFactory, std::__ndk1::default_delete<content::DevToolsSocketFactory> >, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&, base::FilePath const&, base::FilePath const&, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&)'
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.

这个错误看起来是一个库提交在私有分支上然后被去掉了,可以修改下 xwalk/BUILD.gndevtools_http_handler 把东西补回去,但是我查了一下chromium 58的代码,发现没有这个文件夹,应该是 tenta-browser 的私有库。

相关的代码其实在chromium 上是有的,看起来要改下 BUILD.gn 处理下引用关系。可以这样改:

在这个文件(xwalk/BUILD.gn)中 的 if(!is_android){ 之上加下 devtools_http_handler的代码便可。

source_set("xwalk_runtime"){
	sources=[
	....
# 333 modify by Yeshen
 "//content/browser/devtools/devtools_http_handler.h",
 "//content/browser/devtools/devtools_http_handler.cc",
 "//net/server/http_server.h",
 "//net/server/http_server.cc",
 "//net/server/http_connection.h",
 "//net/server/http_connection.cc",
 "//net/server/web_socket.h",
 "//net/server/web_socket.cc",
 "//net/server/web_socket_encoder.h",
 "//net/server/web_socket_encoder.cc",
 "//net/server/http_server_response_info.h",
 "//net/server/http_server_response_info.cc",
 "//net/server/http_server_request_info.h",
 "//net/server/http_server_request_info.cc"
 # 347 modify by Yeshen
	]
	if(!is_android){
    ...
    }
}

PS:这部分确实还有探索的空间,从目前研究原生为webrtc的思路来参考。可以做这样的假设:

  1. 浏览器上我们的源会crash可能也是因为nack的重传策略的影响。
  2. 扩展硬解支持,和原生一样,只要在编码和解码出,增加下白名单,或者把白名单机制去掉,就可以支持任意有硬解芯片的手机/设备。
  3. 我猜浏览器也是能支持软解的,但是需要找到方法把代码中的开关打开。
相关推荐
©️2020 CSDN 皮肤主题: 深蓝海洋 设计师:CSDN官方博客 返回首页