From e0830170ad900528e6b47ca2a881121187c2244b Mon Sep 17 00:00:00 2001 From: Raymond Khalife Date: Sat, 14 Feb 2026 20:20:31 -0500 Subject: [PATCH] feat: Lookup the target cargo directory --- recipes/rust/recipe.hbs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/recipes/rust/recipe.hbs b/recipes/rust/recipe.hbs index d5f36e4..230c3a4 100644 --- a/recipes/rust/recipe.hbs +++ b/recipes/rust/recipe.hbs @@ -17,10 +17,12 @@ build: - command -v gzip >/dev/null 2>&1 || { echo >&2 "gzip not found. Please install gzip to compress build output. \n"; exit 1; } {{/if}} + {{! We get the target directory from `cargo metadata` with sed in order not to in introduce a dependency on jq }} + {{! We do this because the target directory might be outside of current directory if we are running in a cargo workspace }} - type: script commands: - cargo build --package {{ package }} --target wasm32-unknown-unknown --release - - mv target/wasm32-unknown-unknown/release/{{ replace "-" "_" package }}.wasm "$ICP_WASM_OUTPUT_PATH" + - TARGET_DIR=$(cargo metadata --format-version 1 --no-deps | sed -n 's/.*"target_directory":"\([^"]*\)".*/\1/p'); cp "${TARGET_DIR}/wasm32-unknown-unknown/release/{{ replace "-" "_" package }}.wasm" "$ICP_WASM_OUTPUT_PATH" - type: script commands: