Skip to content

Commit

Permalink
fix: attempt to fix building for Android
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikBjare committed Feb 21, 2021
1 parent 3764fb5 commit 8599c77
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 10 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Expand Up @@ -97,6 +97,7 @@ jobs:
${{ runner.os }}-${{ env.cache-name }}-
- name: Install NDK
run: |
export ANDROID_NDK_HOME= # needed because GitHub Actions sets it by default...
./install-ndk.sh
- name: Build
run: |
Expand Down
3 changes: 3 additions & 0 deletions Makefile
Expand Up @@ -71,3 +71,6 @@ install:
# Install systemd user service
mkdir -p $(DESTDIR)$(PREFIX)/lib/systemd/user
install -m 644 aw-server.service $(DESTDIR)$(PREFIX)/lib/systemd/user/aw-server.service

clean:
cargo clean
4 changes: 2 additions & 2 deletions aw-server/Cargo.toml
Expand Up @@ -35,10 +35,10 @@ aw-models = { path = "../aw-models" }
aw-transform = { path = "../aw-transform" }
aw-query = { path = "../aw-query" }

[target.'cfg(target_os="linux")'.dependencies]
[target.'cfg(all(target_os="linux", target_arch="x86"))'.dependencies]
jemallocator = "0.3.2"

[target.'cfg(all(target_os="android", target_arch="x86"))'.dependencies]
[target.'cfg(target_os="android")'.dependencies]
jni = { version = "0.18", default-features = false }
libc = "0.2"
android_logger = "0.9"
Expand Down
3 changes: 2 additions & 1 deletion compile-android.sh
Expand Up @@ -32,6 +32,7 @@ for archtargetstr in \
export PATH="$NDK_ARCH_DIR:$ORIG_PATH"
cargo build -p aw-server --target $target --lib $($RELEASE && echo '--release')
else
echo "Couldn't find directory for target $arch"
echo "Couldn't find directory $NDK_ARCH_DIR"
exit 1
fi
done
14 changes: 7 additions & 7 deletions install-ndk.sh
Expand Up @@ -9,7 +9,7 @@ project_path="$(readlink -f "$script_dir/.")"

if [ -z "$ANDROID_NDK_HOME" ]; then
echo 'ANDROID_NDK_HOME not set, downloading NDK...';
wget --no-verbose -O android-ndk.zip https://dl.google.com/android/repository/android-ndk-r20-linux-x86_64.zip;
wget --no-verbose -O android-ndk.zip https://dl.google.com/android/repository/android-ndk-r21-linux-x86_64.zip;
unzip -q -d NDK android-ndk.zip;
ls NDK;
mv NDK/*/* NDK/;
Expand All @@ -24,12 +24,12 @@ for arch in \
'x86_64' \
'i686' \
; do
sudo ln -s -f $NDK_TOOLCHAIN_BIN/$arch-linux-android26-clang $NDK_TOOLCHAIN_BIN/$arch-linux-android-clang
ln -s -f $NDK_TOOLCHAIN_BIN/$arch-linux-android26-clang $NDK_TOOLCHAIN_BIN/$arch-linux-android-clang
done

# This has a slightly different path from the ones above
sudo ln -s -f $NDK_TOOLCHAIN_BIN/armv7a-linux-androideabi26-clang $NDK_TOOLCHAIN_BIN/armv7a-linux-androideabi-clang
sudo ln -s -f $NDK_TOOLCHAIN_BIN/armv7a-linux-androideabi26-clang $NDK_TOOLCHAIN_BIN/arm-linux-androideabi-clang
ln -s -f $NDK_TOOLCHAIN_BIN/armv7a-linux-androideabi26-clang $NDK_TOOLCHAIN_BIN/armv7a-linux-androideabi-clang
ln -s -f $NDK_TOOLCHAIN_BIN/armv7a-linux-androideabi26-clang $NDK_TOOLCHAIN_BIN/arm-linux-androideabi-clang

# Add to Rust
echo "Setting up Rust toolchains..."
Expand All @@ -40,18 +40,18 @@ echo "Creating cargo config..."
mkdir -p $project_path/.cargo
echo "
[target.aarch64-linux-android]
ar = '$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android26-ar'
ar = '$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android-ar'
linker = '$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android26-clang'
[target.armv7-linux-androideabi]
ar = '$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi-ar'
linker = '$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi-clang'
[target.i686-linux-android]
ar = '$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/i686-linux-android26-ar'
ar = '$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/i686-linux-android-ar'
linker = '$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/i686-linux-android26-clang'
[target.x86_64-linux-android]
ar = '$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android26-ar'
ar = '$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android-ar'
linker = '$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android26-clang'
" > $project_path/.cargo/config

0 comments on commit 8599c77

Please sign in to comment.