a52b20cc35
* remove docker build cruft - Simplified environment variable sourcing in build scripts by using a single build-env.sh file. - Updated Dockerfile to streamline the build process and reduce unnecessary comments. - Enhanced setup-cross-compilation.sh to directly set target and linker variables without temporary files. - Improved clarity and maintainability of build scripts. * fix setup-cross-compilation.sh - Updated the script to use a more concise syntax for exporting environment variables. - Improved readability by using echo and conditional checks for BINDGEN_EXTRA_CLANG_ARGS. - This change simplifies the script while maintaining functionality. * Refactor setup-cross-compilation.sh for improved readability - Changed the syntax for checking BINDGEN_EXTRA_CLANG_ARGS to use a conditional statement for clarity. - This enhances the script's maintainability while preserving its functionality.
44 lines
1.4 KiB
Bash
Executable File
44 lines
1.4 KiB
Bash
Executable File
#!/bin/bash
|
|
set -euo pipefail
|
|
|
|
TARGETARCH="$1"
|
|
BUILDARCH="$2"
|
|
BINDGEN_EXTRA_CLANG_ARGS=""
|
|
|
|
apt-get update
|
|
|
|
if [ "$TARGETARCH" = "$BUILDARCH" ]; then
|
|
TARGET="$(rustup target list --installed | head -n1)"
|
|
LINKER="gcc"
|
|
apt-get install -y gcc libgcc-s1 make
|
|
LIBDIR="/lib/$(gcc -print-multiarch)"
|
|
elif [ "$TARGETARCH" = "arm64" ]; then
|
|
TARGET="aarch64-unknown-linux-gnu"
|
|
LINKER="aarch64-linux-gnu-gcc"
|
|
apt-get install -y gcc-aarch64-linux-gnu libgcc-s1-arm64-cross make
|
|
LIBDIR="/usr/aarch64-linux-gnu/lib"
|
|
elif [ "$TARGETARCH" = "arm" ]; then
|
|
TARGET="armv7-unknown-linux-gnueabihf"
|
|
LINKER="arm-linux-gnueabihf-gcc"
|
|
apt-get install -y gcc-arm-linux-gnueabihf libgcc-s1-armhf-cross make cmake libclang-dev
|
|
cargo install --force --locked bindgen-cli
|
|
SYSROOT=$(arm-linux-gnueabihf-gcc -print-sysroot)
|
|
BINDGEN_EXTRA_CLANG_ARGS="--sysroot=$SYSROOT -I$SYSROOT/usr/include -I$SYSROOT/usr/include/arm-linux-gnueabihf"
|
|
LIBDIR="/usr/arm-linux-gnueabihf/lib"
|
|
else
|
|
echo "Unsupported cross compilation target: $TARGETARCH"
|
|
exit 1
|
|
fi
|
|
|
|
mkdir -p /tmp/sqlpage-libs
|
|
cp "$LIBDIR/libgcc_s.so.1" /tmp/sqlpage-libs/
|
|
rustup target add "$TARGET"
|
|
|
|
{
|
|
echo "export TARGET='$TARGET'"
|
|
echo "export LINKER='$LINKER'"
|
|
if [ -n "$BINDGEN_EXTRA_CLANG_ARGS" ]; then
|
|
printf "export BINDGEN_EXTRA_CLANG_ARGS=%q\n" "$BINDGEN_EXTRA_CLANG_ARGS"
|
|
fi
|
|
} > /tmp/build-env.sh
|