Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wasm_bindgen: allow target name with directory #2758

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion wasm_bindgen/private/wasm_bindgen.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand All @@ -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)
args.add("--out-name", out_name)
args.add_all(bindgen_flags)
args.add(input_file)

Expand All @@ -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(
Expand Down
Loading