krata: rework cross-compilation

This commit is contained in:
Alex Zenla
2024-03-21 21:31:10 +00:00
parent 332a1bba26
commit 0191e5b2c1
27 changed files with 321 additions and 131 deletions

View File

@ -3,11 +3,22 @@ set -e
TOOLS_DIR="$(dirname "${0}")"
RUST_TARGET="$("${TOOLS_DIR}/target.sh")"
CROSS_COMPILE="$("${TOOLS_DIR}/cross-compile.sh")"
if [ "${RUST_LIBC}" = "musl" ] && [ -f "/etc/alpine-release" ]
if [ "${TARGET_LIBC}" = "musl" ] && [ -f "/etc/alpine-release" ]
then
export RUSTFLAGS="-Ctarget-feature=-crt-static"
fi
if [ -z "${CARGO}" ]
then
if [ "${CROSS_COMPILE}" = "1" ] && command -v cross > /dev/null
then
CARGO="cross"
else
CARGO="cargo"
fi
fi
export CARGO_BUILD_TARGET="${RUST_TARGET}"
exec cargo "${@}"
exec "${CARGO}" "${@}"