Skip to content

Commit 7c85235

Browse files
committed
fix: correct bindgen filename extraction and re-enable wasmsign2
Two critical fixes: 1. Fixed wit_bindgen extraction to use correct filenames: - Separate wit-bindgen's output filename from Bazel's declared filename - wit-bindgen generates: basic_component.rs (no suffix) - Bazel declares: basic_component_native_guest.rs (with suffix) - Extract from wit-bindgen output filename, rename to Bazel filename - Resolves: file_ops extraction failures for native-guest bindings 2. Re-enabled wasmsign2 using pulseengine/wsc repository: - New location: https://github.com/pulseengine/wsc - Release: v0.2.7-rc.1 with wsc-cli.wasm - SHA256: cb3125ce35704fed117bee95d56ab34576c6c1c8b940234aba5dc9893c224fa7 - Re-enabled wasmsign2_wrapper go_binary - Re-enabled wasm_signing examples in CI builds This should resolve all remaining build failures.
1 parent 9476144 commit 7c85235

File tree

4 files changed

+32
-53
lines changed

4 files changed

+32
-53
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ jobs:
153153
//examples/js_component:simple_js_component \
154154
//examples/js_component:hello_js_component \
155155
//examples/js_component:calc_js_component \
156+
//examples/wasm_signing/... \
156157
//rust/... \
157158
//go/... \
158159
//cpp/... \
@@ -167,7 +168,6 @@ jobs:
167168
//test/integration/... \
168169
//docs-site/... \
169170
-//examples/go_component:calculator_simple \
170-
-//examples/wasm_signing/... \
171171
172172
- name: Run Tests
173173
run: bazel test --test_output=errors -- //test/integration:basic_component_build_test //test/integration:basic_component_validation //test/unit:unit_tests //test/wkg/unit:smoke //test/js:test_hello_js_component_provides_info //test/js:test_calc_js_component_provides_info //test/js:test_npm_dependencies_installation
@@ -248,6 +248,7 @@ jobs:
248248
//examples/js_component:simple_js_component \
249249
//examples/js_component:hello_js_component \
250250
//examples/js_component:calc_js_component \
251+
//examples/wasm_signing/... \
251252
//rust/... \
252253
//go/... \
253254
//cpp/... \
@@ -267,7 +268,6 @@ jobs:
267268
//docs-site/... \
268269
-//examples/cpp_component/multi_component_system:analytics_service \
269270
-//examples/go_component:calculator_component \
270-
-//examples/wasm_signing/... \
271271
-//examples/go_component:calculator_component_debug \
272272
-//examples/go_component:calculator_simple \
273273
-//examples/go_component:calculator_simple_binding \

MODULE.bazel

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -203,15 +203,13 @@ http_file(
203203
url = "https://github.com/pulseengine/bazel-file-ops-component/releases/download/v0.1.0-rc.3/file_ops_component.wasm",
204204
)
205205

206-
# wasmsign2 CLI WASM binary for component signing
207-
# Commented out temporarily: release v0.2.7-rc.2 not available
208-
# TODO: Update to use official wasm-signatures/wasmsign2 when WASM binary is published
209-
# http_file(
210-
# name = "wasmsign2_cli_wasm",
211-
# downloaded_file_path = "wasmsign2.wasm",
212-
# sha256 = "0a2ba6a55621d83980daa7f38e3770ba6b9342736971a0cebf613df08377cd34",
213-
# url = "https://github.com/pulseengine/wasmsign2/releases/download/v0.2.7-rc.2/wasmsign2-cli.wasm",
214-
# )
206+
# wasmsign2 CLI WASM binary for component signing (from pulseengine/wsc)
207+
http_file(
208+
name = "wasmsign2_cli_wasm",
209+
downloaded_file_path = "wasmsign2.wasm",
210+
sha256 = "cb3125ce35704fed117bee95d56ab34576c6c1c8b940234aba5dc9893c224fa7",
211+
url = "https://github.com/pulseengine/wsc/releases/download/v0.2.7-rc.1/wsc-cli.wasm",
212+
)
215213

216214
# WASM Tools Component toolchain for universal wasm-tools operations
217215
register_toolchains("//toolchains:wasm_tools_component_toolchain_local")

tools/wasmsign2_wrapper/BUILD.bazel

