Skip to content

Commit

Permalink
feat: target dir flag
Browse files Browse the repository at this point in the history
  • Loading branch information
Eveeifyeve authored Sep 24, 2024
1 parent 993d64b commit a5c595d
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions pkgs/by-name/ca/cargo-tauri/hook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,6 @@ tauriBuildHook() {
# separateDebugInfo.
export "CARGO_PROFILE_${cargoBuildType@U}_STRIP"=false

if [ -n "${buildAndTestSubdir-}" ]; then
# ensure the output doesn't end up in the subdirectory
CARGO_TARGET_DIR="$(pwd)/target"
export CARGO_TARGET_DIR

# Tauri doesn't respect $CARGO_TARGET_DIR, but does respect the cargo
# argument...but that doesn't respect `--target`, so we have to use the
# config file
# https://github.com/tauri-apps/tauri/issues/10190
mkdir -p .cargo
printf '\nbuild.target-dir = "%s"' "$CARGO_TARGET_DIR" >>config.toml

pushd "${buildAndTestSubdir}"
fi

local cargoFlagsArray=(
"-j" "$NIX_BUILD_CORES"
"--target" "@rustHostPlatformSpec@"
Expand All @@ -44,6 +29,11 @@ tauriBuildHook() {
"--target" "@rustHostPlatformSpec@"
)

# https://github.com/tauri-apps/tauri/issues/10190 if fixed so we can default to `--target-dir`
if [ -n "${buildAndTestSubdir-}" ]; then
cargoFlagsArray+=("--target-dir" "$(pwd)/target")
fi

if [ "${cargoBuildType}" != "debug" ]; then
cargoFlagsArray+=("--profile" "${cargoBuildType}")
fi
Expand Down

0 comments on commit a5c595d

Please sign in to comment.