From e3ddcb037de01c6ca93ab4c7b321ef0b29fe4592 Mon Sep 17 00:00:00 2001 From: Satoshi Otomakan Date: Wed, 25 Oct 2023 14:06:39 +0200 Subject: [PATCH] [CI]: Try to build boost for android manually --- .github/workflows/android-ci.yml | 4 ++-- tools/android-sdk | 16 ++++++++++++++++ tools/android-test | 3 +++ tools/download-dependencies | 15 +++++++++++++++ tools/install-dependencies | 29 +++++++++++++++++++++++++++-- 5 files changed, 63 insertions(+), 4 deletions(-) diff --git a/.github/workflows/android-ci.yml b/.github/workflows/android-ci.yml index 17ee83452d9..32faecf0af2 100644 --- a/.github/workflows/android-ci.yml +++ b/.github/workflows/android-ci.yml @@ -12,7 +12,7 @@ concurrency: jobs: build: - runs-on: macos-latest + runs-on: ubuntu-latest # if: github.event.pull_request.draft == false steps: - uses: actions/checkout@v3 @@ -28,7 +28,7 @@ jobs: - name: Install system dependencies run: | - tools/install-sys-dependencies-mac + tools/install-sys-dependencies-linux - name: Cache Rust uses: Swatinem/rust-cache@v2 diff --git a/tools/android-sdk b/tools/android-sdk index 2ee8025fdb4..3320d30f246 100644 --- a/tools/android-sdk +++ b/tools/android-sdk @@ -2,6 +2,22 @@ export NDK_API_LEVEL=21 +# TODO Make this better +find_android_ndk_path() { + if [[ "$ANDROID_NDK_HOME" != "" ]]; then + >&2 echo "Use ANDROID_NDK_HOME" + elif [[ "$ANDROID_HOME" != "" ]]; then + >&2 echo "ANDROID_NDK_HOME is not set. Use ANDROID_HOME value instead" + ANDROID_NDK_HOME="$ANDROID_HOME/ndk" + else + >&2 echo "WARNING: ANDROID_HOME is not set. Use a default path" + ANDROID_NDK_HOME="$HOME/Library/Android/sdk/ndk" + fi + + PATH_TO_NDK="$ANDROID_NDK_HOME/23.1.7779620" + echo $PATH_TO_NDK +} + find_android_ndk() { if [[ "$ANDROID_NDK_HOME" != "" ]]; then >&2 echo "Use ANDROID_NDK_HOME" diff --git a/tools/android-test b/tools/android-test index 8aafb802106..5c9791080cf 100755 --- a/tools/android-test +++ b/tools/android-test @@ -13,6 +13,9 @@ PORT=5556 if [[ `uname` == "Darwin" ]]; then export BOOST_ROOT=$(brew --prefix boost) +else + # TODO + export BOOST_ROOT=./build/local fi # Make sure it builds before starting an emulator diff --git a/tools/download-dependencies b/tools/download-dependencies index bd138ca5904..58b9b0a34b8 100755 --- a/tools/download-dependencies +++ b/tools/download-dependencies @@ -53,9 +53,24 @@ function download_protobuf() { tar xzf protobuf-java-$PROTOBUF_VERSION.tar.gz } +function download_boost_for_android() { + echo "Downloading Boost-for-Android..." + SRC_DIR="$ROOT/build/local/src" + mkdir -p "$SRC_DIR" + cd "$SRC_DIR" + + if [ ! -d "$SRC_DIR/Boost-for-Android" ];then + git clone https://github.com/moritz-wundke/Boost-for-Android.git + fi +} + download_gtest download_libcheck download_nolhmann_json download_protobuf +if [[ "$1" == "android" ]]; then + download_boost_for_android +fi + echo "done." diff --git a/tools/install-dependencies b/tools/install-dependencies index 3a04f8434bd..cb609ce11ea 100755 --- a/tools/install-dependencies +++ b/tools/install-dependencies @@ -12,6 +12,7 @@ MAKE=make # Load dependencies version BASE_DIR=$(cd `dirname $0`; pwd) source ${BASE_DIR}/dependencies-version +source ${BASE_DIR}/android-sdk # Setup up folders export PATH="$PREFIX/bin":$PATH @@ -22,7 +23,7 @@ export LD_LIBRARY_PATH="$PREFIX/lib" export LD_RUN_PATH="$PREFIX/lib" function download_dependencies() { - ${BASE_DIR}/download-dependencies + ${BASE_DIR}/download-dependencies $1 } function build_gtest() { @@ -87,10 +88,34 @@ function build_swift_plugin() { $PREFIX/bin/protoc-gen-swift --version } -download_dependencies +# TODO make this better +function build_boost_for_android() { + NDK_PATH=$(find_android_ndk_path) + echo $NDK_PATH + + BOOST_DIR="$ROOT/build/local/src/Boost-for-Android" + BOOST_TEMP_DIR="$BOOST_DIR/release" + + mkdir -p "$BOOST_TEMP_DIR" + + pushd $BOOST_DIR + ./build-android.sh --prefix=$BOOST_TEMP_DIR --without-libraries=program_options,thread,atomic,chrono,filesystem,iostreams,json,log,python,random,regex,test,timer --arch=x86 $NDK_PATH + popd + + mkdir -p "$PREFIX/include" + mkdir -p "$PREFIX/lib" + mv "$BOOST_TEMP_DIR/x86/include/boost-1_82/boost" "$PREFIX/include" + cp -r "$BOOST_TEMP_DIR/x86/lib/" "$PREFIX/lib" +} + +download_dependencies $1 build_gtest build_libcheck build_protobuf +if [[ "$1" == "android" ]]; then + build_boost_for_android +fi + cd "$ROOT"