Skip to content

Commit 396cec6

Browse files
committed
refactor: eliminate shared dependency workspace and simplify toolchain approach
- Remove shared bazel_tools_deps directory that caused version conflicts - Implement separate crate_universe workspace for wasmsign2 (Bazel-native rust_binary) - Revert wizer and wasm-tools to use proven download strategy (hermetic binaries) - Remove unused legacy toolchain files (BUILD.hermetic, BUILD.nixpkgs, etc.) - Fix cpp_component_toolchain missing function and wasi_sdk extension issues - Clean up 5 unused BUILD files and 1 unused .bzl file following RULE #1: THE BAZEL WAY FIRST Strategy now follows proven patterns: - wasmsign2: Bazel-native build with separate dependency resolution ✅ - wizer: Download strategy (hermetic pre-built binaries) ✅ - wasm-tools: Download strategy (hermetic pre-built binaries) ✅
1 parent b4deae0 commit 396cec6

File tree

9 files changed

+207
-306
lines changed

9 files changed

+207
-306
lines changed

MODULE.bazel

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ register_toolchains("@tinygo_toolchain//:tinygo_toolchain_def")
107107
wizer = use_extension("//wasm:extensions.bzl", "wizer")
108108
wizer.register(
109109
name = "wizer",
110-
strategy = "build",
110+
strategy = "download",
111111
version = "9.0.0",
112112
)
113113
use_repo(wizer, "wizer_toolchain")
@@ -187,30 +187,25 @@ crate.from_cargo(
187187
],
188188
)
189189
crate.from_cargo(
190-
name = "bazel_tools_crates",
191-
cargo_lockfile = "//toolchains/bazel_tools_deps:Cargo.lock",
192-
manifests = ["//toolchains/bazel_tools_deps:Cargo.toml"],
190+
name = "wasmsign2_crates",
191+
manifests = ["@wasmsign2_src//:Cargo.toml"],
193192
supported_platform_triples = [
194193
"x86_64-unknown-linux-gnu",
195194
"aarch64-unknown-linux-gnu", # BCR environment ARM64 Linux
196195
"aarch64-apple-darwin",
197196
"x86_64-pc-windows-msvc",
198197
],
199198
)
200-
use_repo(crate, "bazel_tools_crates", "crates", "wizer_crates")
199+
use_repo(crate, "crates", "wasmsign2_crates", "wizer_crates")
201200

202201
# Modernized WASM tool repositories using git_repository + rules_rust
203202
wasm_tool_repos = use_extension("//toolchains:extensions.bzl", "wasm_tool_repositories")
204203
use_repo(
205204
wasm_tool_repos,
206205
"wac_src",
207206
"wasm_tools_src",
207+
"wasmsign2_src",
208208
"wit_bindgen_src",
209209
"wizer_src",
210210
"wrpc_src",
211211
)
212-
213-
# Hermetic WebAssembly tools via http_archive using checksum registry
214-
wasm_hermetic = use_extension("//toolchains:hermetic_extension.bzl", "wasm_hermetic")
215-
wasm_hermetic.register()
216-
use_repo(wasm_hermetic, "wac_hermetic", "wasm_tools_hermetic", "wasmtime_hermetic", "wit_bindgen_hermetic", "wkg_hermetic")

