script to build isodrive
This commit is contained in:
77
build_isodrive.sh
Executable file
77
build_isodrive.sh
Executable file
@@ -0,0 +1,77 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# Build isodrive from source for all Android architectures
|
||||
# Requires: Android NDK (or runs via nix-shell on NixOS)
|
||||
|
||||
SCRIPT_DIR=$(dirname "$(realpath "$0")")
|
||||
ISODRIVE_DIR="/tmp/isodrive"
|
||||
OUTPUT_DIR="$SCRIPT_DIR/app/src/main/assets/bin"
|
||||
|
||||
# Clone isodrive source
|
||||
if [[ -d "$ISODRIVE_DIR" ]]; then
|
||||
echo "Updating isodrive source..."
|
||||
git -C "$ISODRIVE_DIR" pull
|
||||
else
|
||||
echo "Cloning isodrive..."
|
||||
git clone --depth 1 https://github.com/nitanmarcel/isodrive "$ISODRIVE_DIR"
|
||||
fi
|
||||
|
||||
SRCS="$ISODRIVE_DIR/src/util.cpp $ISODRIVE_DIR/src/configfsisomanager.cpp $ISODRIVE_DIR/src/androidusbisomanager.cpp $ISODRIVE_DIR/src/main.cpp"
|
||||
CFLAGS="-I$ISODRIVE_DIR/src/include -static-libstdc++ -Os -s"
|
||||
|
||||
build_all() {
|
||||
local NDK="$1"
|
||||
local TOOLCHAIN="$NDK/toolchains/llvm/prebuilt/linux-x86_64/bin"
|
||||
|
||||
echo "Building arm64-v8a..."
|
||||
"$TOOLCHAIN/aarch64-linux-android26-clang++" $CFLAGS $SRCS -o "$OUTPUT_DIR/arm64-v8a/isodrive"
|
||||
|
||||
echo "Building armeabi-v7a..."
|
||||
"$TOOLCHAIN/armv7a-linux-androideabi26-clang++" $CFLAGS $SRCS -o "$OUTPUT_DIR/armeabi-v7a/isodrive"
|
||||
|
||||
echo "Building x86_64..."
|
||||
"$TOOLCHAIN/x86_64-linux-android26-clang++" $CFLAGS $SRCS -o "$OUTPUT_DIR/x86_64/isodrive"
|
||||
|
||||
echo "Building x86..."
|
||||
"$TOOLCHAIN/i686-linux-android26-clang++" $CFLAGS $SRCS -o "$OUTPUT_DIR/x86/isodrive"
|
||||
|
||||
echo "Done! Built isodrive for all architectures."
|
||||
ls -la "$OUTPUT_DIR"/*/isodrive
|
||||
}
|
||||
|
||||
# On NixOS, prefer nix-shell (local Android SDK has /bin/bash issues)
|
||||
if command -v nix-shell &>/dev/null; then
|
||||
echo "Using nix-shell to get Android NDK..."
|
||||
export SRCS CFLAGS OUTPUT_DIR
|
||||
NIXPKGS_ALLOW_UNFREE=1 nix-shell -p androidenv.androidPkgs.ndk-bundle --run '
|
||||
SDK_ROOT=$(find /nix/store -maxdepth 1 -name "*android-sdk-ndk*" -type d 2>/dev/null | head -1)
|
||||
NDK=$(ls -d "$SDK_ROOT/libexec/android-sdk/ndk/"* | head -1)
|
||||
TOOLCHAIN="$NDK/toolchains/llvm/prebuilt/linux-x86_64/bin"
|
||||
|
||||
echo "Using NDK: $NDK"
|
||||
|
||||
echo "Building arm64-v8a..."
|
||||
"$TOOLCHAIN/aarch64-linux-android26-clang++" $CFLAGS $SRCS -o "$OUTPUT_DIR/arm64-v8a/isodrive"
|
||||
|
||||
echo "Building armeabi-v7a..."
|
||||
"$TOOLCHAIN/armv7a-linux-androideabi26-clang++" $CFLAGS $SRCS -o "$OUTPUT_DIR/armeabi-v7a/isodrive"
|
||||
|
||||
echo "Building x86_64..."
|
||||
"$TOOLCHAIN/x86_64-linux-android26-clang++" $CFLAGS $SRCS -o "$OUTPUT_DIR/x86_64/isodrive"
|
||||
|
||||
echo "Building x86..."
|
||||
"$TOOLCHAIN/i686-linux-android26-clang++" $CFLAGS $SRCS -o "$OUTPUT_DIR/x86/isodrive"
|
||||
|
||||
echo "Done!"
|
||||
ls -la "$OUTPUT_DIR"/*/isodrive
|
||||
'
|
||||
elif [[ -n "${ANDROID_NDK_HOME:-}" ]]; then
|
||||
build_all "$ANDROID_NDK_HOME"
|
||||
elif [[ -n "${ANDROID_NDK:-}" ]]; then
|
||||
build_all "$ANDROID_NDK"
|
||||
else
|
||||
echo "Error: Android NDK not found."
|
||||
echo "Set ANDROID_NDK_HOME or ANDROID_NDK, or install nix-shell."
|
||||
exit 1
|
||||
fi
|
||||
Reference in New Issue
Block a user