| 1 | #!/usr/bin/env bash |
| 2 | # SPDX-License-Identifier: Apache-2.0 |
| 3 | # Copyright (c) 2026 UtopiaIA |
| 4 | # |
| 5 | # Builds the release binary with every build path remapped, then checks that |
| 6 | # the home directory does not appear anywhere inside it. Published binaries are |
| 7 | # built by CI; use this for local release builds. |
| 8 | set -euo pipefail |
| 9 | cd "$(dirname "$0")/.." |
| 10 | |
| 11 | cargo_home="${CARGO_HOME:-$HOME/.cargo}" |
| 12 | rustup_home="${RUSTUP_HOME:-$HOME/.rustup}" |
| 13 | # When several prefixes match, rustc applies the last one, so the most general |
| 14 | # goes first. |
| 15 | export RUSTFLAGS="${RUSTFLAGS:-} --remap-path-prefix=$HOME=~ --remap-path-prefix=$rustup_home=/rustup --remap-path-prefix=$cargo_home=/cargo --remap-path-prefix=$PWD=." |
| 16 | |
| 17 | cargo build --release --locked -p elffuss-braid-cli |
| 18 | |
| 19 | bin=target/release/braid |
| 20 | if strings "$bin" | grep -qF "$HOME"; then |
| 21 | echo "build-release: $bin still contains the home directory path" >&2 |
| 22 | exit 1 |
| 23 | fi |
| 24 | echo "build-release: $bin contains no home-directory path" |