Support for different arch-s and libc-s

This commit is contained in:
DarkCat09 2024-04-09 13:01:27 +04:00
parent ad79fb5cbf
commit b8ce2c13dc
Signed by: DarkCat09
GPG key ID: 0A26CD5B3345D6E3
2 changed files with 13 additions and 4 deletions

View file

@ -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

View file

@ -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