GeezerVison is showing github.com — build: support android build on ndk version equal or above 23 · nodejs/node@e655869
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: android-configure +42-36Lines changed: 42 additions & 36 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 8 | 8 | # modules with npm. Also, don't forget to set the arch in npm config using | 9 | 9 | # 'npm config set arch=<arch>' | 10 | 10 |
| | 11 | +if [ $# -ne 3 ]; then | | 12 | + echo "$0 should have 3 parameters: ndk_path, target_arch and sdk_version" | | 13 | + exit 1 | | 14 | +fi | | 15 | + | | 16 | +NDK_PATH=$1 | | 17 | +ARCH="$2" | | 18 | +ANDROID_SDK_VERSION=$3 | 11 | 19 |
| 12 | | -if [ -z "$2" ]; then | 13 | | - ARCH=arm | 14 | | -else | 15 | | - ARCH="$2" | | 20 | +if [ $ANDROID_SDK_VERSION -lt 23 ]; then | | 21 | + echo "$ANDROID_SDK_VERSION should equal or later than 23(Android 6.0)" | 16 | 22 | fi | 17 | 23 |
| 18 | 24 | CC_VER="4.9" | | 25 | + | 19 | 26 | case $ARCH in | 20 | 27 | arm) | 21 | | - DEST_CPU="$ARCH" | 22 | | - SUFFIX="$ARCH-linux-androideabi" | 23 | | - TOOLCHAIN_NAME="$SUFFIX" | | 28 | + DEST_CPU="arm" | | 29 | + TOOLCHAIN_NAME="armv7-linux-androideabi" | 24 | 30 | ;; | 25 | 31 | x86) | 26 | 32 | DEST_CPU="ia32" | 27 | | - SUFFIX="i686-linux-android" | 28 | | - TOOLCHAIN_NAME="$ARCH" | | 33 | + TOOLCHAIN_NAME="i686-linux-android" | 29 | 34 | ;; | 30 | 35 | x86_64) | 31 | | - DEST_CPU="ia32" | 32 | | - SUFFIX="$ARCH-linux-android" | 33 | | - TOOLCHAIN_NAME="$ARCH" | | 36 | + DEST_CPU="x64" | | 37 | + TOOLCHAIN_NAME="x86_64-linux-android" | | 38 | + ARCH="x64" | | 39 | + ;; | | 40 | + arm64|aarch64) | | 41 | + DEST_CPU="arm64" | | 42 | + TOOLCHAIN_NAME="aarch64-linux-android" | | 43 | + ARCH="arm64" | 34 | 44 | ;; | 35 | 45 | *) | 36 | 46 | echo "Unsupported architecture provided: $ARCH" | 37 | 47 | exit 1 | 38 | 48 | ;; | 39 | 49 | esac | 40 | 50 |
| 41 | | -NDK_PATH=$1 | 42 | | -function make_toolchain { | 43 | | - $NDK_PATH/build/tools/make-standalone-toolchain.sh \ | 44 | | - --toolchain=$TOOLCHAIN_NAME-$CC_VER \ | 45 | | - --arch=$ARCH \ | 46 | | - --install-dir=$TOOLCHAIN \ | 47 | | - --platform=android-21 | 48 | | -} | | 51 | +HOST_OS="linux" | | 52 | +HOST_ARCH="x86_64" | | 53 | +export CC_host=$(which gcc) | | 54 | +export CXX_host=$(which g++) | 49 | 55 |
| 50 | | -export TOOLCHAIN=$PWD/android-toolchain | 51 | | -if [ -d "$TOOLCHAIN" ]; then | 52 | | - read -r -p "NDK toolchain already exists. Replace it? [y/N]" response | 53 | | - case "$response" in | 54 | | - [Yy]) | 55 | | - rm -rf "$TOOLCHAIN" | 56 | | - make_toolchain | 57 | | - esac | 58 | | -else | 59 | | - make_toolchain | | 56 | +host_gcc_version=$($CC_host --version | grep gcc | awk '{print $NF}') | | 57 | +major=$(echo $host_gcc_version | awk -F . '{print $1}') | | 58 | +minor=$(echo $host_gcc_version | awk -F . '{print $2}') | | 59 | +if [ -z $major ] || [ -z $minor ] || [ $major -lt 6 ] || [ $major -eq 6 -a $minor -lt 3 ]; then | | 60 | + echo "host gcc $host_gcc_version is too old, need gcc 6.3.0" | | 61 | + exit 1 | 60 | 62 | fi | | 63 | + | | 64 | +SUFFIX="$TOOLCHAIN_NAME$ANDROID_SDK_VERSION" | | 65 | +TOOLCHAIN=$NDK_PATH/toolchains/llvm/prebuilt/$HOST_OS-$HOST_ARCH | | 66 | + | 61 | 67 | export PATH=$TOOLCHAIN/bin:$PATH | 62 | | -export AR=$TOOLCHAIN/bin/$SUFFIX-ar | 63 | | -export CC=$TOOLCHAIN/bin/$SUFFIX-gcc | 64 | | -export CXX=$TOOLCHAIN/bin/$SUFFIX-g++ | 65 | | -export LINK=$TOOLCHAIN/bin/$SUFFIX-g++ | | 68 | +export CC=$TOOLCHAIN/bin/$SUFFIX-clang | | 69 | +export CXX=$TOOLCHAIN/bin/$SUFFIX-clang++ | | 70 | + | 66 | 71 |
| 67 | 72 | GYP_DEFINES="target_arch=$ARCH" | 68 | 73 | GYP_DEFINES+=" v8_target_arch=$ARCH" | 69 | 74 | GYP_DEFINES+=" android_target_arch=$ARCH" | 70 | | -GYP_DEFINES+=" host_os=linux OS=android" | | 75 | +GYP_DEFINES+=" host_os=$HOST_OS OS=android" | 71 | 76 | export GYP_DEFINES | 72 | 77 |
| 73 | 78 | if [ -f "configure" ]; then | 74 | 79 | ./configure \ | 75 | 80 | --dest-cpu=$DEST_CPU \ | 76 | 81 | --dest-os=android \ | 77 | 82 | --without-snapshot \ | 78 | | - --openssl-no-asm | | 83 | + --openssl-no-asm \ | | 84 | + --cross-compiling | 79 | 85 | fi |
Collapse file Copy file name to clipboardExpand all lines: common.gypi +4Lines changed: 4 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 442 | 442 | 'defines': [ '_GLIBCXX_USE_C99_MATH' ], | 443 | 443 | 'libraries': [ '-llog' ], | 444 | 444 | }], | | 445 | + ['_toolset=="host"', { | | 446 | + 'cflags': [ '-pthread' ], | | 447 | + 'ldflags': [ '-pthread' ], | | 448 | + }], | 445 | 449 | ], | 446 | 450 | }], | 447 | 451 | ['OS=="mac"', { | |
Collapse file Copy file name to clipboardExpand all lines: deps/cares/config/android/ares_config.h +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 128 | 128 | #define HAVE_GETNAMEINFO 1 | 129 | 129 |
| 130 | 130 | /* Define to 1 if you have the getservbyport_r function. */ | 131 | | -#define HAVE_GETSERVBYPORT_R 1 | | 131 | +/* #undef HAVE_GETSERVBYPORT_R */ | 132 | 132 |
| 133 | 133 | /* Define to 1 if you have the `gettimeofday' function. */ | 134 | 134 | #define HAVE_GETTIMEOFDAY 1 | |
Collapse file Copy file name to clipboardExpand all lines: deps/openssl/openssl-cl_no_asm.gypi +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 12 | 12 | 'includes': ['config/archs/linux-ppc64/no-asm/openssl-cl.gypi'], | 13 | 13 | }, 'target_arch=="s390x" and OS=="linux"', { | 14 | 14 | 'includes': ['config/archs/linux64-s390x/no-asm/openssl-cl.gypi'], | 15 | | - }, 'target_arch=="arm" and OS=="linux"', { | | 15 | + }, 'target_arch=="arm" and OS in ("linux", "android")', { | 16 | 16 | 'includes': ['config/archs/linux-armv4/no-asm/openssl-cl.gypi'], | 17 | | - }, 'target_arch=="arm64" and OS=="linux"', { | | 17 | + }, 'target_arch=="arm64" and OS in ("linux", "android")', { | 18 | 18 | 'includes': ['config/archs/linux-aarch64/no-asm/openssl-cl.gypi'], | 19 | 19 | }, 'target_arch=="arm64" and OS=="win"', { | 20 | 20 | 'includes': ['config/archs/VC-WIN64-ARM/no-asm/openssl-cl.gypi'], | |
Collapse file Copy file name to clipboardExpand all lines: deps/openssl/openssl_no_asm.gypi +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 13 | 13 | 'includes': ['config/archs/linux-ppc64/no-asm/openssl.gypi'], | 14 | 14 | }, 'target_arch=="s390x" and OS=="linux"', { | 15 | 15 | 'includes': ['config/archs/linux64-s390x/no-asm/openssl.gypi'], | 16 | | - }, 'target_arch=="arm" and OS=="linux"', { | | 16 | + }, 'target_arch=="arm" and OS in ("linux", "android")', { | 17 | 17 | 'includes': ['config/archs/linux-armv4/no-asm/openssl.gypi'], | 18 | | - }, 'target_arch=="arm64" and OS=="linux"', { | | 18 | + }, 'target_arch=="arm64" and OS in ("linux", "android")', { | 19 | 19 | 'includes': ['config/archs/linux-aarch64/no-asm/openssl.gypi'], | 20 | 20 | }, 'target_arch=="ia32" and OS=="freebsd"', { | 21 | 21 | 'includes': ['config/archs/BSD-x86/no-asm/openssl.gypi'], | |
Collapse file Copy file name to clipboardExpand all lines: deps/uv/uv.gyp +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 261 | 261 | 'src/unix/android-ifaddrs.c', | 262 | 262 | 'src/unix/procfs-exepath.c', | 263 | 263 | 'src/unix/random-getrandom.c', | | 264 | + 'src/unix/random-getentropy.c', | 264 | 265 | 'src/unix/random-sysctl-linux.c', | 265 | 266 | 'src/unix/sysinfo-loadavg.c', | 266 | 267 | ], | |
Collapse file Copy file name to clipboardExpand all lines: tools/gyp/pylib/gyp/generator/make.py +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -201,7 +201,7 @@ def CalculateGeneratorInputInfo(params): | 201 | 201 | quiet_cmd_link = LINK($(TOOLSET)) $@ | 202 | 202 | quiet_cmd_link_host = LINK($(TOOLSET)) $@ | 203 | 203 | cmd_link = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ -Wl,--start-group $(LD_INPUTS) -Wl,--end-group $(LIBS) | 204 | | -cmd_link_host = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $(LD_INPUTS) $(LIBS) | | 204 | +cmd_link_host = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ -Wl,--start-group $(LD_INPUTS) -Wl,--end-group $(LIBS) | 205 | 205 |
| 206 | 206 | # Other shared-object link notes: | 207 | 207 | # - Set SONAME to the library filename so our binaries don't reference | |
Collapse file Copy file name to clipboardExpand all lines: tools/v8_gypfiles/v8.gyp +17-27Lines changed: 17 additions & 27 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 956 | 956 | }], | 957 | 957 | ['is_android', { | 958 | 958 | 'sources': [ | 959 | | - '<(V8_ROOT)/src/base/debug/stack_trace_android.cc', | 960 | 959 | '<(V8_ROOT)/src/base/platform/platform-posix.cc', | 961 | 960 | '<(V8_ROOT)/src/base/platform/platform-posix.h', | 962 | 961 | '<(V8_ROOT)/src/base/platform/platform-posix-time.cc', | 963 | 962 | '<(V8_ROOT)/src/base/platform/platform-posix-time.h', | 964 | 963 | ], | 965 | | - 'conditions': [ | 966 | | - ['_toolset=="host"', { | 967 | | - 'link_settings': { | | 964 | + 'link_settings': { | | 965 | + 'target_conditions': [ | | 966 | + ['_toolset=="host" and host_os=="linux"', { | 968 | 967 | 'libraries': [ | 969 | 968 | '-ldl', | 970 | 969 | '-lrt' | 971 | | - ] | 972 | | - }, | 973 | | - 'conditions': [ | 974 | | - ['_toolset=="host"', { | 975 | | - 'conditions': [ | 976 | | - ['host_os == "mac"', { | 977 | | - 'sources': [ | 978 | | - '<(V8_ROOT)/src/base/debug/stack_trace_posix.cc' | 979 | | - '<(V8_ROOT)/src/base/platform/platform-macos.cc' | 980 | | - ] | 981 | | - }, { | 982 | | - 'sources': [ | 983 | | - '<(V8_ROOT)/src/base/debug/stack_trace_posix.cc' | 984 | | - '<(V8_ROOT)/src/base/platform/platform-linux.cc' | 985 | | - ] | 986 | | - }], | 987 | | - ], | 988 | | - }, { | 989 | | - 'sources': [ | 990 | | - '<(V8_ROOT)/src/base/debug/stack_trace_android.cc' | 991 | | - '<(V8_ROOT)/src/base/platform/platform-linux.cc' | 992 | | - ] | 993 | | - }], | | 970 | + ], | | 971 | + }], | | 972 | + ], | | 973 | + }, | | 974 | + 'target_conditions': [ | | 975 | + ['_toolset=="host"', { | | 976 | + 'sources': [ | | 977 | + '<(V8_ROOT)/src/base/debug/stack_trace_posix.cc', | | 978 | + '<(V8_ROOT)/src/base/platform/platform-linux.cc', | | 979 | + ], | | 980 | + }, { | | 981 | + 'sources': [ | | 982 | + '<(V8_ROOT)/src/base/debug/stack_trace_android.cc', | | 983 | + '<(V8_ROOT)/src/base/platform/platform-linux.cc', | 994 | 984 | ], | 995 | 985 | }], | 996 | 986 | ], | |
|