Skip to content

Commit

Permalink
[CI]: Try to build boost for android manually
Browse files Browse the repository at this point in the history
  • Loading branch information
satoshiotomakan committed Oct 25, 2023
1 parent c4eddfc commit e3ddcb0
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/android-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
16 changes: 16 additions & 0 deletions tools/android-sdk
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 3 additions & 0 deletions tools/android-test
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions tools/download-dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -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."
29 changes: 27 additions & 2 deletions tools/install-dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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() {
Expand Down Expand Up @@ -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"

0 comments on commit e3ddcb0

Please sign in to comment.