From bba2ca7a300b376762daa9915b4b0ac26936d70b Mon Sep 17 00:00:00 2001 From: Matt Duch Date: Mon, 22 Jul 2024 13:24:00 -0500 Subject: [PATCH 1/2] wasm_bindgen: allow target name with directory --- wasm_bindgen/private/wasm_bindgen.bzl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wasm_bindgen/private/wasm_bindgen.bzl b/wasm_bindgen/private/wasm_bindgen.bzl index e4732f180a..dd129e6520 100644 --- a/wasm_bindgen/private/wasm_bindgen.bzl +++ b/wasm_bindgen/private/wasm_bindgen.bzl @@ -64,7 +64,7 @@ def rust_wasm_bindgen_action(ctx, toolchain, wasm_file, target_output, bindgen_f args = ctx.actions.args() args.add("--target", target_output) args.add("--out-dir", bindgen_wasm_module.dirname) - args.add("--out-name", ctx.label.name) + args.add("--out-name", ctx.label.name.split("/").pop()) args.add_all(bindgen_flags) args.add(input_file) From ec0f0f92723154ee464b0ea3111759b6fe7aeb7a Mon Sep 17 00:00:00 2001 From: Matt Duch Date: Wed, 24 Jul 2024 08:54:18 -0500 Subject: [PATCH 2/2] add snippets --- wasm_bindgen/private/wasm_bindgen.bzl | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/wasm_bindgen/private/wasm_bindgen.bzl b/wasm_bindgen/private/wasm_bindgen.bzl index dd129e6520..96b7d1ad65 100644 --- a/wasm_bindgen/private/wasm_bindgen.bzl +++ b/wasm_bindgen/private/wasm_bindgen.bzl @@ -52,9 +52,16 @@ def rust_wasm_bindgen_action(ctx, toolchain, wasm_file, target_output, bindgen_f bindgen_wasm_module = ctx.actions.declare_file(ctx.label.name + "_bg.wasm") + out_dir = ctx.label.name.split("/") + out_name = out_dir.pop() + out_dir_name = "/".join(out_dir) + js_out = [ctx.actions.declare_file(ctx.label.name + ".js")] ts_out = [ctx.actions.declare_file(ctx.label.name + ".d.ts")] + if target_output == "web" or target_output == "bundler": + js_out.append(ctx.actions.declare_directory(out_dir_name + "/snippets")) + if target_output == "bundler": js_out.append(ctx.actions.declare_file(ctx.label.name + "_bg.js")) ts_out.append(ctx.actions.declare_file(ctx.label.name + "_bg.wasm.d.ts")) @@ -64,7 +71,7 @@ def rust_wasm_bindgen_action(ctx, toolchain, wasm_file, target_output, bindgen_f args = ctx.actions.args() args.add("--target", target_output) args.add("--out-dir", bindgen_wasm_module.dirname) - args.add("--out-name", ctx.label.name.split("/").pop()) + args.add("--out-name", out_name) args.add_all(bindgen_flags) args.add(input_file) @@ -75,6 +82,9 @@ def rust_wasm_bindgen_action(ctx, toolchain, wasm_file, target_output, bindgen_f mnemonic = "RustWasmBindgen", progress_message = "Generating WebAssembly bindings for {}...".format(progress_message_label), arguments = [args], + env = { + "RUST_LOG": "debug", + }, ) return RustWasmBindgenInfo(