麒麟 arm64 V10SP1 编译 phantomjs

目前国内国产化代替需求越来越多,但是类似于 phantomjs 这种较老的软件网上资料比较少,难以移植到 arm64 上,所以这篇文章分享一下 phantomjs 的移植编译,帮助有需求的人。

下载源码

git clone https://github.com/vitallium/phantomjs.git
git check 2.1.1
git submodule init
git submodule update

下载 openssl 1.0.1 版本

V10SP1 上面的 openssl 版本为 1.1.1 以上,不适用于 phantomjs 2.1.1,因此编译和使用时需要 1.0.1 版本,openssl 编译比较简单。

wget https://ftp.openssl.org/source/old/1.0.1/openssl-1.0.1u.tar.gz
./config
make install    # 路径一般为 /usr/local/ssl,也可以只 make,只需要使用 libssl.so 和 libcrypto.so 文件

修改 phantomjs 源码 bug

phantomjs 依赖的 qtwebkit,在 arm64 编译时存在 bug,需要修改源码后编译。

vim src/qt/qtwebkit/Source/JavaScriptCore/API/JSStringRef.h
--- webkitgtk-2.4.11.orig/Source/JavaScriptCore/API/JSStringRef.h    2016-04-10 08:48:36.000000000 +0200
+++ webkitgtk-2.4.11/Source/JavaScriptCore/API/JSStringRef.h    2017-12-20 23:04:55.000000000 +0100
@@ -27,6 +27,7 @@
 #define JSStringRef_h

 #include 
+#include 

 #ifndef __cplusplus
 #include 
@@ -43,7 +44,7 @@
 @typedef JSChar
 @abstract A Unicode character.
 */
-    typedef unsigned short JSChar;
+    typedef char16_t JSChar;
 #else
     typedef wchar_t JSChar;
 #endif

编译

qt-config 的路径是上面 openssl 编译后库的路径。

python build.py --qt-config="-L/usr/local/ssl/lib" --qt-config="-I/usr/local/ssl/include" --qt-config="-no-pch"

使用

需要指定 libssllibcrypto 的位置,都放在 libssl_path

export LD_LIBRARY_PATH=/libssl_path:$LD_LIBRARY_PATH

之后就可以使用 phantomjs

你可能感兴趣的:(麒麟 arm64 V10SP1 编译 phantomjs)