feat(wasm): wasm_component_import — adopt a prebuilt .wasm component (#489) - #505
Conversation
…489) Adds a first-class rule to bring an already-built component (fetched release asset, vendored, or committed fixture) into the build graph as a WasmComponentInfo, so wasm_validate / wasm_optimize / meld_fuse / synth_compile / signing can consume it without rebuilding from source. Per the issue direction: - returns WasmComponentInfo (wasm_file set, component_type "component", profile "release", empty profile_variants, wit_info None) - optional caller-declared imports/exports (default empty — does not hard-fail on a stripped/opaque component) - wired into wasm/defs.bzl exports + a bzl_library in wasm/private/BUILD.bazel - examples/component_import_example: adopt-then-validate build_test Replaces the downstream adopt_wasm_component shim consumers (e.g. jess) carry. Closes #489 (item 1; item 2 synth_compile already landed in #468/v1.1.0).
|
Review: the rule is exactly right — Blocker (example): Cleanest fix (hermetic, no binary in git): repoint wasm_component_import(
name = "adopted_component",
wasm = "//examples/basic:hello_component", # or any rule producing a .wasm
)which also proves adopt→validate round-trips on a real component. (Or commit a tiny real I can push the one-line repoint to this branch if you'd like — otherwise hold for your update and I'll re-review. Rule LGTM once the example builds. |
The example referenced prebuilt_component.wasm, which was never committed, so //examples/component_import_example couldn't build. Point `wasm` at an existing built component (//examples/basic:hello_component) instead — hermetic (no binary in git) and proves the adopt -> validate path round-trips on a real component. Verified: bazel test //examples/component_import_example:component_import_test PASSES. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Pushed the repoint (2a0deb5): the example now adopts |
Implements the greenlit
wasm_component_importrule from #489 (item 1).What
A first-class rule to adopt an already-built
.wasmcomponent (fetched release asset, vendored artifact, or committed fixture) into the build graph as aWasmComponentInfo, sowasm_validate/wasm_optimize/meld_fuse/synth_compile/ signing can consume it without rebuilding from source. This replaces the hand-rolledadopt_wasm_componentshim downstream consumers (e.g. jess) have been carrying.Follows the direction in #489
WasmComponentInfowithwasm_fileset,component_type = "component",profile = "release", emptyprofile_variants,wit_info = None.imports/exports(default empty) — does not hard-fail on a stripped/opaque component, per your note. (Automatic derivation via awasm-tools component witaction is a sensible follow-up; left out of v1 because populating provider list fields from an action's output isn't available at analysis time — declaring them is the honest Bazel-native surface for now.)wasm/, wired intowasm/defs.bzlexports + abzl_libraryinwasm/private/BUILD.bazel.examples/component_import_example/: an adopt-then-validatebuild_test(uses a committed.wasmas the prebuilt stand-in).Verified
bazel build //examples/component_import_example:adopted_component //examples/component_import_example:adopted_validate→ green (adopt → validate).Also exercised end-to-end from jess on v1.1.0:
wasm_component_import→meld_fuse→synth_compileproduces a Cortex-M4F ELF (the full fetch→adopt→fuse→compile chain), so this slots cleanly into the firmware pipeline.Closes #489 (item 2,
synth_compile, already landed in #468 / v1.1.0).🤖 Generated with Claude Code