update build script

This commit is contained in:
fuwa
2018-07-25 16:02:52 +00:00
parent c1ef6a9d58
commit 5317f4773e
13 changed files with 99 additions and 1165 deletions
+1
View File
@@ -10,3 +10,4 @@
opt
vendor
external-libs/monero
+6 -102
View File
@@ -1,9 +1,3 @@
# Notes for the wownerujo port
* all the steps in this guide are packaged in `script/all.sh`
* update android sdk to the latest version
* manually run through all the scripts, expect to install any missing tools on your system
# BUILDING external libs
Based on https://forum.getmonero.org/5/support/87643/building-monero-v0-10-3-1-for-android and the internet.
@@ -14,113 +8,23 @@ These instructions are tailored to building ```wallep_api```.
These instructions build all supported architectures: ```'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'```.
Yes, lots of copy&paste here. TODO: Script this.
## Prepare Ubuntu environment
```Shell
sudo apt-get install build-essential cmake tofrodos libtool-bin
sudo mkdir /opt/android
sudo chown $LOGNAME /opt/android
```
## Install Android NDK
```Shell
cd /opt/android
wget https://dl.google.com/android/repository/android-ndk-r16b-linux-x86_64.zip
unzip android-ndk-r16b-linux-x86_64.zip
ln -s android-ndk-r16b ndk
ndk/build/tools/make_standalone_toolchain.py --api 21 --stl=libc++ --arch arm --install-dir /opt/android/tool/arm
ndk/build/tools/make_standalone_toolchain.py --api 21 --stl=libc++ --arch arm64 --install-dir /opt/android/tool/arm64
ndk/build/tools/make_standalone_toolchain.py --api 21 --stl=libc++ --arch x86 --install-dir /opt/android/tool/x86
ndk/build/tools/make_standalone_toolchain.py --api 21 --stl=libc++ --arch x86_64 --install-dir /opt/android/tool/x86_64
```
## Prepare output
```Shell
mkdir -p /opt/android/build
```
## Build OpenSSL
Best is to compile openssl from sources. Copying from your phone or elsewhere (don't!) ends up in misery.
If you don't want to build for all architectures, edit ```build-all-arch.sh``` before running it (Line 12).
* Install NDK: <https://developer.android.com/ndk/guides/>
* set `$ANDROID_NDK_ROOT`, for example:
```Shell
cd /opt/android
git clone https://github.com/m2049r/android-openssl.git
wget https://github.com/openssl/openssl/archive/OpenSSL_1_0_2l.tar.gz
cd android-openssl
tar xfz ../OpenSSL_1_0_2l.tar.gz
ANDROID_NDK_ROOT=/opt/android/ndk ./build-all-arch.sh
export $ANDROID_NDK_ROOT=~/Android/Sdk/ndk-bundle
```
### Install & make symlinks
## Build
```Shell
mkdir -p /opt/android/build/openssl/{arm,arm64,x86,x86_64}
cp -a /opt/android/android-openssl/prebuilt/armeabi /opt/android/build/openssl/arm/lib
cp -a /opt/android/android-openssl/prebuilt/arm64-v8a /opt/android/build/openssl/arm64/lib
cp -a /opt/android/android-openssl/prebuilt/x86 /opt/android/build/openssl/x86/lib
cp -a /opt/android/android-openssl/prebuilt/x86_64 /opt/android/build/openssl/x86_64/lib
cp -aL /opt/android/android-openssl/openssl-OpenSSL_1_0_2l/include/openssl/ /opt/android/build/openssl/include
ln -s /opt/android/build/openssl/include /opt/android/build/openssl/arm/include
ln -s /opt/android/build/openssl/include /opt/android/build/openssl/arm64/include
ln -s /opt/android/build/openssl/include /opt/android/build/openssl/x86/include
ln -s /opt/android/build/openssl/include /opt/android/build/openssl/x86_64/include
```
```Shell
ln -sf /opt/android/build/openssl/include /opt/android/tool/arm/sysroot/usr/include/openssl
ln -sf /opt/android/build/openssl/arm/lib/*.so /opt/android/tool/arm/sysroot/usr/lib
ln -sf /opt/android/build/openssl/include /opt/android/tool/arm64/sysroot/usr/include/openssl
ln -sf /opt/android/build/openssl/arm64/lib/*.so /opt/android/tool/arm64/sysroot/usr/lib
ln -sf /opt/android/build/openssl/include /opt/android/tool/x86/sysroot/usr/include/openssl
ln -sf /opt/android/build/openssl/x86/lib/*.so /opt/android/tool/x86/sysroot/usr/lib
ln -sf /opt/android/build/openssl/include /opt/android/tool/x86_64/sysroot/usr/include/openssl
ln -sf /opt/android/build/openssl/x86_64/lib/*.so /opt/android/tool/x86_64/sysroot/usr/lib64
```
## Build Boost
```Shell
cd /opt/android
wget https://sourceforge.net/projects/boost/files/boost/1.58.0/boost_1_58_0.tar.gz/download -O boost_1_58_0.tar.gz
tar xfz boost_1_58_0.tar.gz
cd boost_1_58_0
./bootstrap.sh
```
Comment out ```using ::fgetpos;``` & ```using ::fsetpos;``` in ```cstdio```.
Then build & install to ```/opt/android/build/boost``` with
```Shell
PATH=/opt/android/tool/arm/arm-linux-androideabi/bin:/opt/android/tool/arm/bin:$PATH ./b2 --build-type=minimal link=static runtime-link=static --with-chrono --with-date_time --with-filesystem --with-program_options --with-regex --with-serialization --with-system --with-thread --build-dir=android-arm --prefix=/opt/android/build/boost/arm --includedir=/opt/android/build/boost/include toolset=clang threading=multi threadapi=pthread target-os=android install
ln -sf ../include /opt/android/build/boost/arm
PATH=/opt/android/tool/arm64/aarch64-linux-android/bin:/opt/android/tool/arm64/bin:$PATH ./b2 --build-type=minimal link=static runtime-link=static --with-chrono --with-date_time --with-filesystem --with-program_options --with-regex --with-serialization --with-system --with-thread --build-dir=android-arm64 --prefix=/opt/android/build/boost/arm64 --includedir=/opt/android/build/boost/include toolset=clang threading=multi threadapi=pthread target-os=android install
ln -sf ../include /opt/android/build/boost/arm64
PATH=/opt/android/tool/x86/i686-linux-android/bin:/opt/android/tool/x86/bin:$PATH ./b2 --build-type=minimal link=static runtime-link=static --with-chrono --with-date_time --with-filesystem --with-program_options --with-regex --with-serialization --with-system --with-thread --build-dir=android-x86 --prefix=/opt/android/build/boost/x86 --includedir=/opt/android/build/boost/include toolset=clang threading=multi threadapi=pthread target-os=android install
ln -sf ../include /opt/android/build/boost/x86
PATH=/opt/android/tool/x86_64/x86_64-linux-android/bin:/opt/android/tool/x86_64/bin:$PATH ./b2 --build-type=minimal link=static runtime-link=static --with-chrono --with-date_time --with-filesystem --with-program_options --with-regex --with-serialization --with-system --with-thread --build-dir=android-x86_64 --prefix=/opt/android/build/boost/x86_64 --includedir=/opt/android/build/boost/include toolset=clang threading=multi threadapi=pthread target-os=android install
ln -sf ../include /opt/android/build/boost/x86_64
```
## And finally: Build Monero
```Shell
cd /opt/android
git clone https://github.com/m2049r/monero.git
cd /opt/android/monero
./build-all-arch.sh
```
# Bringing it all together
- Copy all .a libraries into the appropriate `external-libs` folders.
- Copy `/opt/android/monero/src/wallet/api/wallet2_api.h` into `external-libs/monero/include`
If using default locations, this would mean:
```Shell
cd <path-to-xmrwallet>/external-libs
# remove old stuff
find . -name "*.a" -or -name "*.h" -type f -delete
./collect.sh
./script/build-external-libs/all.sh
```
+4 -3
View File
@@ -5,6 +5,7 @@
set -e
orig_path=$PATH
build_root=$EXTERNAL_LIBS_BUILD_ROOT
packages=(boost openssl monero)
archs=(arm arm64 x86 x86_64)
@@ -32,11 +33,11 @@ for arch in ${archs[@]}; do
OUTPUT_DIR=`pwd`/$package/lib/$xarch
mkdir -p $OUTPUT_DIR
rm -f $OUTPUT_DIR/*.a
cp -a /opt/android/build/$package/$arch/lib/*.a $OUTPUT_DIR
cp -a $build_root/build/$package/$arch/lib/*.a $OUTPUT_DIR
if [ $package = "monero" -a -d "/opt/android/build/$package/include" ]; then
if [ $package = "monero" -a -d "$build_root/build/$package/include" ]; then
rm -rf $OUTPUT_DIR/../../include
cp -a /opt/android/build/$package/include $OUTPUT_DIR/../..
cp -a $build_root/build/$package/include $OUTPUT_DIR/../..
fi
done
File diff suppressed because it is too large Load Diff
+21 -16
View File
@@ -3,22 +3,27 @@
# make sure $ANDROID_NDK_ROOT is properly set
# for example: export $ANDROID_NDK_ROOT=~/Android/Sdk/ndk-bundle
DEFAULT_ANDROID_NDK_ROOT=~/Android/Sdk/ndk-bundle
ANDROID_NDK_ROOT="${ANDROID_NDK_ROOT:-${DEFAULT_ANDROID_NDK_ROOT}}"
export ANDROID_NDK_ROOT
DEFAULT_EXTERNAL_LIBS_BUILD=`pwd`/build/external-libs
EXTERNAL_LIBS_BUILD_PATH="${EXTERNAL_LIBS_BUILD_PATH:-${DEFAULT_EXTERNAL_LIBS_BUILD}}"
export EXTERNAL_LIBS_BUILD_PATH
source script/build-external-libs/env.sh
echo "ANDROID_NDK_ROOT: " $ANDROID_NDK_ROOT
echo "EXTERNAL_LIBS_BUILD_PATH: " $EXTERNAL_LIBS_BUILD_PATH
echo "EXTERNAL_LIBS_BUILD_ROOT: " $EXTERNAL_LIBS_BUILD_ROOT
script/build-external-libs/prep-toolchain.sh
script/build-external-libs/build-openssl.sh
script/build-external-libs/post-build-openssl.sh
script/build-external-libs/pre-build-boost.sh
script/build-external-libs/build-boost.sh
script/build-external-libs/build-wownero.sh
script/build-external-libs/collect.sh
# script/build-external-libs/prep-toolchain.sh
# script/build-external-libs/build-openssl.sh
# script/build-external-libs/post-build-openssl.sh
# script/build-external-libs/pre-build-boost.sh
# script/build-external-libs/build-boost.sh
# script/build-external-libs/build-wownero.sh
+10 -9
View File
@@ -1,12 +1,13 @@
#!/bin/sh
cd /opt/android/boost_1_58_0
build_root=$EXTERNAL_LIBS_BUILD_ROOT
cd $build_root/boost_1_58_0
PATH=/opt/android/tool/arm/arm-linux-androideabi/bin:/opt/android/tool/arm/bin:$PATH ./b2 --build-type=minimal link=static runtime-link=static --with-chrono --with-date_time --with-filesystem --with-program_options --with-regex --with-serialization --with-system --with-thread --build-dir=android-arm --prefix=/opt/android/build/boost/arm --includedir=/opt/android/build/boost/include toolset=clang threading=multi threadapi=pthread target-os=android install
ln -sf ../include /opt/android/build/boost/arm
PATH=/opt/android/tool/arm64/aarch64-linux-android/bin:/opt/android/tool/arm64/bin:$PATH ./b2 --build-type=minimal link=static runtime-link=static --with-chrono --with-date_time --with-filesystem --with-program_options --with-regex --with-serialization --with-system --with-thread --build-dir=android-arm64 --prefix=/opt/android/build/boost/arm64 --includedir=/opt/android/build/boost/include toolset=clang threading=multi threadapi=pthread target-os=android install
ln -sf ../include /opt/android/build/boost/arm64
PATH=/opt/android/tool/x86/i686-linux-android/bin:/opt/android/tool/x86/bin:$PATH ./b2 --build-type=minimal link=static runtime-link=static --with-chrono --with-date_time --with-filesystem --with-program_options --with-regex --with-serialization --with-system --with-thread --build-dir=android-x86 --prefix=/opt/android/build/boost/x86 --includedir=/opt/android/build/boost/include toolset=clang threading=multi threadapi=pthread target-os=android install
ln -sf ../include /opt/android/build/boost/x86
PATH=/opt/android/tool/x86_64/x86_64-linux-android/bin:/opt/android/tool/x86_64/bin:$PATH ./b2 --build-type=minimal link=static runtime-link=static --with-chrono --with-date_time --with-filesystem --with-program_options --with-regex --with-serialization --with-system --with-thread --build-dir=android-x86_64 --prefix=/opt/android/build/boost/x86_64 --includedir=/opt/android/build/boost/include toolset=clang threading=multi threadapi=pthread target-os=android install
ln -sf ../include /opt/android/build/boost/x86_64
PATH=$build_root/tool/arm/arm-linux-androideabi/bin:$build_root/tool/arm/bin:$PATH ./b2 --build-type=minimal link=static runtime-link=static --with-chrono --with-date_time --with-filesystem --with-program_options --with-regex --with-serialization --with-system --with-thread --build-dir=android-arm --prefix=$build_root/build/boost/arm --includedir=$build_root/build/boost/include toolset=clang threading=multi threadapi=pthread target-os=android install
ln -sf ../include $build_root/build/boost/arm
PATH=$build_root/tool/arm64/aarch64-linux-android/bin:$build_root/tool/arm64/bin:$PATH ./b2 --build-type=minimal link=static runtime-link=static --with-chrono --with-date_time --with-filesystem --with-program_options --with-regex --with-serialization --with-system --with-thread --build-dir=android-arm64 --prefix=$build_root/build/boost/arm64 --includedir=$build_root/build/boost/include toolset=clang threading=multi threadapi=pthread target-os=android install
ln -sf ../include $build_root/build/boost/arm64
PATH=$build_root/tool/x86/i686-linux-android/bin:$build_root/tool/x86/bin:$PATH ./b2 --build-type=minimal link=static runtime-link=static --with-chrono --with-date_time --with-filesystem --with-program_options --with-regex --with-serialization --with-system --with-thread --build-dir=android-x86 --prefix=$build_root/build/boost/x86 --includedir=$build_root/build/boost/include toolset=clang threading=multi threadapi=pthread target-os=android install
ln -sf ../include $build_root/build/boost/x86
PATH=$build_root/tool/x86_64/x86_64-linux-android/bin:$build_root/tool/x86_64/bin:$PATH ./b2 --build-type=minimal link=static runtime-link=static --with-chrono --with-date_time --with-filesystem --with-program_options --with-regex --with-serialization --with-system --with-thread --build-dir=android-x86_64 --prefix=$build_root/build/boost/x86_64 --includedir=$build_root/build/boost/include toolset=clang threading=multi threadapi=pthread target-os=android install
ln -sf ../include $build_root/build/boost/x86_64
+2 -1
View File
@@ -1,6 +1,7 @@
#!/bin/sh
cd /opt/android
cd $EXTERNAL_LIBS_BUILD_ROOT
git clone https://github.com/m2049r/android-openssl.git
wget https://github.com/openssl/openssl/archive/OpenSSL_1_0_2l.tar.gz
cd android-openssl
+2 -2
View File
@@ -1,8 +1,8 @@
#!/bin/sh
cd /opt/android
git clone --recursive -b wownerojo https://github.com/fuwa0529/wownero
cd $EXTERNAL_LIBS_BUILD_ROOT
git clone --recursive -b mobile https://github.com/fuwa0529/wownero
cd wownero
+9
View File
@@ -0,0 +1,9 @@
#!/bin/sh
cd external-libs
find . -name "*.a" -exec rm {} \;
find . -name "*.h" -exec rm {} \;
./collect.sh
+11
View File
@@ -0,0 +1,11 @@
#!/bin/sh
DEFAULT_ANDROID_NDK_ROOT=~/Android/Sdk/ndk-bundle
ANDROID_NDK_ROOT="${ANDROID_NDK_ROOT:-${DEFAULT_ANDROID_NDK_ROOT}}"
export ANDROID_NDK_ROOT
DEFAULT_EXTERNAL_LIBS_BUILD_ROOT=`pwd`/build/external-libs
EXTERNAL_LIBS_BUILD_ROOT="${EXTERNAL_LIBS_BUILD_ROOT:-${DEFAULT_EXTERNAL_LIBS_BUILD_ROOT}}"
export EXTERNAL_LIBS_BUILD_ROOT
@@ -1,26 +1,28 @@
#!/bin/sh
mkdir -p /opt/android/build/openssl/{arm,arm64,x86,x86_64}
build_root=$EXTERNAL_LIBS_BUILD_ROOT
cp -a /opt/android/android-openssl/prebuilt/armeabi /opt/android/build/openssl/arm/lib
cp -a /opt/android/android-openssl/prebuilt/arm64-v8a /opt/android/build/openssl/arm64/lib
cp -a /opt/android/android-openssl/prebuilt/x86 /opt/android/build/openssl/x86/lib
cp -a /opt/android/android-openssl/prebuilt/x86_64 /opt/android/build/openssl/x86_64/lib
cp -aL /opt/android/android-openssl/openssl-OpenSSL_1_0_2l/include/openssl/ /opt/android/build/openssl/include
ln -s /opt/android/build/openssl/include /opt/android/build/openssl/arm/include
ln -s /opt/android/build/openssl/include /opt/android/build/openssl/arm64/include
ln -s /opt/android/build/openssl/include /opt/android/build/openssl/x86/include
ln -s /opt/android/build/openssl/include /opt/android/build/openssl/x86_64/include
mkdir -p $build_root/build/openssl/{arm,arm64,x86,x86_64}
cp -a $build_root/android-openssl/prebuilt/armeabi $build_root/build/openssl/arm/lib
cp -a $build_root/android-openssl/prebuilt/arm64-v8a $build_root/build/openssl/arm64/lib
cp -a $build_root/android-openssl/prebuilt/x86 $build_root/build/openssl/x86/lib
cp -a $build_root/android-openssl/prebuilt/x86_64 $build_root/build/openssl/x86_64/lib
cp -aL $build_root/android-openssl/openssl-OpenSSL_1_0_2l/include/openssl/ $build_root/build/openssl/include
ln -s $build_root/build/openssl/include $build_root/build/openssl/arm/include
ln -s $build_root/build/openssl/include $build_root/build/openssl/arm64/include
ln -s $build_root/build/openssl/include $build_root/build/openssl/x86/include
ln -s $build_root/build/openssl/include $build_root/build/openssl/x86_64/include
ln -sf /opt/android/build/openssl/include /opt/android/tool/arm/sysroot/usr/include/openssl
ln -sf /opt/android/build/openssl/arm/lib/*.so /opt/android/tool/arm/sysroot/usr/lib
ln -sf $build_root/build/openssl/include $build_root/tool/arm/sysroot/usr/include/openssl
ln -sf $build_root/build/openssl/arm/lib/*.so $build_root/tool/arm/sysroot/usr/lib
ln -sf /opt/android/build/openssl/include /opt/android/tool/arm64/sysroot/usr/include/openssl
ln -sf /opt/android/build/openssl/arm64/lib/*.so /opt/android/tool/arm64/sysroot/usr/lib
ln -sf $build_root/build/openssl/include $build_root/tool/arm64/sysroot/usr/include/openssl
ln -sf $build_root/build/openssl/arm64/lib/*.so $build_root/tool/arm64/sysroot/usr/lib
ln -sf /opt/android/build/openssl/include /opt/android/tool/x86/sysroot/usr/include/openssl
ln -sf /opt/android/build/openssl/x86/lib/*.so /opt/android/tool/x86/sysroot/usr/lib
ln -sf $build_root/build/openssl/include $build_root/tool/x86/sysroot/usr/include/openssl
ln -sf $build_root/build/openssl/x86/lib/*.so $build_root/tool/x86/sysroot/usr/lib
ln -sf /opt/android/build/openssl/include /opt/android/tool/x86_64/sysroot/usr/include/openssl
ln -sf /opt/android/build/openssl/x86_64/lib/*.so /opt/android/tool/x86_64/sysroot/usr/lib64
ln -sf $build_root/build/openssl/include $build_root/tool/x86_64/sysroot/usr/include/openssl
ln -sf $build_root/build/openssl/x86_64/lib/*.so $build_root/tool/x86_64/sysroot/usr/lib64
@@ -1,6 +1,6 @@
#!/bin/sh
cd /opt/android
cd $EXTERNAL_LIBS_BUILD_ROOT
wget https://sourceforge.net/projects/boost/files/boost/1.58.0/boost_1_58_0.tar.gz/download -O boost_1_58_0.tar.gz
tar xfz boost_1_58_0.tar.gz
cd boost_1_58_0
+12 -6
View File
@@ -1,18 +1,24 @@
#!/bin/sh
echo "preparing /opt/android"
mkdir -p /opt/android/build
echo "preparing $EXTERNAL_LIBS_BUILD_ROOT"
build_root=$EXTERNAL_LIBS_BUILD_ROOT
rm -rf $build_root
mkdir -p $build_root
PATH=$ANDROID_NDK_ROOT/build/tools/:$PATH
echo "installing arm"
make_standalone_toolchain.py --api 21 --stl=libc++ --arch arm --install-dir /opt/android/tool/arm
make_standalone_toolchain.py --api 21 --stl=libc++ --arch arm --install-dir $build_root/tool/arm
echo "installing arm64"
make_standalone_toolchain.py --api 21 --stl=libc++ --arch arm64 --install-dir /opt/android/tool/arm64
make_standalone_toolchain.py --api 21 --stl=libc++ --arch arm64 --install-dir $build_root/tool/arm64
echo "installing x86"
make_standalone_toolchain.py --api 21 --stl=libc++ --arch x86 --install-dir /opt/android/tool/x86
make_standalone_toolchain.py --api 21 --stl=libc++ --arch x86 --install-dir $build_root/tool/x86
echo "installing x86_64"
make_standalone_toolchain.py --api 21 --stl=libc++ --arch x86_64 --install-dir /opt/android/tool/x86_64
make_standalone_toolchain.py --api 21 --stl=libc++ --arch x86_64 --install-dir $build_root/tool/x86_64
echo "done"