buildRustCrate: fix wasm bins with hyphenated names

These are currently broken because buildRustCrate will try to mv from
an underscored name to a hyphenated name, but will only try to move an
unsuffixed name; rustc generates wasm binaries with a .wasm suffix.
This commit is contained in:
Sam Pointon
2025-09-08 17:11:06 +02:00
committed by Alyssa Ross
parent 947f328b0a
commit 227ac4d95a
2 changed files with 18 additions and 1 deletions
@@ -60,7 +60,11 @@ build_bin() {
--color ${colors} \
if [ "$crate_name_" != "$crate_name" ]; then
mv target/bin/$crate_name_ target/bin/$crate_name
if [ -f "target/bin/$crate_name_.wasm" ]; then
mv target/bin/$crate_name_.wasm target/bin/$crate_name.wasm
else
mv target/bin/$crate_name_ target/bin/$crate_name
fi
fi
}
@@ -838,6 +838,19 @@ rec {
];
};
crateWasm32BinHyphens = assertOutputs {
name = "wasm32-crate-bin-hyphens";
mkCrate = mkCrate pkgsCross.wasm32-unknown-none.buildRustCrate;
crateArgs = {
crateName = "wasm32-crate-bin-hyphens";
crateBin = [ { name = "wasm32-crate-bin-hyphens"; } ];
src = mkBin "src/main.rs";
};
expectedFiles = [
"./bin/wasm32-crate-bin-hyphens.wasm"
];
};
brotliTest =
let
pkg = brotliCrates.brotli_2_5_0 { };