From baa81465ad85992edf0cb9ac8a15b7d5e0faac12 Mon Sep 17 00:00:00 2001 From: Andy Zhang Date: Fri, 14 Sep 2018 13:35:53 +0800 Subject: [PATCH] build: add compile for android arm64/x86/x86-64 Add compile options for Android arm64/x86/x86-64 and update the instructions in README.md. PR-URL: https://github.com/libuv/libuv/pull/1934 Reviewed-By: Ben Noordhuis --- README.md | 25 +++++++++++++++++++++- android-configure => android-configure-arm | 2 +- android-configure-arm64 | 23 ++++++++++++++++++++ android-configure-x86 | 23 ++++++++++++++++++++ android-configure-x86_64 | 25 ++++++++++++++++++++++ 5 files changed, 96 insertions(+), 2 deletions(-) rename android-configure => android-configure-arm (92%) create mode 100755 android-configure-arm64 create mode 100755 android-configure-x86 create mode 100755 android-configure-x86_64 diff --git a/README.md b/README.md index 23674719..b24b7226 100644 --- a/README.md +++ b/README.md @@ -282,8 +282,31 @@ Make sure that you specify the architecture you wish to build for in the Run: +For arm + ```bash -$ source ./android-configure NDK_PATH gyp [API_LEVEL] +$ source ./android-configure-arm NDK_PATH gyp [API_LEVEL] +$ make -C out +``` + +or for arm64 + +```bash +$ source ./android-configure-arm64 NDK_PATH gyp [API_LEVEL] +$ make -C out +``` + +or for x86 + +```bash +$ source ./android-configure-x86 NDK_PATH gyp [API_LEVEL] +$ make -C out +``` + +or for x86_64 + +```bash +$ source ./android-configure-x86_64 NDK_PATH gyp [API_LEVEL] $ make -C out ``` diff --git a/android-configure b/android-configure-arm similarity index 92% rename from android-configure rename to android-configure-arm index b5c11cd4..331fdd9e 100755 --- a/android-configure +++ b/android-configure-arm @@ -1,6 +1,6 @@ #!/bin/bash -export TOOLCHAIN=$PWD/android-toolchain +export TOOLCHAIN=$PWD/android-toolchain-arm mkdir -p $TOOLCHAIN API=${3:-24} $1/build/tools/make-standalone-toolchain.sh \ diff --git a/android-configure-arm64 b/android-configure-arm64 new file mode 100755 index 00000000..1acd905d --- /dev/null +++ b/android-configure-arm64 @@ -0,0 +1,23 @@ +#!/bin/bash + +export TOOLCHAIN=$PWD/android-toolchain-arm64 +mkdir -p $TOOLCHAIN +API=${3:-24} +$1/build/tools/make-standalone-toolchain.sh \ + --toolchain=aarch64-linux-android-4.9 \ + --arch=arm64 \ + --install-dir=$TOOLCHAIN \ + --platform=android-$API \ + --force +export PATH=$TOOLCHAIN/bin:$PATH +export AR=aarch64-linux-android-ar +export CC=aarch64-linux-android-gcc +export CXX=aarch64-linux-android-g++ +export LINK=aarch64-linux-android-g++ +export PLATFORM=android +export CFLAGS="-D__ANDROID_API__=$API" + +if [[ $2 == 'gyp' ]] + then + ./gyp_uv.py -Dtarget_arch=arm64 -DOS=android -f make-android +fi diff --git a/android-configure-x86 b/android-configure-x86 new file mode 100755 index 00000000..a149715f --- /dev/null +++ b/android-configure-x86 @@ -0,0 +1,23 @@ +#!/bin/bash + +export TOOLCHAIN=$PWD/android-toolchain-x86 +mkdir -p $TOOLCHAIN +API=${3:-24} +$1/build/tools/make-standalone-toolchain.sh \ + --toolchain=x86-4.9 \ + --arch=x86 \ + --install-dir=$TOOLCHAIN \ + --platform=android-$API \ + --force +export PATH=$TOOLCHAIN/bin:$PATH +export AR=i686-linux-android-ar +export CC=i686-linux-android-gcc +export CXX=i686-linux-android-g++ +export LINK=i686-linux-android-g++ +export PLATFORM=android +export CFLAGS="-D__ANDROID_API__=$API" + +if [[ $2 == 'gyp' ]] + then + ./gyp_uv.py -Dtarget_arch=x86 -DOS=android -f make-android +fi diff --git a/android-configure-x86_64 b/android-configure-x86_64 new file mode 100755 index 00000000..ff045957 --- /dev/null +++ b/android-configure-x86_64 @@ -0,0 +1,25 @@ +#!/bin/bash + +export TOOLCHAIN=$PWD/android-toolchain-x86_64 +mkdir -p $TOOLCHAIN +API=${3:-24} +$1/build/tools/make-standalone-toolchain.sh \ + --toolchain=x86_64-4.9 \ + --arch=x86_64 \ + --install-dir=$TOOLCHAIN \ + --platform=android-$API \ + --force +export PATH=$TOOLCHAIN/bin:$PATH +export AR=x86_64-linux-android-ar +export CC=x86_64-linux-android-gcc +export CXX=x86_64-linux-android-g++ +export LINK=x86_64-linux-android-g++ +export PLATFORM=android +export CFLAGS="-D__ANDROID_API__=$API -fPIC" +export CXXFLAGS="-D__ANDROID_API__=$API -fPIC" +export LDFLAGS="-fPIC" + +if [[ $2 == 'gyp' ]] + then + ./gyp_uv.py -Dtarget_arch=x86_64 -DOS=android -f make-android +fi