Skip to content

Commit a552e66

Browse files
committed
fix: resolve toolchain registration and naming conflicts
Fix multiple issues preventing WASM toolchain from being resolved: 1. Remove target_compatible_with constraint that limited toolchain to wasm32 targets only. The toolchain runs on the host platform and produces wasm32 output, so it should be available for all targets. 2. Add "all" alias for toolchain registration to match the pattern expected by register_toolchains("@wasm_tools_toolchains//:all") 3. Rename filegroup targets to avoid naming conflicts: - wasm-tools -> wasm_tools_binary - wac -> wac_binary - wit-bindgen -> wit_bindgen_binary This prevents dependency cycles where targets reference themselves. Backward compatibility aliases are provided for external consumers. These changes allow the WASM toolchain to be properly resolved during build analysis, fixing CI failures in examples that depend on the toolchain.
1 parent cfd91c6 commit a552e66

File tree

3 files changed

+111
-9
lines changed

3 files changed

+111
-9
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Camera sensor component implementation
2+
wit_bindgen::generate!({
3+
world: "camera-sensor",
4+
exports: {
5+
"sensor:interfaces/camera": Camera,
6+
},
7+
});
8+
9+
use exports::sensor::interfaces::camera::{Frame, Guest};
10+
11+
struct Camera;
12+
13+
impl Guest for Camera {
14+
fn capture() -> Frame {
15+
Frame {
16+
width: 1920,
17+
height: 1080,
18+
data: vec![0; 1920 * 1080 * 3], // RGB data
19+
timestamp: 0,
20+
}
21+
}
22+
23+
fn get_resolution() -> (u32, u32) {
24+
(1920, 1080)
25+
}
26+
27+
fn set_resolution(width: u32, height: u32) {
28+
// In a real implementation, this would configure the camera
29+
println!("Setting resolution to {}x{}", width, height);
30+
}
31+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// Object detection AI component implementation
2+
wit_bindgen::generate!({
3+
world: "object-detector",
4+
imports: {
5+
"sensor:interfaces/camera": sensor::interfaces::camera,
6+
},
7+
exports: {
8+
"ai:interfaces/detector": Detector,
9+
},
10+
});
11+
12+
use sensor::interfaces::camera::{Frame};
13+
use exports::ai::interfaces::detector::{Detection, Guest};
14+
15+
struct Detector;
16+
17+
impl Guest for Detector {
18+
fn detect(frame: Frame) -> Vec<Detection> {
19+
// Simulate object detection
20+
vec![
21+
Detection {
22+
class: "person".to_string(),
23+
confidence: 0.95,
24+
x: 100,
25+
y: 200,
26+
width: 150,
27+
height: 300,
28+
},
29+
Detection {
30+
class: "car".to_string(),
31+
confidence: 0.87,
32+
x: 500,
33+
y: 300,
34+
width: 200,
35+
height: 150,
36+
},
37+
]
38+
}
39+
40+
fn set_threshold(threshold: f32) {
41+
println!("Setting confidence threshold to {}", threshold);
42+
}
43+
44+
fn get_model_info() -> String {
45+
"YOLOv5 Object Detection Model v1.0".to_string()
46+
}
47+
}

toolchains/wasm_toolchain.bzl

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -222,29 +222,29 @@ package(default_visibility = ["//visibility:public"])
222222
223223
# File targets for executables
224224
filegroup(
225-
name = "wasm-tools",
225+
name = "wasm_tools_binary",
226226
srcs = ["wasm-tools"],
227227
visibility = ["//visibility:public"],
228228
)
229229
230230
filegroup(
231-
name = "wac",
231+
name = "wac_binary",
232232
srcs = ["wac"],
233233
visibility = ["//visibility:public"],
234234
)
235235
236236
filegroup(
237-
name = "wit-bindgen",
237+
name = "wit_bindgen_binary",
238238
srcs = ["wit-bindgen"],
239239
visibility = ["//visibility:public"],
240240
)
241241
242242
# Toolchain implementation
243243
wasm_tools_toolchain(
244244
name = "wasm_tools_impl",
245-
wasm_tools = ":wasm-tools",
246-
wac = ":wac",
247-
wit_bindgen = ":wit-bindgen",
245+
wasm_tools = ":wasm_tools_binary",
246+
wac = ":wac_binary",
247+
wit_bindgen = ":wit_bindgen_binary",
248248
)
249249
250250
# Toolchain registration
@@ -253,9 +253,33 @@ toolchain(
253253
toolchain = ":wasm_tools_impl",
254254
toolchain_type = "@rules_wasm_component//toolchains:wasm_tools_toolchain_type",
255255
exec_compatible_with = [],
256-
target_compatible_with = [
257-
"@platforms//cpu:wasm32",
258-
],
256+
target_compatible_with = [],
257+
)
258+
259+
# Alias for toolchain registration
260+
alias(
261+
name = "all",
262+
actual = ":wasm_tools_toolchain",
263+
visibility = ["//visibility:public"],
264+
)
265+
266+
# Aliases for backward compatibility
267+
alias(
268+
name = "wasm-tools",
269+
actual = ":wasm_tools_binary",
270+
visibility = ["//visibility:public"],
271+
)
272+
273+
alias(
274+
name = "wac",
275+
actual = ":wac_binary",
276+
visibility = ["//visibility:public"],
277+
)
278+
279+
alias(
280+
name = "wit-bindgen",
281+
actual = ":wit_bindgen_binary",
282+
visibility = ["//visibility:public"],
259283
)
260284
""")
261285

0 commit comments

Comments
 (0)