toolchains/BUILD.bazel

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -188,63 +188,3 @@ toolchain(
188188
toolchain = ":wasm_tools_component_toolchain_impl",
189189
toolchain_type = ":wasm_tools_component_toolchain_type",
190190
)
191-
192-
# Hermetic WebAssembly toolchain using pre-built binaries
193-
# These tools are downloaded via http_archive in the hermetic_extension
194-
195-
# Create filegroups for easy access to the hermetic tools
196-
filegroup(
197-
name = "wasm_tools_hermetic_filegroup",
198-
srcs = ["@wasm_tools_hermetic//:bin"],
199-
visibility = ["//visibility:public"],
200-
)
201-
202-
filegroup(
203-
name = "wasmtime_hermetic_filegroup",
204-
srcs = ["@wasmtime_hermetic//:bin"],
205-
visibility = ["//visibility:public"],
206-
)
207-
208-
filegroup(
209-
name = "wit_bindgen_hermetic_filegroup",
210-
srcs = ["@wit_bindgen_hermetic//:bin"],
211-
visibility = ["//visibility:public"],
212-
)
213-
214-
filegroup(
215-
name = "wac_hermetic_filegroup",
216-
srcs = ["@wac_hermetic//file"],
217-
visibility = ["//visibility:public"],
218-
)
219-
220-
filegroup(
221-
name = "wkg_hermetic_filegroup",
222-
srcs = ["@wkg_hermetic//file"],
223-
visibility = ["//visibility:public"],
224-
)
225-
226-
# Maintain backwards compatibility with simpler names
227-
alias(
228-
name = "wasm_tools_hermetic",
229-
actual = ":wasm_tools_hermetic_filegroup",
230-
)
231-
232-
alias(
233-
name = "wasmtime_hermetic",
234-
actual = ":wasmtime_hermetic_filegroup",
235-
)
236-
237-
alias(
238-
name = "wit_bindgen_hermetic",
239-
actual = ":wit_bindgen_hermetic_filegroup",
240-
)
241-
242-
alias(
243-
name = "wac_hermetic",
244-
actual = ":wac_hermetic_filegroup",
245-
)
246-
247-
alias(
248-
name = "wkg_hermetic",
249-
actual = ":wkg_hermetic_filegroup",
250-
)

toolchains/BUILD.wasm_tools

Lines changed: 3 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,10 @@
11
"""BUILD file for wasm-tools repository
22

3-
This file creates wasm-tools binary using both cargo (legacy) and Bazel-native rust_binary.
4-
The rust_binary approach eliminates cargo sandbox issues.
3+
This file creates wasm-tools binary using cargo build with download strategy.
4+
The download strategy provides hermetic builds without complex workspace dependencies.
55
"""
66

