1
0
mirror of https://github.com/libuv/libuv synced 2025-03-28 21:13:16 +00:00

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 <info@bnoordhuis.nl>
This commit is contained in:
Andy Zhang 2018-09-14 13:35:53 +08:00 committed by Ben Noordhuis
parent 153ea114ff
commit baa81465ad
5 changed files with 96 additions and 2 deletions

View File

@ -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
```

View File

@ -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 \

23
android-configure-arm64 Executable file
View File

@ -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

23
android-configure-x86 Executable file
View File

@ -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

25
android-configure-x86_64 Executable file
View File

@ -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