Skip to content

Commit

Permalink
add snippets
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-duch committed Jul 24, 2024
1 parent bba2ca7 commit ec0f0f9
Showing 1 changed file with 11 additions and 1 deletion.
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.split("/").pop())
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

0 comments on commit ec0f0f9

Please sign in to comment.