From 469ea8d2fc265c11f33a9adb2ad7959d0751f1b3 Mon Sep 17 00:00:00 2001 From: Markus Mayer Date: Sat, 22 Jul 2023 13:56:29 +0200 Subject: [PATCH] Update cross-build script to zip up results --- .gitignore | 1 + cross-build.sh | 23 +++++++++++++++++------ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 1f1dac1..7458ce8 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ /.env /.idea /*.bak +/*.gz diff --git a/cross-build.sh b/cross-build.sh index 93a11e6..8b3c68c 100755 --- a/cross-build.sh +++ b/cross-build.sh @@ -1,18 +1,29 @@ #!/usr/bin/env bash set -euo pipefail +PACKAGE_VERSION=$(sed -n 's/^version *= *"\(.*\)"/\1/p' "Cargo.toml") +echo "Cross-building for version ${PACKAGE_VERSION}" + +PROFILE=release-lto + echo "Building for Linux (GNU libc)" +LINUX_FLAVOR=linux-gnu +TARGET=x86_64-unknown-${LINUX_FLAVOR} # rustup target add x86_64-unknown-linux-gnu -cargo auditable build --profile=release-lto --target=x86_64-unknown-linux-gnu -ls -lah target/x86_64-unknown-linux-gnu/release-lto/k8sfwd +cargo auditable build --profile=${PROFILE} --target=${TARGET} +ls -lah target/${TARGET}/${PROFILE}/k8sfwd +gzip --keep -c target/${TARGET}/${PROFILE}/k8sfwd > "k8sfwd-${PACKAGE_VERSION}-${LINUX_FLAVOR}.gz" echo "Building for Linux (musl)" +LINUX_FLAVOR=linux-musl +TARGET=x86_64-unknown-${LINUX_FLAVOR} # rustup target add x86_64-unknown-linux-musl -cargo auditable build --profile=release-lto --target=x86_64-unknown-linux-musl -ls -lah target/x86_64-unknown-linux-musl/release-lto/k8sfwd +cargo auditable build --profile=${PROFILE} --target=${TARGET} +ls -lah target/${TARGET}/${PROFILE}/k8sfwd +gzip --keep -c target/${TARGET}/${PROFILE}/k8sfwd > "k8sfwd-${PACKAGE_VERSION}-${LINUX_FLAVOR}.gz" # TODO: Add OSX support # echo "Building for Apple Darwin" # # rustup target add x86_64-apple-darwin -# cargo auditable build --profile=release-lto --target=x86_64-apple-darwin -# ls -lah target/x86_64-apple-darwin/release-lto/k8sfwd +# cargo auditable build --profile=${PROFILE} --target=x86_64-apple-darwin +# ls -lah target/x86_64-apple-darwin/${PROFILE}/k8sfwd