Skip to content

Commit 3c83680

Browse files
committed
fix: add bitflags module to embedded wit_bindgen runtime
Add bitflags module to the embedded runtime in rust_wasm_component_bindgen.bzl to support WASI filesystem interfaces that generate bitflags for DescriptorFlags, PathFlags, and OpenFlags. Changes: - Add pub mod bitflags with pub(crate) use bitflags in both guest and native-guest wrappers - Add bitflags dependency to both bindings libraries - Add bitflags crate to tools/checksum_updater Cargo.toml The bitflags macro is now accessible as crate::wit_bindgen::rt::bitflags::bitflags! as expected by generated code. Tested with: - //examples/basic:hello_component_bindings_host - //tools/checksum_updater_wasm:checksum_updater_wasm_component (uses wasi:filesystem/types)
1 parent 731ad57 commit 3c83680

File tree

4 files changed

+51
-33
lines changed

4 files changed

+51
-33
lines changed

MODULE.bazel.lock

Lines changed: 31 additions & 31 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/rust_wasm_component_bindgen.bzl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,13 @@ pub mod wit_bindgen {
157157
}
158158
}
159159
}
160+
161+
// Bitflags module for WASI interfaces
162+
pub mod bitflags {
163+
// Re-export bitflags macro without #[macro_export]
164+
// Generated code expects: crate::wit_bindgen::rt::bitflags::bitflags!
165+
pub(crate) use bitflags;
166+
}
160167
}
161168
}
162169
@@ -244,6 +251,13 @@ pub mod wit_bindgen {
244251
}
245252
}
246253
}
254+
255+
// Bitflags module for WASI interfaces
256+
pub mod bitflags {
257+
// Re-export bitflags macro without #[macro_export]
258+
// Generated code expects: crate::wit_bindgen::rt::bitflags::bitflags!
259+
pub(crate) use bitflags;
260+
}
247261
}
248262
}
249263
@@ -498,6 +512,7 @@ def rust_wasm_component_bindgen(
498512
srcs = [":" + wrapper_native_guest_target],
499513
crate_name = name.replace("-", "_") + "_bindings",
500514
edition = "2021",
515+
deps = ["@crates//:bitflags"], # Required for WASI filesystem interfaces
501516
visibility = visibility, # Make native bindings publicly available
502517
)
503518

@@ -508,6 +523,7 @@ def rust_wasm_component_bindgen(
508523
srcs = [":" + wrapper_guest_target],
509524
crate_name = name.replace("-", "_") + "_bindings",
510525
edition = "2021",
526+
deps = ["@crates//:bitflags"], # Required for WASI filesystem interfaces
511527
visibility = ["//visibility:private"],
512528
)
513529

tools/checksum_updater/Cargo.lock

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tools/checksum_updater/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ tempfile = "3.23"
3333
async-trait = "0.1"
3434
wit-bindgen = "0.46.0" # WIT binding generation for macro usage (MUST match CLI version in wasm_toolchain.bzl)
3535
uuid = { version = "1.18", default-features = false } # UUID generation for user service (deterministic, no getrandom dependency)
36+
bitflags = "2.6" # Bitflags for WASI filesystem interfaces in generated bindings
3637

3738
[dev-dependencies]
3839
tokio-test = "0.4"

0 commit comments

Comments
 (0)