From b8ce2c13dc66eeda24a1d3ba4df9e788dafde9c3 Mon Sep 17 00:00:00 2001 From: DarkCat09 Date: Tue, 9 Apr 2024 13:01:27 +0400 Subject: [PATCH] Support for different arch-s and libc-s --- README.md | 6 ++++++ build.sh | 11 +++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index c54fb74..b02ba10 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,12 @@ for building reqwest4j and Piped respectively) 4. Run the script: `./build.sh` (`bash build.sh` if you executed previous commands from bash) +You can set environment variables +`ARCH=x86_64|aarch64|armv7...`, +`LIBC=musl|gnu|musleabi|gnueabi`, +e.g. `ARCH=aarch64 ./build.sh`. +They default to x86_64 musl. + ## How to start Piped 1. Edit config.properties 2. Change `/home/piped` in start.sh to directory diff --git a/build.sh b/build.sh index cdf3719..7b8fe65 100755 --- a/build.sh +++ b/build.sh @@ -2,6 +2,9 @@ # shellcheck source=patcher.sh WORKDIR=$(pwd) +ARCH="${ARCH:-x86_64}" +LIBC="${LIBC:-musl}" +TARGET="$ARCH-unknown-linux-$LIBC" # --- @@ -76,11 +79,11 @@ cd_and_exec reqwest4j patch_reqwest4j # --- -export RUSTFLAGS="-C target-feature=-crt-static" +[ "$LIBC" = "musl" ] && export RUSTFLAGS="-C target-feature=-crt-static" title 'Building reqwest-jni' cd_and_exec reqwest4j/reqwest-jni \ - cargo build --release --target x86_64-unknown-linux-musl + cargo build --release --target "$TARGET" title 'Building reqwest4j without Rust library...' OLD_PATH="$PATH" @@ -109,12 +112,12 @@ cd_and_exec reqwest4j/build/libs \ REQJNI_NAME="libreqwest.so" REQJNI="$WORKDIR/$REQJNI_NAME" -cd_and_exec reqwest4j/reqwest-jni/target/x86_64-unknown-linux-musl/release \ +cd_and_exec "reqwest4j/reqwest-jni/target/$TARGET/release" \ cp libreqwest_jni.so "$REQJNI" # Create JAR native libraries tree title '--Creating libraries directory tree' -NATIVES="META-INF/natives/linux/x86_64" +NATIVES="META-INF/natives/linux/$ARCH" mkdir -p "$NATIVES" # Move reqwest-jni to native libraries directory