7-
load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_library")
8-
9-
# Bazel-native rust_binary build (NEW: eliminates cargo sandbox issues)
10-
rust_binary(
11-
name = "wasm_tools_bazel",
12-
srcs = [
13-
"src/bin/wasm-tools/main.rs",
14-
],
15-
crate_name = "wasm_tools",
16-
edition = "2021",
17-
deps = [
18-
":wasm_tools_lib",
19-
],
20-
visibility = ["//visibility:public"],
21-
)
22-
23-
# Supporting library crate for Bazel-native build
24-
rust_library(
25-
name = "wasm_tools_lib",
26-
srcs = glob([
27-
"src/**/*.rs",
28-
], exclude = [
29-
"src/bin/**/*.rs",
30-
]),
31-
crate_name = "wasm_tools",
32-
edition = "2021",
33-
deps = [
34-
# Use dependencies from bazel_tools_crates
35-
"@bazel_tools_crates//:anyhow",
36-
"@bazel_tools_crates//:clap",
37-
"@bazel_tools_crates//:env_logger",
38-
"@bazel_tools_crates//:log",
39-
"@bazel_tools_crates//:serde",
40-
"@bazel_tools_crates//:serde_json",
41-
"@bazel_tools_crates//:termcolor",
42-
"@bazel_tools_crates//:wat",
43-
"@bazel_tools_crates//:wasm-encoder",
44-
"@bazel_tools_crates//:wasmparser",
45-
"@bazel_tools_crates//:wasmprinter",
46-
"@bazel_tools_crates//:wasm-mutate",
47-
"@bazel_tools_crates//:wasm-shrink",
48-
"@bazel_tools_crates//:wasm-smith",
49-
"@bazel_tools_crates//:wit-parser",
50-
"@bazel_tools_crates//:wit-component",
51-
],
52-
visibility = ["//visibility:public"],
53-
)
54-
55-
# Legacy cargo build (for backward compatibility)
7+
# Cargo build for wasm-tools
568
genrule(
579
name = "wasm_tools_cargo",
5810
srcs = glob(["**/*"]), # All source files

toolchains/BUILD.wasmsign2

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
"""BUILD file for wasmsign2 repository
2+
3+
This file creates wasmsign2 binary using both cargo (legacy) and Bazel-native rust_binary.
4+
The rust_binary approach eliminates cargo sandbox issues and provides true hermeticity.
5+
"""
6+
7+
load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_library")
8+
9+
# Bazel-native rust_binary build (NEW: eliminates cargo sandbox issues)
10+
rust_binary(
11+
name = "wasmsign2_bazel",
12+
srcs = [
13+
"src/cli/main.rs",
14+
],
15+
crate_name = "wasmsign2",
16+
edition = "2021",
17+
deps = [
18+
":wasmsign2_lib",
19+
# CLI-specific dependencies from wasmsign2 CLI Cargo.toml
20+
"@wasmsign2_crates//:clap",
21+
"@wasmsign2_crates//:env_logger",
22+
"@wasmsign2_crates//:regex",
23+
"@wasmsign2_crates//:ureq",
24+
"@wasmsign2_crates//:uri_encode",
25+
],
26+
visibility = ["//visibility:public"],
27+
)
28+
29+
# Supporting library crate for Bazel-native build
30+
rust_library(
31+
name = "wasmsign2_lib",
32+
srcs = glob([
33+
"src/lib/src/**/*.rs",
34+
]),
35+
crate_root = "src/lib/src/lib.rs",
36+
crate_name = "wasmsign2",
37+
edition = "2021",
38+
deps = [
39+
# Core dependencies from wasmsign2 library Cargo.toml
40+
"@wasmsign2_crates//:anyhow",
41+
"@wasmsign2_crates//:ct-codecs",
42+
"@wasmsign2_crates//:ed25519-compact",
43+
"@wasmsign2_crates//:getrandom",
44+
"@wasmsign2_crates//:hmac-sha256",
45+
"@wasmsign2_crates//:log",
46+
"@wasmsign2_crates//:regex",
47+
"@wasmsign2_crates//:ssh-keys",
48+
"@wasmsign2_crates//:thiserror",
49+
],
50+
visibility = ["//visibility:public"],
51+
)
52+
53+
# Legacy cargo build (for backward compatibility during transition)
54+
genrule(
55+
name = "wasmsign2",
56+
srcs = glob(["**/*"]), # All source files
57+
outs = ["wasmsign2"],
58+
cmd = """cd $$(dirname $(location Cargo.toml)) && \
59+
cargo build --release --bin wasmsign2 && \
60+
cp target/release/wasmsign2 $(location wasmsign2)""",
61+
visibility = ["//visibility:public"],
62+
tags = ["requires-network"], # Cargo may need to fetch dependencies
63+
)
64+
65+
# Export the legacy binary for toolchain use
66+
filegroup(
67+
name = "wasmsign2_binary",
68+
srcs = [":wasmsign2"],
69+
visibility = ["//visibility:public"],
70+
)

toolchains/BUILD.wizer

Lines changed: 3 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,10 @@
11
"""BUILD file for wizer repository
22

3-
This file creates wizer binary using both cargo (legacy) and Bazel-native rust_binary.
4-
The rust_binary approach eliminates cargo sandbox issues.
3+
This file creates wizer binary using cargo build with download strategy.
4+
The download strategy provides hermetic builds without complex workspace dependencies.
55
"""
66

7-
load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_library")
8-
9-
# Bazel-native rust_binary build (NEW: eliminates cargo sandbox issues)
10-
rust_binary(
11-
name = "wizer_bazel",
12-
srcs = [
13-
"src/bin/wizer.rs",
14-
],
15-
crate_name = "wizer",
16-
edition = "2021",
17-
deps = [
18-
":wizer_lib",
19-
],
20-
visibility = ["//visibility:public"],
21-
)
22-
23-
# Supporting library crate for Bazel-native build
24-
rust_library(
25-
name = "wizer_lib",
26-
srcs = glob([
27-
"src/**/*.rs",
28-
], exclude = [
29-
"src/bin/**/*.rs",
30-
]),
31-
crate_name = "wizer",
32-
edition = "2021",
33-
deps = [
34-
# Use dependencies from bazel_tools_crates
35-
"@bazel_tools_crates//:anyhow",
36-
"@bazel_tools_crates//:clap",
37-
"@bazel_tools_crates//:env_logger",
38-
"@bazel_tools_crates//:log",
39-
"@bazel_tools_crates//:wasmtime",
40-
"@bazel_tools_crates//:wasmtime-wasi",
41-
"@bazel_tools_crates//:wasm-encoder",
42-
"@bazel_tools_crates//:wasmparser",
43-
],
44-
visibility = ["//visibility:public"],
45-
)
46-
47-
# Legacy cargo build (for backward compatibility)
7+
# Cargo build for wizer
488
genrule(
499
name = "wizer",
5010
srcs = glob(["**/*"]), # All source files

0 commit comments

Comments
 (0)