Lines changed: 16 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -3,50 +3,28 @@
33
This wrapper executes the pre-built wasmsign2.wasm component via wasmtime,
44
resolving symlinks to real paths to work with both Bazel's sandbox and
55
WASI's security model.
6-
7-
TEMPORARILY DISABLED: wasmsign2 binary not available
8-
TODO: Re-enable when wasmsign2 WASM binary is published
96
"""
107

118
load("@rules_go//go:def.bzl", "go_binary")
129

1310
package(default_visibility = ["//visibility:public"])
1411

15-
# Temporarily commented out - wasmsign2 binary not available
16-
# # Wrapper binary that executes wasmsign2.wasm with path resolution
17-
# go_binary(
18-
# name = "wasmsign2_wrapper",
19-
# srcs = ["main.go"],
20-
# data = [
21-
# "@wasmsign2_cli_wasm//file",
22-
# "@wasmtime_toolchain//:wasmtime",
23-
# ],
24-
# pure = "on", # Pure Go for cross-platform compatibility
25-
# visibility = ["//visibility:public"],
26-
# deps = ["@rules_go//go/runfiles"],
27-
# )
28-
#
29-
# # Export for easy access in toolchains
30-
# alias(
31-
# name = "wasmsign2",
32-
# actual = ":wasmsign2_wrapper",
33-
# visibility = ["//visibility:public"],
34-
# )
35-
36-
# Stub target to prevent build failures while wasmsign2 is unavailable
37-
# This will fail at runtime if actually used, but allows builds to complete
38-
genrule(
12+
# Wrapper binary that executes wasmsign2.wasm with path resolution
13+
go_binary(
3914
name = "wasmsign2_wrapper",
40-
outs = ["wasmsign2_stub.sh"],
41-
cmd = """
42-
cat > $@ << 'EOF'
43-
#!/bin/sh
44-
echo "ERROR: wasmsign2 is temporarily unavailable" >&2
45-
echo "The wasmsign2 binary could not be downloaded from upstream" >&2
46-
exit 1
47-
EOF
48-
chmod +x $@
49-
""",
50-
executable = True,
15+
srcs = ["main.go"],
16+
data = [
17+
"@wasmsign2_cli_wasm//file",
18+
"@wasmtime_toolchain//:wasmtime",
19+
],
20+
pure = "on", # Pure Go for cross-platform compatibility
21+
visibility = ["//visibility:public"],
22+
deps = ["@rules_go//go/runfiles"],
23+
)
24+
25+
# Export for easy access in toolchains
26+
alias(
27+
name = "wasmsign2",
28+
actual = ":wasmsign2_wrapper",
5129
visibility = ["//visibility:public"],
5230
)

wit/wit_bindgen.bzl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@ def _wit_bindgen_impl(ctx):
5151
# Fallback to target name if world_name not provided
5252
base_filename = ctx.label.name.replace("_wit_bindgen_guest", "").replace("_wit_bindgen_native_guest", "")
5353

54-
# Include generation_mode in filename to avoid conflicts between guest and native-guest
54+
# wit-bindgen generates files without any suffix
55+
wit_bindgen_output_filename = base_filename + ".rs"
56+
57+
# Include generation_mode in Bazel output filename to avoid conflicts between guest and native-guest
5558
mode_suffix = "_" + ctx.attr.generation_mode.replace("-", "_") if ctx.attr.generation_mode != "guest" else ""
5659
rust_filename = base_filename + mode_suffix + ".rs"
5760
out_file = ctx.actions.declare_file(rust_filename)
@@ -179,9 +182,9 @@ def _wit_bindgen_impl(ctx):
179182

180183
# Extract the generated .rs file from output directory
181184
# wit-bindgen creates a predictable filename: world_name.to_snake_case() + ".rs"
182-
# Since world is now mandatory, we always know the exact filename
185+
# Use the filename that wit-bindgen actually generates (without our Bazel suffix)
183186
# Use file_ops component for cross-platform file copying
184-
source_path = out_dir.path + "/" + rust_filename
187+
source_path = out_dir.path + "/" + wit_bindgen_output_filename
185188

186189
# Build JSON config for file_ops
187190
config_file = ctx.actions.declare_file(ctx.label.name + "_extract_config.json")
@@ -208,7 +211,7 @@ def _wit_bindgen_impl(ctx):
208211
inputs = [out_dir, config_file],
209212
outputs = [out_file],
210213
mnemonic = "ExtractRustBinding",
211-
progress_message = "Extracting {} from wit-bindgen output".format(rust_filename),
214+
progress_message = "Extracting {} from wit-bindgen output".format(wit_bindgen_output_filename),
212215
)
213216
else:
214217
# No dependencies - run wit-bindgen directly on WIT files

0 commit comments

Comments
 (0)