Skip to content

Commit

Permalink
build: add option to explictly set RUSTFLAGS
Browse files Browse the repository at this point in the history
Reads the env RUSTFLAGS from the env and passes it to nix-build as an argstr.

Signed-off-by: Niladri Halder <[email protected]>
  • Loading branch information
niladrih committed Oct 23, 2024
1 parent b6f8450 commit 03a4f75
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions scripts/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -261,11 +261,6 @@ parse_common_arg() {
STATIC_LINKING="false"
shift
;;
--extra-build-args)
shift
CUSTOM_BUILD_ARGS="$1"
shift
;;
--skip-bins)
shift
BUILD_BINARIES=
Expand Down Expand Up @@ -340,9 +335,6 @@ setup() {
TAG="$ALIAS_TAG"
ALIAS_TAG=
fi
if [ -n "$CUSTOM_BUILD_ARGS" ]; then
NIX_BUILD="$NIX_BUILD $CUSTOM_BUILD_ARGS"
fi
}

cache_deps() {
Expand Down Expand Up @@ -467,7 +459,7 @@ build_images() {
# the images we already have locally.
if [ -z "$SKIP_BUILD" ]; then
echo "Building $image:$TAG ..."
$NIX_BUILD --out-link "$archive-image" -A "images.$BUILD_TYPE.$archive" --arg allInOne "$ALL_IN_ONE" --arg incremental "$INCREMENTAL" --argstr product_prefix "$PRODUCT_PREFIX"
$NIX_BUILD --out-link "$archive-image" -A "images.$BUILD_TYPE.$archive" --arg allInOne "$ALL_IN_ONE" --arg incremental "$INCREMENTAL" --argstr product_prefix "$PRODUCT_PREFIX" --argstr rustFlags "$RUSTFLAGS"
if [ -n "$CONTAINER_LOAD" ]; then
container_load "$archive-image"
if [ "$image" != "$image_basename" ]; then
Expand Down Expand Up @@ -570,7 +562,7 @@ build_bins() {
mkdir -p "$BINARY_OUT_LINK"
for name in $BUILD_BINARIES; do
echo "Building static $name ..."
$NIX_BUILD --out-link "$BINARY_OUT_LINK/$name" -A "$PROJECT.$BUILD_TYPE.$name" --arg allInOne "$ALL_IN_ONE" --arg static "$STATIC_LINKING"
$NIX_BUILD --out-link "$BINARY_OUT_LINK/$name" -A "$PROJECT.$BUILD_TYPE.$name" --arg allInOne "$ALL_IN_ONE" --arg static "$STATIC_LINKING" --argstr rustFlags "$RUSTFLAGS"
done
fi
}
Expand Down Expand Up @@ -607,12 +599,14 @@ common_help() {
--incremental Builds components in two stages allowing for faster rebuilds during development.
--build-bins Builds all the static binaries.
--no-static-linking Don't build the binaries with static linking.
--extra-build-args <args> Build with custom $NIX_BUILD command args.
--build-bin Specify which binary to build.
--skip-bins Don't build the static binaries.
--build-binary-out <path> Specify the outlink path for the binaries (otherwise it's the current directory).
--skopeo-copy Don't load containers into host, simply copy them to registry with skopeo.
--skip-cargo-deps Don't prefetch the cargo build dependencies.
Environment Variables:
RUSTFLAGS Set Rust compiler options when building binaries.
EOF
}

Expand Down Expand Up @@ -646,7 +640,6 @@ INCREMENTAL="false"
DEFAULT_BINARIES=${BUILD_BINARIES:-}
BUILD_BINARIES=
STATIC_LINKING="true"
CUSTOM_BUILD_ARGS=""
BINARY_OUT_LINK="."
CARGO_VENDOR_DIR=${CARGO_VENDOR_DIR:-}
CARGO_VENDOR_ATTEMPTS=${CARGO_VENDOR_ATTEMPTS:-25}
Expand Down

0 comments on commit 03a4f75

Please sign in to comment.