mirror of
https://github.com/zebrajr/node.git
synced 2025-12-06 12:20:27 +01:00
build: support android build on ndk version equal or above 23
change scripts and sources for android build, don't need standalone toolchain after ndk 19, and use clang as default android target compiler. PR-URL: https://github.com/nodejs/node/pull/31521 Reviewed-By: Christian Clauss <cclauss@me.com>
This commit is contained in:
parent
ecf842ec27
commit
e65586985f
|
|
@ -8,29 +8,39 @@
|
|||
# modules with npm. Also, don't forget to set the arch in npm config using
|
||||
# 'npm config set arch=<arch>'
|
||||
|
||||
if [ $# -ne 3 ]; then
|
||||
echo "$0 should have 3 parameters: ndk_path, target_arch and sdk_version"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$2" ]; then
|
||||
ARCH=arm
|
||||
else
|
||||
NDK_PATH=$1
|
||||
ARCH="$2"
|
||||
ANDROID_SDK_VERSION=$3
|
||||
|
||||
if [ $ANDROID_SDK_VERSION -lt 23 ]; then
|
||||
echo "$ANDROID_SDK_VERSION should equal or later than 23(Android 6.0)"
|
||||
fi
|
||||
|
||||
CC_VER="4.9"
|
||||
|
||||
case $ARCH in
|
||||
arm)
|
||||
DEST_CPU="$ARCH"
|
||||
SUFFIX="$ARCH-linux-androideabi"
|
||||
TOOLCHAIN_NAME="$SUFFIX"
|
||||
DEST_CPU="arm"
|
||||
TOOLCHAIN_NAME="armv7-linux-androideabi"
|
||||
;;
|
||||
x86)
|
||||
DEST_CPU="ia32"
|
||||
SUFFIX="i686-linux-android"
|
||||
TOOLCHAIN_NAME="$ARCH"
|
||||
TOOLCHAIN_NAME="i686-linux-android"
|
||||
;;
|
||||
x86_64)
|
||||
DEST_CPU="ia32"
|
||||
SUFFIX="$ARCH-linux-android"
|
||||
TOOLCHAIN_NAME="$ARCH"
|
||||
DEST_CPU="x64"
|
||||
TOOLCHAIN_NAME="x86_64-linux-android"
|
||||
ARCH="x64"
|
||||
;;
|
||||
arm64|aarch64)
|
||||
DEST_CPU="arm64"
|
||||
TOOLCHAIN_NAME="aarch64-linux-android"
|
||||
ARCH="arm64"
|
||||
;;
|
||||
*)
|
||||
echo "Unsupported architecture provided: $ARCH"
|
||||
|
|
@ -38,36 +48,31 @@ case $ARCH in
|
|||
;;
|
||||
esac
|
||||
|
||||
NDK_PATH=$1
|
||||
function make_toolchain {
|
||||
$NDK_PATH/build/tools/make-standalone-toolchain.sh \
|
||||
--toolchain=$TOOLCHAIN_NAME-$CC_VER \
|
||||
--arch=$ARCH \
|
||||
--install-dir=$TOOLCHAIN \
|
||||
--platform=android-21
|
||||
}
|
||||
HOST_OS="linux"
|
||||
HOST_ARCH="x86_64"
|
||||
export CC_host=$(which gcc)
|
||||
export CXX_host=$(which g++)
|
||||
|
||||
export TOOLCHAIN=$PWD/android-toolchain
|
||||
if [ -d "$TOOLCHAIN" ]; then
|
||||
read -r -p "NDK toolchain already exists. Replace it? [y/N]" response
|
||||
case "$response" in
|
||||
[Yy])
|
||||
rm -rf "$TOOLCHAIN"
|
||||
make_toolchain
|
||||
esac
|
||||
else
|
||||
make_toolchain
|
||||
host_gcc_version=$($CC_host --version | grep gcc | awk '{print $NF}')
|
||||
major=$(echo $host_gcc_version | awk -F . '{print $1}')
|
||||
minor=$(echo $host_gcc_version | awk -F . '{print $2}')
|
||||
if [ -z $major ] || [ -z $minor ] || [ $major -lt 6 ] || [ $major -eq 6 -a $minor -lt 3 ]; then
|
||||
echo "host gcc $host_gcc_version is too old, need gcc 6.3.0"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
SUFFIX="$TOOLCHAIN_NAME$ANDROID_SDK_VERSION"
|
||||
TOOLCHAIN=$NDK_PATH/toolchains/llvm/prebuilt/$HOST_OS-$HOST_ARCH
|
||||
|
||||
export PATH=$TOOLCHAIN/bin:$PATH
|
||||
export AR=$TOOLCHAIN/bin/$SUFFIX-ar
|
||||
export CC=$TOOLCHAIN/bin/$SUFFIX-gcc
|
||||
export CXX=$TOOLCHAIN/bin/$SUFFIX-g++
|
||||
export LINK=$TOOLCHAIN/bin/$SUFFIX-g++
|
||||
export CC=$TOOLCHAIN/bin/$SUFFIX-clang
|
||||
export CXX=$TOOLCHAIN/bin/$SUFFIX-clang++
|
||||
|
||||
|
||||
GYP_DEFINES="target_arch=$ARCH"
|
||||
GYP_DEFINES+=" v8_target_arch=$ARCH"
|
||||
GYP_DEFINES+=" android_target_arch=$ARCH"
|
||||
GYP_DEFINES+=" host_os=linux OS=android"
|
||||
GYP_DEFINES+=" host_os=$HOST_OS OS=android"
|
||||
export GYP_DEFINES
|
||||
|
||||
if [ -f "configure" ]; then
|
||||
|
|
@ -75,5 +80,6 @@ if [ -f "configure" ]; then
|
|||
--dest-cpu=$DEST_CPU \
|
||||
--dest-os=android \
|
||||
--without-snapshot \
|
||||
--openssl-no-asm
|
||||
--openssl-no-asm \
|
||||
--cross-compiling
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -442,6 +442,10 @@
|
|||
'defines': [ '_GLIBCXX_USE_C99_MATH' ],
|
||||
'libraries': [ '-llog' ],
|
||||
}],
|
||||
['_toolset=="host"', {
|
||||
'cflags': [ '-pthread' ],
|
||||
'ldflags': [ '-pthread' ],
|
||||
}],
|
||||
],
|
||||
}],
|
||||
['OS=="mac"', {
|
||||
|
|
|
|||
2
deps/cares/config/android/ares_config.h
vendored
2
deps/cares/config/android/ares_config.h
vendored
|
|
@ -128,7 +128,7 @@
|
|||
#define HAVE_GETNAMEINFO 1
|
||||
|
||||
/* Define to 1 if you have the getservbyport_r function. */
|
||||
#define HAVE_GETSERVBYPORT_R 1
|
||||
/* #undef HAVE_GETSERVBYPORT_R */
|
||||
|
||||
/* Define to 1 if you have the `gettimeofday' function. */
|
||||
#define HAVE_GETTIMEOFDAY 1
|
||||
|
|
|
|||
4
deps/openssl/openssl-cl_no_asm.gypi
vendored
4
deps/openssl/openssl-cl_no_asm.gypi
vendored
|
|
@ -12,9 +12,9 @@
|
|||
'includes': ['config/archs/linux-ppc64/no-asm/openssl-cl.gypi'],
|
||||
}, 'target_arch=="s390x" and OS=="linux"', {
|
||||
'includes': ['config/archs/linux64-s390x/no-asm/openssl-cl.gypi'],
|
||||
}, 'target_arch=="arm" and OS=="linux"', {
|
||||
}, 'target_arch=="arm" and OS in ("linux", "android")', {
|
||||
'includes': ['config/archs/linux-armv4/no-asm/openssl-cl.gypi'],
|
||||
}, 'target_arch=="arm64" and OS=="linux"', {
|
||||
}, 'target_arch=="arm64" and OS in ("linux", "android")', {
|
||||
'includes': ['config/archs/linux-aarch64/no-asm/openssl-cl.gypi'],
|
||||
}, 'target_arch=="arm64" and OS=="win"', {
|
||||
'includes': ['config/archs/VC-WIN64-ARM/no-asm/openssl-cl.gypi'],
|
||||
|
|
|
|||
4
deps/openssl/openssl_no_asm.gypi
vendored
4
deps/openssl/openssl_no_asm.gypi
vendored
|
|
@ -13,9 +13,9 @@
|
|||
'includes': ['config/archs/linux-ppc64/no-asm/openssl.gypi'],
|
||||
}, 'target_arch=="s390x" and OS=="linux"', {
|
||||
'includes': ['config/archs/linux64-s390x/no-asm/openssl.gypi'],
|
||||
}, 'target_arch=="arm" and OS=="linux"', {
|
||||
}, 'target_arch=="arm" and OS in ("linux", "android")', {
|
||||
'includes': ['config/archs/linux-armv4/no-asm/openssl.gypi'],
|
||||
}, 'target_arch=="arm64" and OS=="linux"', {
|
||||
}, 'target_arch=="arm64" and OS in ("linux", "android")', {
|
||||
'includes': ['config/archs/linux-aarch64/no-asm/openssl.gypi'],
|
||||
}, 'target_arch=="ia32" and OS=="freebsd"', {
|
||||
'includes': ['config/archs/BSD-x86/no-asm/openssl.gypi'],
|
||||
|
|
|
|||
1
deps/uv/uv.gyp
vendored
1
deps/uv/uv.gyp
vendored
|
|
@ -261,6 +261,7 @@
|
|||
'src/unix/android-ifaddrs.c',
|
||||
'src/unix/procfs-exepath.c',
|
||||
'src/unix/random-getrandom.c',
|
||||
'src/unix/random-getentropy.c',
|
||||
'src/unix/random-sysctl-linux.c',
|
||||
'src/unix/sysinfo-loadavg.c',
|
||||
],
|
||||
|
|
|
|||
|
|
@ -201,7 +201,7 @@ cmd_alink_thin = rm -f $@ && $(AR.$(TOOLSET)) crsT $@ $(filter %.o,$^)
|
|||
quiet_cmd_link = LINK($(TOOLSET)) $@
|
||||
quiet_cmd_link_host = LINK($(TOOLSET)) $@
|
||||
cmd_link = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ -Wl,--start-group $(LD_INPUTS) -Wl,--end-group $(LIBS)
|
||||
cmd_link_host = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $(LD_INPUTS) $(LIBS)
|
||||
cmd_link_host = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ -Wl,--start-group $(LD_INPUTS) -Wl,--end-group $(LIBS)
|
||||
|
||||
# Other shared-object link notes:
|
||||
# - Set SONAME to the library filename so our binaries don't reference
|
||||
|
|
|
|||
|
|
@ -956,41 +956,31 @@
|
|||
}],
|
||||
['is_android', {
|
||||
'sources': [
|
||||
'<(V8_ROOT)/src/base/debug/stack_trace_android.cc',
|
||||
'<(V8_ROOT)/src/base/platform/platform-posix.cc',
|
||||
'<(V8_ROOT)/src/base/platform/platform-posix.h',
|
||||
'<(V8_ROOT)/src/base/platform/platform-posix-time.cc',
|
||||
'<(V8_ROOT)/src/base/platform/platform-posix-time.h',
|
||||
],
|
||||
'conditions': [
|
||||
['_toolset=="host"', {
|
||||
'link_settings': {
|
||||
'target_conditions': [
|
||||
['_toolset=="host" and host_os=="linux"', {
|
||||
'libraries': [
|
||||
'-ldl',
|
||||
'-lrt'
|
||||
]
|
||||
},
|
||||
'conditions': [
|
||||
['_toolset=="host"', {
|
||||
'conditions': [
|
||||
['host_os == "mac"', {
|
||||
'sources': [
|
||||
'<(V8_ROOT)/src/base/debug/stack_trace_posix.cc'
|
||||
'<(V8_ROOT)/src/base/platform/platform-macos.cc'
|
||||
]
|
||||
}, {
|
||||
'sources': [
|
||||
'<(V8_ROOT)/src/base/debug/stack_trace_posix.cc'
|
||||
'<(V8_ROOT)/src/base/platform/platform-linux.cc'
|
||||
]
|
||||
],
|
||||
}],
|
||||
],
|
||||
},
|
||||
'target_conditions': [
|
||||
['_toolset=="host"', {
|
||||
'sources': [
|
||||
'<(V8_ROOT)/src/base/debug/stack_trace_posix.cc',
|
||||
'<(V8_ROOT)/src/base/platform/platform-linux.cc',
|
||||
],
|
||||
}, {
|
||||
'sources': [
|
||||
'<(V8_ROOT)/src/base/debug/stack_trace_android.cc'
|
||||
'<(V8_ROOT)/src/base/platform/platform-linux.cc'
|
||||
]
|
||||
}],
|
||||
'<(V8_ROOT)/src/base/debug/stack_trace_android.cc',
|
||||
'<(V8_ROOT)/src/base/platform/platform-linux.cc',
|
||||
],
|
||||
}],
|
||||
],
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user