diff --git a/android-configure b/android-configure index 1dc238e..ab1f38c 100755 --- a/android-configure +++ b/android-configure @@ -18,10 +18,15 @@ fi CC_VER="4.9" case $ARCH in arm) - DEST_CPU="$ARCH" + DEST_CPU="${ARCH}" SUFFIX="$ARCH-linux-androideabi" TOOLCHAIN_NAME="$SUFFIX" ;; + arm64) + DEST_CPU="${ARCH}" + SUFFIX="aarch64-linux-android" + TOOLCHAIN_NAME="$SUFFIX" + ;; x86) DEST_CPU="ia32" SUFFIX="i686-linux-android" @@ -50,6 +55,10 @@ 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 AR_host=ar +export CC_host=gcc +export CXX_host=g++ +export LINK_host=g++ GYP_DEFINES="target_arch=$ARCH" GYP_DEFINES+=" v8_target_arch=$ARCH" @@ -57,6 +66,11 @@ GYP_DEFINES+=" android_target_arch=$ARCH" GYP_DEFINES+=" host_os=linux OS=android" export GYP_DEFINES +# You might want to add the following options if you target arm or arm64 +# --enable-static to build node as static lib +# --with-intl=none to disable icu because it's quite bothersome to add support +# for it in android and it bloats outputs a lot + if [ -f "configure" ]; then ./configure \ --dest-cpu=$DEST_CPU \ diff --git a/arch.gypi b/arch.gypi new file mode 100644 index 0000000..894ad9c --- /dev/null +++ b/arch.gypi @@ -0,0 +1,54 @@ +{ + 'conditions': [ + [ 'target_arch=="ia32"', { + 'cflags': [ '-m32' ], + 'ldflags': [ '-m32' ], + }], + [ 'target_arch=="x32"', { + 'cflags': [ '-mx32' ], + 'ldflags': [ '-mx32' ], + }], + [ 'target_arch=="x64"', { + 'cflags': [ '-m64' ], + 'ldflags': [ '-m64' ], + }], + [ 'target_arch=="ppc" and OS!="aix"', { + 'cflags': [ '-m32' ], + 'ldflags': [ '-m32' ], + }], + [ 'target_arch=="ppc64" and OS!="aix"', { + 'cflags': [ '-m64', '-mminimal-toc' ], + 'ldflags': [ '-m64' ], + }], + [ 'target_arch=="s390"', { + 'cflags': [ '-m31' ], + 'ldflags': [ '-m31' ], + }], + [ 'target_arch=="s390x"', { + 'cflags': [ '-m64' ], + 'ldflags': [ '-m64' ], + }], + [ 'OS=="solaris"', { + 'cflags': [ '-pthreads' ], + 'ldflags': [ '-pthreads' ], + 'cflags!': [ '-pthread' ], + 'ldflags!': [ '-pthread' ], + }], + [ 'OS=="aix"', { + 'conditions': [ + [ 'target_arch=="ppc"', { + 'ldflags': [ '-Wl,-bmaxdata:0x60000000/dsa' ], + }], + [ 'target_arch=="ppc64"', { + 'cflags': [ '-maix64' ], + 'ldflags': [ '-maix64' ], + }], + ], + 'ldflags': [ '-Wl,-bbigtoc' ], + 'ldflags!': [ '-rdynamic' ], + }], + [ 'node_shared=="true"', { + 'cflags': [ '-fPIC' ], + }], + ], +} diff --git a/common.gypi b/common.gypi index 646db0d..cf8b124 100644 --- a/common.gypi +++ b/common.gypi @@ -247,64 +247,18 @@ ['_type=="static_library"', { 'standalone_static_library': 1, # disable thin archive which needs binutils >= 2.19 }], - ], - 'conditions': [ - [ 'target_arch=="ia32"', { - 'cflags': [ '-m32' ], - 'ldflags': [ '-m32' ], - }], - [ 'target_arch=="x32"', { - 'cflags': [ '-mx32' ], - 'ldflags': [ '-mx32' ], - }], - [ 'target_arch=="x64"', { - 'cflags': [ '-m64' ], - 'ldflags': [ '-m64' ], - }], - [ 'target_arch=="ppc" and OS!="aix"', { - 'cflags': [ '-m32' ], - 'ldflags': [ '-m32' ], - }], - [ 'target_arch=="ppc64" and OS!="aix"', { - 'cflags': [ '-m64', '-mminimal-toc' ], - 'ldflags': [ '-m64' ], - }], - [ 'target_arch=="s390"', { - 'cflags': [ '-m31' ], - 'ldflags': [ '-m31' ], - }], - [ 'target_arch=="s390x"', { - 'cflags': [ '-m64' ], - 'ldflags': [ '-m64' ], - }], - [ 'OS=="solaris"', { - 'cflags': [ '-pthreads' ], - 'ldflags': [ '-pthreads' ], - 'cflags!': [ '-pthread' ], - 'ldflags!': [ '-pthread' ], - }], - [ 'OS=="aix"', { - 'conditions': [ - [ 'target_arch=="ppc"', { - 'ldflags': [ '-Wl,-bmaxdata:0x60000000/dsa' ], - }], - [ 'target_arch=="ppc64"', { - 'cflags': [ '-maix64' ], - 'ldflags': [ '-maix64' ], - }], - ], - 'ldflags': [ '-Wl,-bbigtoc' ], - 'ldflags!': [ '-rdynamic' ], - }], - [ 'node_shared=="true"', { - 'cflags': [ '-fPIC' ], + ['_toolset=="host"', { + 'includes': [ 'arch.gypi' ], + }], + ['_toolset=="target"', { + 'includes': [ 'arch.gypi' ], }], + ['OS=="android" and _toolset=="target"', { + 'defines': ['_GLIBCXX_USE_C99_MATH'], + 'libraries': [ '-llog' ], + }], ], - }], - [ 'OS=="android"', { - 'defines': ['_GLIBCXX_USE_C99_MATH'], - 'libraries': [ '-llog' ], - }], + }], ['OS=="mac"', { 'defines': ['_DARWIN_USE_64_BIT_INODE=1'], 'xcode_settings': {