diff --git a/.github/workflows/bcr-compatibility.yml b/.github/workflows/bcr-compatibility.yml index bf26792c..afa63cf7 100644 --- a/.github/workflows/bcr-compatibility.yml +++ b/.github/workflows/bcr-compatibility.yml @@ -186,8 +186,8 @@ jobs: name: BCR Multi-Platform Test runs-on: ${{ matrix.os }} timeout-minutes: 25 - # Only run on main branch to avoid overloading PR checks - if: github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch' + # Run on all PRs and main branch to catch Windows issues early + # Windows builds have been failing silently - now we'll catch them! strategy: fail-fast: false @@ -198,6 +198,13 @@ jobs: # Skip some combinations to reduce CI load - os: windows-latest bazel_version: "6.x" + # On PRs, only test latest Bazel versions to reduce load + - os: windows-latest + bazel_version: "7.x" + - os: ubuntu-latest + bazel_version: "6.x" + - os: macos-latest + bazel_version: "6.x" steps: - name: Checkout Repository diff --git a/.gitignore b/.gitignore index 60b5a54e..8c98f7b8 100644 --- a/.gitignore +++ b/.gitignore @@ -80,3 +80,6 @@ coverage/ perf.data flamegraph.svg __pycache__/ + +# Legacy bazel strategy BUILD files (removed in dependency management cleanup) +toolchains/BUILD.*_bazel diff --git a/CLAUDE.md b/CLAUDE.md index d37d8499..770086fe 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -295,6 +295,246 @@ http_archive( - **Path Handling**: Use Bazel's path utilities - **Platform Detection**: Use `@platforms//` constraints, not `uname` +## Dependency Management Patterns + +### 🎯 RULE #2: STRATIFIED HYBRID APPROACH + +**Use the RIGHT download pattern for each dependency category** + +This project uses a **stratified hybrid approach** to dependency management, selecting the most appropriate mechanism based on the characteristics of each dependency type. + +### Decision Matrix + +| Dependency Type | Pattern | Location | Why | +|----------------|---------|----------|-----| +| **Multi-platform GitHub binaries** | JSON Registry + secure_download | `checksums/tools/*.json` | Solves platform × version matrix, central security auditing | +| **Bazel Central Registry deps** | `bazel_dep` | `MODULE.bazel` | Ecosystem standard, automatic dependency resolution | +| **Source builds** | `git_repository` | `wasm_tools_repositories.bzl` | Bazel standard, maximum flexibility | +| **Universal WASM binaries** | JSON Registry (preferred) or `http_file` | `checksums/tools/*.json` or `MODULE.bazel` | Platform-independent, security auditable | +| **NPM packages** | Hermetic npm + package.json | `toolchains/jco_toolchain.bzl` | Ecosystem standard, package lock files | + +### Pattern 1: JSON Registry (Multi-Platform GitHub Binaries) + +**Use for**: Tools with different binaries per platform (wasm-tools, wit-bindgen, wac, wkg, wasmtime, wizer, wasi-sdk, nodejs, tinygo) + +**Why**: Elegantly handles the combinatorial explosion of (platforms × versions × URL patterns) + +**Structure**: +```json +{ + "tool_name": "wasm-tools", + "github_repo": "bytecodealliance/wasm-tools", + "latest_version": "1.240.0", + "supported_platforms": ["darwin_amd64", "darwin_arm64", "linux_amd64", "linux_arm64", "windows_amd64"], + "versions": { + "1.240.0": { + "release_date": "2025-10-08", + "platforms": { + "darwin_arm64": { + "sha256": "8959eb9f494af13868af9e13e74e4fa0fa6c9306b492a9ce80f0e576eb10c0c6", + "url_suffix": "aarch64-macos.tar.gz" + } + // ... other platforms + } + } + } +} +``` + +**Usage**: +```python +# In toolchain .bzl file +from toolchains.secure_download import secure_download_tool + +secure_download_tool(ctx, "wasm-tools", "1.240.0", platform) +``` + +**Benefits**: +- ✅ Single source of truth for all versions and checksums +- ✅ Central security auditing (`checksums/` directory) +- ✅ Supports multiple versions side-by-side +- ✅ Platform detection and URL construction automatic +- ✅ Clean API via `registry.bzl` + +### Pattern 2: Bazel Central Registry (`bazel_dep`) + +**Use for**: Standard Bazel ecosystem dependencies (rules_rust, bazel_skylib, platforms, rules_cc, etc.) + +**Why**: Bazel's standard mechanism with automatic dependency resolution + +**Structure**: +```starlark +# MODULE.bazel +bazel_dep(name = "rules_rust", version = "0.65.0") +bazel_dep(name = "bazel_skylib", version = "1.8.1") +bazel_dep(name = "platforms", version = "1.0.0") +``` + +**Benefits**: +- ✅ Ecosystem standard - no learning curve +- ✅ Automatic transitive dependency resolution +- ✅ Maintained by Bazel team +- ✅ Built-in security and version compatibility + +**Do NOT**: +- ❌ Duplicate BCR deps in JSON registry +- ❌ Use http_archive for tools available in BCR + +### Pattern 3: Git Repository (Source Builds) + +**Use for**: Custom forks, bleeding edge versions, or when source builds are required + +**Why**: Bazel-native source repository management + +**Structure**: +```starlark +# wasm_tools_repositories.bzl +load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") + +git_repository( + name = "wasm_tools_src", + remote = "https://github.com/bytecodealliance/wasm-tools.git", + tag = "v1.235.0", + build_file = "//toolchains:BUILD.wasm_tools", +) +``` + +**When to use**: +- Custom fork with patches +- Need bleeding edge from main branch +- Binary not available for your platform +- Building from source is required for licensing + +**Prefer download over build**: When prebuilt binaries are available and work correctly, use Pattern 1 (JSON Registry) instead for faster, more hermetic builds. + +### Pattern 4: Universal WASM Binaries + +**Use for**: WebAssembly components (platform-independent .wasm files) + +**Preferred**: JSON Registry for consistency and security auditing +```json +// checksums/tools/file-ops-component.json +{ + "tool_name": "file-ops-component", + "github_repo": "pulseengine/bazel-file-ops-component", + "latest_version": "0.1.0-rc.3", + "supported_platforms": ["wasm"], // Universal + "versions": { + "0.1.0-rc.3": { + "release_date": "2025-10-15", + "platforms": { + "wasm": { + "sha256": "8a9b1aa8a2c9d3dc36f1724ccbf24a48c473808d9017b059c84afddc55743f1e", + "url": "https://github.com/.../file_ops_component.wasm" + } + } + } + } +} +``` + +**Alternative**: `http_file` for very simple cases (legacy) +```starlark +# MODULE.bazel (only for simple cases) +http_file( + name = "component_external", + url = "https://github.com/.../component.wasm", + sha256 = "abc123...", + downloaded_file_path = "component.wasm", +) +``` + +**Recommendation**: Migrate all WASM components to JSON Registry for: +- Consistent security auditing +- Version management +- Same tooling as other downloads + +### Pattern 5: NPM Packages + +**Use for**: Node.js ecosystem tools (jco, componentize-js) + +**Why**: npm is the standard package manager with lock file support + +**Structure**: +```python +# Download hermetic Node.js first (Pattern 1) +secure_download_tool(ctx, "nodejs", "20.18.0", platform) + +# Use hermetic npm for package installation +ctx.execute([npm_path, "install", "@bytecodealliance/jco@1.4.0"]) +``` + +**Benefits**: +- ✅ Hermetic builds (no system Node.js dependency) +- ✅ Package lock files for reproducibility +- ✅ Ecosystem standard + +### Adding New Dependencies + +**Decision Tree**: + +1. **Is it in Bazel Central Registry?** + - YES → Use `bazel_dep` (Pattern 2) + - NO → Continue to step 2 + +2. **Is it a GitHub release with platform-specific binaries?** + - YES → Create JSON in `checksums/tools/` (Pattern 1) + - NO → Continue to step 3 + +3. **Is it a universal WASM component?** + - YES → Create JSON in `checksums/tools/` with platform "wasm" (Pattern 4) + - NO → Continue to step 4 + +4. **Is it an NPM package?** + - YES → Use hermetic npm installation (Pattern 5) + - NO → Continue to step 5 + +5. **Must it be built from source?** + - YES → Use `git_repository` (Pattern 3) + - NO → Reconsider if this dependency is needed + +### Security Best Practices + +1. **Always verify checksums**: All downloads MUST have SHA256 verification +2. **Central audit trail**: Prefer JSON registry for auditability +3. **Version pinning**: Always specify exact versions, never use "latest" +4. **Minimal versions**: Keep only latest stable + previous stable in JSON files +5. **Review changes**: All checksum changes require careful PR review + +### Maintenance Guidelines + +**Adding a new version to JSON registry**: +```bash +# 1. Download binaries for all platforms +# 2. Calculate SHA256 checksums +shasum -a 256 wasm-tools-1.241.0-*.tar.gz + +# 3. Add version block to JSON file +# 4. Update "latest_version" if appropriate +# 5. Remove old versions if keeping only latest + previous +``` + +**Updating a BCR dependency**: +```starlark +# Simply change version in MODULE.bazel +bazel_dep(name = "rules_rust", version = "0.66.0") # Updated +``` + +**Removing old versions**: +- Keep latest stable version +- Keep previous stable version (for rollback capability) +- Remove all older versions +- Update tests if they pin to old versions + +### Anti-Patterns to Avoid + +❌ **DO NOT** create custom download mechanisms +❌ **DO NOT** hardcode URLs in .bzl files +❌ **DO NOT** duplicate BCR dependencies in JSON registry +❌ **DO NOT** use http_archive for multi-platform binaries (use JSON registry) +❌ **DO NOT** keep more than 2 versions per tool without strong justification +❌ **DO NOT** use "strategy options" - pick ONE best approach per tool + ## Current State ### Toolchains Implemented diff --git a/MODULE.bazel b/MODULE.bazel index e6bf7955..0dc8b10d 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -72,7 +72,7 @@ use_repo(wasi_wit_ext, "wasi_cli", "wasi_cli_v020", "wasi_clocks", "wasi_clocks_ wasm_toolchain = use_extension("//wasm:extensions.bzl", "wasm_toolchain") wasm_toolchain.register( name = "wasm_tools", - strategy = "hybrid", # Hybrid strategy: download binaries + build wasmsign2 from source + strategy = "download", # Download prebuilt binaries from GitHub releases version = "1.240.0", ) use_repo(wasm_toolchain, "wasm_tools_toolchains") diff --git a/MODULE.bazel.lock b/MODULE.bazel.lock index bcd3656e..078ecf90 100644 --- a/MODULE.bazel.lock +++ b/MODULE.bazel.lock @@ -274,7 +274,7 @@ }, "//wasm:extensions.bzl%cpp_component": { "general": { - "bzlTransitiveDigest": "wRxTYf8zqgy7AvgnVQHz+FrpmCkfMTbdcF1olU7aUDE=", + "bzlTransitiveDigest": "/oN4pY14mdYJUl00/7G6+RrF44guzO7Rz4UN7MzMNGE=", "usagesDigest": "60f0O3+qNo5tYrXjypa0YLZBtNMmSOws3xIOdJkff/0=", "recordedFileInputs": {}, "recordedDirentsInputs": {}, @@ -299,7 +299,7 @@ }, "//wasm:extensions.bzl%jco": { "general": { - "bzlTransitiveDigest": "wRxTYf8zqgy7AvgnVQHz+FrpmCkfMTbdcF1olU7aUDE=", + "bzlTransitiveDigest": "/oN4pY14mdYJUl00/7G6+RrF44guzO7Rz4UN7MzMNGE=", "usagesDigest": "Q/dCQKDfQQu8p/6sB8y5vGvN4aSwDm+u8BTrw309aao=", "recordedFileInputs": {}, "recordedDirentsInputs": {}, @@ -324,7 +324,7 @@ }, "//wasm:extensions.bzl%tinygo": { "general": { - "bzlTransitiveDigest": "wRxTYf8zqgy7AvgnVQHz+FrpmCkfMTbdcF1olU7aUDE=", + "bzlTransitiveDigest": "/oN4pY14mdYJUl00/7G6+RrF44guzO7Rz4UN7MzMNGE=", "usagesDigest": "S9y9QlSWG6nNe0ujZB9tmQlT4Pg033+LyW4mGmjksG4=", "recordedFileInputs": {}, "recordedDirentsInputs": {}, @@ -348,7 +348,7 @@ }, "//wasm:extensions.bzl%wasi_sdk": { "general": { - "bzlTransitiveDigest": "wRxTYf8zqgy7AvgnVQHz+FrpmCkfMTbdcF1olU7aUDE=", + "bzlTransitiveDigest": "/oN4pY14mdYJUl00/7G6+RrF44guzO7Rz4UN7MzMNGE=", "usagesDigest": "RoedjSblpjIxlcUjWjhz1L4mn2x/vCtO1RtPL64VguE=", "recordedFileInputs": {}, "recordedDirentsInputs": {}, @@ -568,8 +568,8 @@ }, "//wasm:extensions.bzl%wasm_toolchain": { "general": { - "bzlTransitiveDigest": "wRxTYf8zqgy7AvgnVQHz+FrpmCkfMTbdcF1olU7aUDE=", - "usagesDigest": "XcxYpPkKjKFz1fOuQIqSudETcx5lvuhyVlrosriqy9k=", + "bzlTransitiveDigest": "/oN4pY14mdYJUl00/7G6+RrF44guzO7Rz4UN7MzMNGE=", + "usagesDigest": "K26JJMMwdObXgWtNKqdHJOJUbXGqqT6dDcEoXcxs5j8=", "recordedFileInputs": {}, "recordedDirentsInputs": {}, "envVariables": {}, @@ -577,7 +577,7 @@ "wasm_tools_toolchains": { "repoRuleId": "@@//toolchains:wasm_toolchain.bzl%wasm_toolchain_repository", "attributes": { - "strategy": "download", + "strategy": "hybrid", "version": "1.240.0", "git_commit": "main", "wasm_tools_commit": "", @@ -602,7 +602,7 @@ }, "//wasm:extensions.bzl%wasmtime": { "general": { - "bzlTransitiveDigest": "wRxTYf8zqgy7AvgnVQHz+FrpmCkfMTbdcF1olU7aUDE=", + "bzlTransitiveDigest": "/oN4pY14mdYJUl00/7G6+RrF44guzO7Rz4UN7MzMNGE=", "usagesDigest": "X0TLn9AsUHfmC/GjVrKBURcQOu1h8Php72I2yFmUfgk=", "recordedFileInputs": {}, "recordedDirentsInputs": {}, @@ -627,7 +627,7 @@ }, "//wasm:extensions.bzl%wizer": { "general": { - "bzlTransitiveDigest": "wRxTYf8zqgy7AvgnVQHz+FrpmCkfMTbdcF1olU7aUDE=", + "bzlTransitiveDigest": "/oN4pY14mdYJUl00/7G6+RrF44guzO7Rz4UN7MzMNGE=", "usagesDigest": "6/Tf087fjdhszmx0SYaOq709EsMncT4yVq6Sh711KFo=", "recordedFileInputs": {}, "recordedDirentsInputs": {}, @@ -652,7 +652,7 @@ }, "//wasm:extensions.bzl%wkg": { "general": { - "bzlTransitiveDigest": "wRxTYf8zqgy7AvgnVQHz+FrpmCkfMTbdcF1olU7aUDE=", + "bzlTransitiveDigest": "/oN4pY14mdYJUl00/7G6+RrF44guzO7Rz4UN7MzMNGE=", "usagesDigest": "RcQS+te70rl4obuTEDyFt+9qDoIYt1tzlCBPTO+Pato=", "recordedFileInputs": {}, "recordedDirentsInputs": {}, diff --git a/checksums/registry.bzl b/checksums/registry.bzl index 5f626dca..1d6a96d5 100644 --- a/checksums/registry.bzl +++ b/checksums/registry.bzl @@ -1,15 +1,27 @@ """Centralized checksum registry API for WebAssembly toolchain -This module provides a unified API for accessing tool checksums. Checksum data is -embedded in this file and kept synchronized with checksums/tools/*.json files, which -serve as the canonical source for checksum updater tools and external documentation. - -The embedded approach is used because Bazel rules don't have built-in JSON parsing -capabilities, making direct JSON loading impractical in the build system. +This module provides a unified API for accessing tool checksums from JSON files. """ +def _load_tool_checksums_from_json(repository_ctx, tool_name): + """Load checksums for a tool from JSON file + + Args: + repository_ctx: Repository context for file operations + tool_name: Name of the tool (e.g., 'wasm-tools', 'wit-bindgen') + + Returns: + Dict: Tool data from JSON file, or None if file not found + """ + json_file = repository_ctx.path(Label("@rules_wasm_component//checksums/tools:{}.json".format(tool_name))) + if not json_file.exists: + return None + + content = repository_ctx.read(json_file) + return json.decode(content) + def _load_tool_checksums(tool_name): - """Load checksums for a tool from embedded registry data + """Load checksums for a tool from embedded fallback data Args: tool_name: Name of the tool (e.g., 'wasm-tools', 'wit-bindgen') @@ -18,10 +30,8 @@ def _load_tool_checksums(tool_name): Dict: Tool data from embedded registry, or empty dict if not found Note: - This function uses embedded data rather than JSON file loading because - Bazel rules don't have built-in JSON parsing capabilities. The embedded - data is kept synchronized with checksums/tools/*.json files, which serve - as the canonical source for checksum updater tools and documentation. + This is fallback data for non-repository contexts. + Use _load_tool_checksums_from_json() in repository rules for up-to-date data. """ tool_data = _get_fallback_checksums(tool_name) @@ -61,7 +71,7 @@ def _get_fallback_checksums(tool_name): }, "windows_amd64": { "sha256": "ecf9f2064c2096df134c39c2c97af2c025e974cc32e3c76eb2609156c1690a74", - "url_suffix": "x86_64-windows.tar.gz", + "url_suffix": "x86_64-windows.zip", }, }, }, @@ -106,8 +116,8 @@ def _get_fallback_checksums(tool_name): "url_suffix": "aarch64-linux.tar.gz", }, "windows_amd64": { - "sha256": "0019dfc4b32d63c1392aa264aed2253c1e0c2fb09216f8e2cc269bbfb8bb49b5", - "url_suffix": "x86_64-windows.tar.gz", + "sha256": "039b1eaa170563f762355a23c5ee709790199433e35e5364008521523e9e3398", + "url_suffix": "x86_64-windows.zip", }, }, }, @@ -131,8 +141,8 @@ def _get_fallback_checksums(tool_name): "url_suffix": "aarch64-linux.tar.gz", }, "windows_amd64": { - "sha256": "0019dfc4b32d63c1392aa264aed2253c1e0c2fb09216f8e2cc269bbfb8bb49b5", - "url_suffix": "x86_64-windows.tar.gz", + "sha256": "81f012832e80fe09d384d86bb961d4779f6372a35fa965cc64efe318001ab27e", + "url_suffix": "x86_64-windows.zip", }, }, }, @@ -188,7 +198,7 @@ def _get_fallback_checksums(tool_name): "url_suffix": "aarch64-linux.tar.gz", }, "windows_amd64": { - "sha256": "e133d9f18bc0d8a3d848df78960f9974a4333bee7ed3f99b4c9e900e9e279029", + "sha256": "95c6380ec7c1e385be8427a2da1206d90163fd66b6cbb573a516390988ccbad2", "url_suffix": "x86_64-windows.zip", }, }, @@ -220,7 +230,7 @@ def _get_fallback_checksums(tool_name): "platform_name": "aarch64-unknown-linux-musl", }, "windows_amd64": { - "sha256": "d8c65e5471fc242d8c4993e2125912e10e9373f1e38249157491b3c851bd1336", + "sha256": "7ee34ea41cd567b2578929acce3c609e28818d03f0414914a3939f066737d872", "platform_name": "x86_64-pc-windows-gnu", }, }, @@ -245,7 +255,7 @@ def _get_fallback_checksums(tool_name): "platform_name": "aarch64-unknown-linux-musl", }, "windows_amd64": { - "sha256": "d8c65e5471fc242d8c4993e2125912e10e9373f1e38249157491b3c851bd1336", + "sha256": "7ee34ea41cd567b2578929acce3c609e28818d03f0414914a3939f066737d872", "platform_name": "x86_64-pc-windows-gnu", }, }, @@ -302,7 +312,7 @@ def _get_fallback_checksums(tool_name): "binary_name": "wkg-aarch64-unknown-linux-gnu", }, "windows_amd64": { - "sha256": "0019dfc4b32d63c1392aa264aed2253c1e0c2fb09216f8e2cc269bbfb8bb49b5", + "sha256": "930adea31da8d2a572860304c00903f7683966e722591819e99e26787e58416b", "binary_name": "wkg-x86_64-pc-windows-gnu", }, }, @@ -390,6 +400,10 @@ def _get_fallback_checksums(tool_name): "sha256": "4cf4c553c4640e63e780442146f87d83fdff5737f988c06a6e3b2f0228e37665", "url_suffix": "linux.tar.gz", }, + "windows_amd64": { + "sha256": "4a576c13125c91996d8cc3b70b7ea0612c2044598d2795c9be100d15f874adf6", + "url_suffix": "x86_64-windows.tar.gz", + }, }, }, "26": { @@ -801,6 +815,8 @@ def list_available_tools(): "wizer", "nodejs", "jco", + "file-ops-component", + "wasmsign2-cli", ] def validate_tool_compatibility(tools_config): diff --git a/checksums/tools/file-ops-component.json b/checksums/tools/file-ops-component.json index f279e60a..b247ffd7 100644 --- a/checksums/tools/file-ops-component.json +++ b/checksums/tools/file-ops-component.json @@ -35,16 +35,6 @@ "size_kb": 853 } } - }, - "0.1.0-rc.1": { - "release_date": "2024-10-24", - "description": "Initial test release", - "platforms": { - "wasm_component": { - "sha256": "UNKNOWN", - "url_suffix": "file_ops_component.wasm" - } - } } }, "security": { diff --git a/checksums/tools/nodejs.json b/checksums/tools/nodejs.json index b2e27947..19954b35 100644 --- a/checksums/tools/nodejs.json +++ b/checksums/tools/nodejs.json @@ -5,41 +5,6 @@ "last_checked": "2025-08-17T10:30:00Z", "note": "Node.js runtime for hermetic jco toolchain installation", "versions": { - "18.19.0": { - "release_date": "2024-01-09", - "platforms": { - "darwin_amd64": { - "sha256": "0a749fcdf5d6bf46e1c17b3ea01e050b4d1ec3f3073b14aa745527b45a759c74", - "url_suffix": "darwin-x64.tar.gz", - "binary_path": "node-v{}-darwin-x64/bin/node", - "npm_path": "node-v{}-darwin-x64/bin/npm" - }, - "darwin_arm64": { - "sha256": "8907c42a968765b77730fb319458d63ec4ed009265f8012097c3a052407aa99b", - "url_suffix": "darwin-arm64.tar.gz", - "binary_path": "node-v{}-darwin-arm64/bin/node", - "npm_path": "node-v{}-darwin-arm64/bin/npm" - }, - "linux_amd64": { - "sha256": "61632bb78ee828d6e8f42adc0bc2238a6b8200007093988d3927176a372281e8", - "url_suffix": "linux-x64.tar.xz", - "binary_path": "node-v{}-linux-x64/bin/node", - "npm_path": "node-v{}-linux-x64/bin/npm" - }, - "linux_arm64": { - "sha256": "cf94ab72e45b855257545fec1c017bdf30a9e23611561382eaf64576b999e72d", - "url_suffix": "linux-arm64.tar.xz", - "binary_path": "node-v{}-linux-arm64/bin/node", - "npm_path": "node-v{}-linux-arm64/bin/npm" - }, - "windows_amd64": { - "sha256": "5311913d45e1fcc3643c58d1e3926eb85437b180f025fe5857413c9f02403645", - "url_suffix": "win-x64.zip", - "binary_path": "node-v{}-win-x64/node.exe", - "npm_path": "node-v{}-win-x64/npm.cmd" - } - } - }, "18.20.8": { "release_date": "2024-09-03", "platforms": { diff --git a/checksums/tools/wac.json b/checksums/tools/wac.json index 15ffa894..97ae816f 100644 --- a/checksums/tools/wac.json +++ b/checksums/tools/wac.json @@ -24,7 +24,32 @@ "platform_name": "aarch64-apple-darwin" }, "windows_amd64": { - "sha256": "d8c65e5471fc242d8c4993e2125912e10e9373f1e38249157491b3c851bd1336", + "sha256": "7ee34ea41cd567b2578929acce3c609e28818d03f0414914a3939f066737d872", + "platform_name": "x86_64-pc-windows-gnu" + } + } + }, + "0.8.0": { + "release_date": "2024-08-20", + "platforms": { + "linux_amd64": { + "sha256": "9fee2d8603dc50403ebed580b47b8661b582ffde8a9174bf193b89ca00decf0f", + "platform_name": "x86_64-unknown-linux-musl" + }, + "linux_arm64": { + "sha256": "af966d4efbd411900073270bd4261ac42d9550af8ba26ed49288bb942476c5a9", + "platform_name": "aarch64-unknown-linux-musl" + }, + "darwin_amd64": { + "sha256": "cc58f94c611b3b7f27b16dd0a9a9fc63c91c662582ac7eaa9a14f2dac87b07f8", + "platform_name": "x86_64-apple-darwin" + }, + "darwin_arm64": { + "sha256": "6ca7f69f3e2bbab41f375a35e486d53e5b4968ea94271ea9d9bd59b0d2b65c13", + "platform_name": "aarch64-apple-darwin" + }, + "windows_amd64": { + "sha256": "7ee34ea41cd567b2578929acce3c609e28818d03f0414914a3939f066737d872", "platform_name": "x86_64-pc-windows-gnu" } } diff --git a/checksums/tools/wasi-sdk.json b/checksums/tools/wasi-sdk.json index 3a0afbdf..2a1d2ea5 100644 --- a/checksums/tools/wasi-sdk.json +++ b/checksums/tools/wasi-sdk.json @@ -24,8 +24,8 @@ "url_suffix": "linux.tar.gz" }, "windows_amd64": { - "sha256": "PLACEHOLDER_NEEDS_REAL_CHECKSUM_64_CHARS_XXXXXXXXXXXXXXXX", - "url_suffix": "windows.tar.gz" + "sha256": "4a576c13125c91996d8cc3b70b7ea0612c2044598d2795c9be100d15f874adf6", + "url_suffix": "x86_64-windows.tar.gz" } } }, @@ -53,31 +53,6 @@ "url_suffix": "windows.tar.gz" } } - }, - "25": { - "release_date": "2024-11-01", - "platforms": { - "darwin_amd64": { - "sha256": "55e3ff3fee1a15678a16eeccba0129276c9f6be481bc9c283e7f9f65bf055c11", - "url_suffix": "macos.tar.gz" - }, - "darwin_arm64": { - "sha256": "e1e529ea226b1db0b430327809deae9246b580fa3cae32d31c82dfe770233587", - "url_suffix": "macos.tar.gz" - }, - "linux_amd64": { - "sha256": "52640dde13599bf127a95499e61d6d640256119456d1af8897ab6725bcf3d89c", - "url_suffix": "linux.tar.gz" - }, - "linux_arm64": { - "sha256": "52640dde13599bf127a95499e61d6d640256119456d1af8897ab6725bcf3d89c", - "url_suffix": "linux.tar.gz" - }, - "windows_amd64": { - "sha256": "PLACEHOLDER_NEEDS_REAL_CHECKSUM_64_CHARS_XXXXXXXXXXXXXXXX", - "url_suffix": "windows.tar.gz" - } - } } } } diff --git a/checksums/tools/wasm-tools.json b/checksums/tools/wasm-tools.json index 76f300e0..45899d88 100644 --- a/checksums/tools/wasm-tools.json +++ b/checksums/tools/wasm-tools.json @@ -11,52 +11,6 @@ "windows_amd64" ], "versions": { - "1.235.0": { - "release_date": "2024-12-15", - "platforms": { - "windows_amd64": { - "sha256": "ecf9f2064c2096df134c39c2c97af2c025e974cc32e3c76eb2609156c1690a74", - "url_suffix": "x86_64-windows.tar.gz" - }, - "linux_arm64": { - "sha256": "384ca3691502116fb6f48951ad42bd0f01f9bf799111014913ce15f4f4dde5a2", - "url_suffix": "aarch64-linux.tar.gz" - }, - "darwin_amd64": { - "sha256": "154e9ea5f5477aa57466cfb10e44bc62ef537e32bf13d1c35ceb4fedd9921510", - "url_suffix": "x86_64-macos.tar.gz" - }, - "darwin_arm64": { - "sha256": "17035deade9d351df6183d87ad9283ce4ae7d3e8e93724ae70126c87188e96b2", - "url_suffix": "aarch64-macos.tar.gz" - }, - "linux_amd64": { - "sha256": "4c44bc776aadbbce4eedc90c6a07c966a54b375f8f36a26fd178cea9b419f584", - "url_suffix": "x86_64-linux.tar.gz" - } - } - }, - "1.236.0": { - "release_date": "2025-07-28", - "platforms": { - "darwin_amd64": { - "sha256": "d9356a9de047598d6c2b8ff4a5318c9305485152430e85ceec78052a9bd08828", - "url_suffix": "x86_64-macos.tar.gz" - }, - "darwin_arm64": { - "sha256": "d3094124e18f17864bd0e0de93f1938a466aca374c180962b2ba670a5ec9c8cf", - "url_suffix": "aarch64-macos.tar.gz" - }, - "linux_arm64": { - "sha256": "c11b4d02bd730a8c3e60f4066602ce4264a752013d6c9ec58d70b7f276c3b794", - "url_suffix": "aarch64-linux.tar.gz" - }, - "linux_amd64": { - "sha256": "a4fe8101d98f4efeb4854fde05d7c6a36a9a61e8249d4c72afcda4a4944723fb", - "url_suffix": "x86_64-linux.tar.gz" - } - } - }, "1.239.0": { "release_date": "2024-09-09", "platforms": { @@ -77,8 +31,8 @@ "url_suffix": "aarch64-linux.tar.gz" }, "windows_amd64": { - "sha256": "0019dfc4b32d63c1392aa264aed2253c1e0c2fb09216f8e2cc269bbfb8bb49b5", - "url_suffix": "x86_64-windows.tar.gz" + "sha256": "039b1eaa170563f762355a23c5ee709790199433e35e5364008521523e9e3398", + "url_suffix": "x86_64-windows.zip" } } }, @@ -102,8 +56,8 @@ "url_suffix": "aarch64-linux.tar.gz" }, "windows_amd64": { - "sha256": "0019dfc4b32d63c1392aa264aed2253c1e0c2fb09216f8e2cc269bbfb8bb49b5", - "url_suffix": "x86_64-windows.tar.gz" + "sha256": "81f012832e80fe09d384d86bb961d4779f6372a35fa965cc64efe318001ab27e", + "url_suffix": "x86_64-windows.zip" } } } diff --git a/checksums/tools/wasmsign2-cli.json b/checksums/tools/wasmsign2-cli.json new file mode 100644 index 00000000..5c674291 --- /dev/null +++ b/checksums/tools/wasmsign2-cli.json @@ -0,0 +1,26 @@ +{ + "tool_name": "wasmsign2-cli", + "github_repo": "pulseengine/wasmsign2", + "latest_version": "0.2.7-rc.2", + "last_checked": "2025-10-30T00:00:00.000000Z", + "supported_platforms": ["wasm_component"], + "versions": { + "0.2.7-rc.2": { + "release_date": "2025-10-30", + "description": "WebAssembly component signing tool", + "platforms": { + "wasm_component": { + "sha256": "0a2ba6a55621d83980daa7f38e3770ba6b9342736971a0cebf613df08377cd34", + "url_suffix": "wasmsign2-cli.wasm", + "downloaded_file_path": "wasmsign2.wasm" + } + } + } + }, + "notes": [ + "Platform-independent WebAssembly component", + "Used for signing WASM components", + "WASI Preview 2 compatible", + "Component Model v1 compliant" + ] +} diff --git a/checksums/tools/wasmtime.json b/checksums/tools/wasmtime.json index eae2c94e..ccd037ab 100644 --- a/checksums/tools/wasmtime.json +++ b/checksums/tools/wasmtime.json @@ -29,31 +29,6 @@ } } }, - "27.0.0": { - "release_date": "2024-12-18", - "platforms": { - "darwin_amd64": { - "sha256": "PLACEHOLDER_NEEDS_REAL_CHECKSUM_64_CHARS_XXXXXXXXXXXXXXXX", - "url_suffix": "x86_64-macos.tar.xz" - }, - "linux_amd64": { - "sha256": "PLACEHOLDER_NEEDS_REAL_CHECKSUM_64_CHARS_XXXXXXXXXXXXXXXX", - "url_suffix": "x86_64-linux.tar.xz" - }, - "darwin_arm64": { - "sha256": "PLACEHOLDER_NEEDS_REAL_CHECKSUM_64_CHARS_XXXXXXXXXXXXXXXX", - "url_suffix": "aarch64-macos.tar.xz" - }, - "windows_amd64": { - "sha256": "PLACEHOLDER_NEEDS_REAL_CHECKSUM_64_CHARS_XXXXXXXXXXXXXXXX", - "url_suffix": "x86_64-windows.zip" - }, - "linux_arm64": { - "sha256": "PLACEHOLDER_NEEDS_REAL_CHECKSUM_64_CHARS_XXXXXXXXXXXXXXXX", - "url_suffix": "aarch64-linux.tar.xz" - } - } - }, "37.0.2": { "release_date": "2025-09-04", "platforms": { diff --git a/checksums/tools/wkg.json b/checksums/tools/wkg.json index 0348e72b..936eb6d6 100644 --- a/checksums/tools/wkg.json +++ b/checksums/tools/wkg.json @@ -50,7 +50,7 @@ "binary_name": "wkg-aarch64-unknown-linux-gnu" }, "windows_amd64": { - "sha256": "0019dfc4b32d63c1392aa264aed2253c1e0c2fb09216f8e2cc269bbfb8bb49b5", + "sha256": "930adea31da8d2a572860304c00903f7683966e722591819e99e26787e58416b", "binary_name": "wkg-x86_64-pc-windows-gnu" } } diff --git a/toolchains/cpp_component_toolchain.bzl b/toolchains/cpp_component_toolchain.bzl index 5a2440c0..5df48f4e 100644 --- a/toolchains/cpp_component_toolchain.bzl +++ b/toolchains/cpp_component_toolchain.bzl @@ -77,9 +77,15 @@ def _detect_host_platform(repository_ctx): os_name = repository_ctx.os.name.lower() arch = repository_ctx.os.arch.lower() - if os_name == "mac os x": + # Normalize platform names for cross-platform compatibility + if "mac" in os_name or "darwin" in os_name: os_name = "darwin" + elif "windows" in os_name: + os_name = "windows" + elif "linux" in os_name: + os_name = "linux" + # Normalize architecture names if arch == "x86_64": arch = "amd64" elif arch == "aarch64": @@ -121,7 +127,7 @@ def _setup_downloaded_cpp_tools(repository_ctx, platform, wasi_sdk_version): "linux_arm64": "arm64-linux", "darwin_amd64": "x86_64-macos", "darwin_arm64": "arm64-macos", - "windows_amd64": "x86_64-mingw", + "windows_amd64": "x86_64-windows", } arch_os = platform_map.get(platform, "x86_64-linux") wasi_sdk_dir = "wasi-sdk-{}.0-{}".format(wasi_sdk_version, arch_os) @@ -144,7 +150,7 @@ def _setup_downloaded_cpp_tools(repository_ctx, platform, wasi_sdk_version): )) # Create tool wrappers pointing to downloaded WASI SDK - _create_wasi_sdk_wrappers(repository_ctx, wasi_sdk_dir) + _create_wasi_sdk_wrappers(repository_ctx, wasi_sdk_dir, platform) # Set up sysroot symlink for the downloaded WASI SDK _setup_downloaded_sysroot(repository_ctx) @@ -176,7 +182,7 @@ def _get_wasi_sdk_url(platform, version): "linux_arm64": "arm64-linux", "darwin_amd64": "x86_64-macos", "darwin_arm64": "arm64-macos", - "windows_amd64": "x86_64-mingw", + "windows_amd64": "x86_64-windows", } arch_os = platform_map.get(platform, "x86_64-linux") filename = "wasi-sdk-{}.0-{}.tar.gz".format(version, arch_os) @@ -187,14 +193,14 @@ def _get_wasi_sdk_url(platform, version): "linux_arm64": "linux", "darwin_amd64": "macos", "darwin_arm64": "macos", - "windows_amd64": "mingw", + "windows_amd64": "windows", } os_name = platform_map.get(platform, "linux") filename = "wasi-sdk-{}-{}.tar.gz".format(version, os_name) return base_url.format(version) + "/" + filename -def _create_wasi_sdk_wrappers(repository_ctx, wasi_sdk_dir): +def _create_wasi_sdk_wrappers(repository_ctx, wasi_sdk_dir, platform): """Create Bazel-native tool configurations for WASI SDK tools""" # Get absolute path to the repository root @@ -212,9 +218,11 @@ def _create_wasi_sdk_wrappers(repository_ctx, wasi_sdk_dir): repository_ctx.file("wasi_config.txt", "\n".join(wasi_config)) # Create direct symlinks to WASI SDK binaries (Bazel-native approach) - clang_path = "{}/bin/clang".format(repo_root) - clang_cpp_path = "{}/bin/clang++".format(repo_root) - llvm_ar_path = "{}/bin/llvm-ar".format(repo_root) + # Windows uses .exe extension for executables + exe_suffix = ".exe" if platform == "windows_amd64" else "" + clang_path = "{}/bin/clang{}".format(repo_root, exe_suffix) + clang_cpp_path = "{}/bin/clang++{}".format(repo_root, exe_suffix) + llvm_ar_path = "{}/bin/llvm-ar{}".format(repo_root, exe_suffix) if repository_ctx.path(clang_path).exists: repository_ctx.symlink(clang_path, "clang") diff --git a/toolchains/jco_toolchain.bzl b/toolchains/jco_toolchain.bzl index cd7363f0..e6a9639b 100644 --- a/toolchains/jco_toolchain.bzl +++ b/toolchains/jco_toolchain.bzl @@ -66,9 +66,15 @@ def _detect_host_platform(repository_ctx): os_name = repository_ctx.os.name.lower() arch = repository_ctx.os.arch.lower() - if os_name == "mac os x": + # Normalize platform names for cross-platform compatibility + if "mac" in os_name or "darwin" in os_name: os_name = "darwin" + elif "windows" in os_name: + os_name = "windows" + elif "linux" in os_name: + os_name = "linux" + # Normalize architecture names if arch == "x86_64": arch = "amd64" elif arch == "aarch64": diff --git a/toolchains/monitoring.bzl b/toolchains/monitoring.bzl index 9f150e50..3ad06141 100644 --- a/toolchains/monitoring.bzl +++ b/toolchains/monitoring.bzl @@ -24,8 +24,15 @@ def _detect_platform_simple(ctx): os_name = ctx.os.name.lower() arch = ctx.os.arch.lower() - if os_name == "mac os x": + # Normalize platform names for cross-platform compatibility + if "mac" in os_name or "darwin" in os_name: os_name = "darwin" + elif "windows" in os_name: + os_name = "windows" + elif "linux" in os_name: + os_name = "linux" + + # Normalize architecture names if arch == "x86_64": arch = "amd64" elif arch == "aarch64": diff --git a/toolchains/symmetric_wit_bindgen_toolchain.bzl b/toolchains/symmetric_wit_bindgen_toolchain.bzl index 4d4f2547..8e2f214d 100644 --- a/toolchains/symmetric_wit_bindgen_toolchain.bzl +++ b/toolchains/symmetric_wit_bindgen_toolchain.bzl @@ -8,9 +8,15 @@ def _detect_host_platform(repository_ctx): os_name = repository_ctx.os.name.lower() arch = repository_ctx.os.arch.lower() - if os_name == "mac os x": + # Normalize platform names for cross-platform compatibility + if "mac" in os_name or "darwin" in os_name: os_name = "darwin" + elif "windows" in os_name: + os_name = "windows" + elif "linux" in os_name: + os_name = "linux" + # Normalize architecture names if arch == "x86_64": arch = "amd64" elif arch == "aarch64": diff --git a/toolchains/tinygo_toolchain.bzl b/toolchains/tinygo_toolchain.bzl index 76411a66..99ce24b0 100644 --- a/toolchains/tinygo_toolchain.bzl +++ b/toolchains/tinygo_toolchain.bzl @@ -32,7 +32,7 @@ def _detect_host_platform(repository_ctx): def _download_go(repository_ctx, version, platform): """Download hermetic Go SDK for TinyGo to use""" - go_version = "1.25.0" # Updated for TinyGo 0.39.0 support + go_version = "1.25.3" # Latest stable Go version (1.25.0 doesn't exist) # Map platform to Go's naming convention go_platform_map = { @@ -46,7 +46,9 @@ def _download_go(repository_ctx, version, platform): if not go_platform: fail("Unsupported platform for Go SDK: {}".format(platform)) - go_url = "https://go.dev/dl/go{}.{}.tar.gz".format(go_version, go_platform) + # Windows uses .zip, others use .tar.gz + go_extension = ".zip" if platform == "windows_amd64" else ".tar.gz" + go_url = "https://go.dev/dl/go{}.{}{}".format(go_version, go_platform, go_extension) print("Downloading Go {} for TinyGo from: {}".format(go_version, go_url)) @@ -57,8 +59,9 @@ def _download_go(repository_ctx, version, platform): stripPrefix = "go", ) - # Verify Go installation - go_binary = repository_ctx.path("go_sdk/bin/go") + # Verify Go installation (use .exe on Windows) + go_binary_name = "go.exe" if platform == "windows_amd64" else "go" + go_binary = repository_ctx.path("go_sdk/bin/{}".format(go_binary_name)) if not go_binary.exists: fail("Go binary not found after download: {}".format(go_binary)) @@ -98,8 +101,9 @@ def _download_binaryen(repository_ctx, platform): stripPrefix = "binaryen-version_{}".format(binaryen_version), ) - # Verify wasm-opt installation - wasm_opt_binary = repository_ctx.path("binaryen/bin/wasm-opt") + # Verify wasm-opt installation (use .exe on Windows) + wasm_opt_binary_name = "wasm-opt.exe" if platform == "windows_amd64" else "wasm-opt" + wasm_opt_binary = repository_ctx.path("binaryen/bin/{}".format(wasm_opt_binary_name)) if not wasm_opt_binary.exists: fail("wasm-opt binary not found after download: {}".format(wasm_opt_binary)) @@ -110,10 +114,12 @@ def _download_binaryen(repository_ctx, platform): def _download_tinygo(repository_ctx, version, platform): """Download TinyGo release for the specified platform and version""" - # TinyGo release URL pattern - tinygo_url = "https://github.com/tinygo-org/tinygo/releases/download/v{version}/tinygo{version}.{platform}.tar.gz".format( + # TinyGo release URL pattern (use .zip for Windows, .tar.gz for others) + extension = ".zip" if platform == "windows_amd64" else ".tar.gz" + tinygo_url = "https://github.com/tinygo-org/tinygo/releases/download/v{version}/tinygo{version}.{platform}{extension}".format( version = version, platform = _get_tinygo_platform_suffix(platform), + extension = extension, ) print("Downloading TinyGo {} for {}".format(version, platform)) @@ -125,8 +131,9 @@ def _download_tinygo(repository_ctx, version, platform): stripPrefix = "tinygo", ) - # Verify installation - tinygo_binary = repository_ctx.path("tinygo/bin/tinygo") + # Verify installation (use .exe on Windows) + tinygo_binary_name = "tinygo.exe" if platform == "windows_amd64" else "tinygo" + tinygo_binary = repository_ctx.path("tinygo/bin/{}".format(tinygo_binary_name)) if not tinygo_binary.exists: fail("TinyGo binary not found after download: {}".format(tinygo_binary)) @@ -301,14 +308,14 @@ filegroup( # Go binary for TinyGo alias( name = "go_binary", - actual = "go_sdk/bin/go", + actual = "{go_binary_name}", visibility = ["//visibility:public"], ) # wasm-opt binary from Binaryen alias( name = "wasm_opt_binary", - actual = "binaryen/bin/wasm-opt", + actual = "{wasm_opt_binary_name}", visibility = ["//visibility:public"], ) @@ -353,7 +360,9 @@ toolchain( toolchain_type = "@rules_wasm_component//toolchains:tinygo_toolchain_type", ) """.format( - tinygo_binary_name = "tinygo/bin/tinygo", + tinygo_binary_name = "tinygo/bin/tinygo.exe" if platform == "windows_amd64" else "tinygo/bin/tinygo", + go_binary_name = "go_sdk/bin/go.exe" if platform == "windows_amd64" else "go_sdk/bin/go", + wasm_opt_binary_name = "binaryen/bin/wasm-opt.exe" if platform == "windows_amd64" else "binaryen/bin/wasm-opt", os = "osx" if "darwin" in platform else ("windows" if "windows" in platform else "linux"), cpu = "arm64" if "arm64" in platform else "x86_64", )) diff --git a/toolchains/wasi_sdk_toolchain.bzl b/toolchains/wasi_sdk_toolchain.bzl index 00a55823..a8be016c 100644 --- a/toolchains/wasi_sdk_toolchain.bzl +++ b/toolchains/wasi_sdk_toolchain.bzl @@ -89,9 +89,15 @@ def _detect_host_platform(repository_ctx): os_name = repository_ctx.os.name.lower() arch = repository_ctx.os.arch.lower() - if os_name == "mac os x": + # Normalize platform names for cross-platform compatibility + if "mac" in os_name or "darwin" in os_name: os_name = "darwin" + elif "windows" in os_name: + os_name = "windows" + elif "linux" in os_name: + os_name = "linux" + # Normalize architecture names if arch == "x86_64": arch = "amd64" elif arch == "aarch64": @@ -128,7 +134,7 @@ def _setup_downloaded_wasi_sdk(repository_ctx): "darwin_arm64": "arm64-macos", "linux_amd64": "x86_64-linux", "linux_arm64": "arm64-linux", - "windows_amd64": "x86_64-mingw", + "windows_amd64": "x86_64-windows", } if platform not in platform_mapping: diff --git a/toolchains/wasm_toolchain.bzl b/toolchains/wasm_toolchain.bzl index d0f2a898..781a29a9 100644 --- a/toolchains/wasm_toolchain.bzl +++ b/toolchains/wasm_toolchain.bzl @@ -103,9 +103,15 @@ def _detect_host_platform(repository_ctx): os_name = repository_ctx.os.name.lower() arch = repository_ctx.os.arch.lower() - if os_name == "mac os x": + # Normalize platform names for cross-platform compatibility + if "mac" in os_name or "darwin" in os_name: os_name = "darwin" + elif "windows" in os_name: + os_name = "windows" + elif "linux" in os_name: + os_name = "linux" + # Normalize architecture names if arch == "x86_64": arch = "amd64" elif arch == "aarch64": @@ -134,21 +140,14 @@ def _wasm_toolchain_repository_impl(repository_ctx): for warning in compatibility_warnings: print("Warning: {}".format(warning)) - # All strategies now use modernized approach with git_repository rules - # This eliminates ctx.execute() calls for git clone and cargo build operations + # Use download strategy for fast, hermetic builds with prebuilt binaries if strategy == "download": - _setup_downloaded_tools(repository_ctx) # Use simple method for stability - elif strategy == "build": - _setup_built_tools_enhanced(repository_ctx) # Modernized: uses git_repository - elif strategy == "bazel": - _setup_bazel_native_tools(repository_ctx) - elif strategy == "hybrid": - _setup_hybrid_tools_enhanced(repository_ctx) # Modernized: most robust approach + _setup_downloaded_tools(repository_ctx) else: fail(format_diagnostic_error( "E001", "Unknown strategy: {}".format(strategy), - "Must be 'download', 'build', 'bazel', or 'hybrid'", + "Must be 'download' (other strategies removed in dependency management cleanup)", )) # Create BUILD files for all strategies @@ -481,11 +480,18 @@ def _download_wasm_tools(repository_ctx): platform_info.url_suffix, ) - # Download and extract tarball, letting Bazel handle the structure + # Determine stripPrefix based on archive format + # Windows uses .zip, others use .tar.gz + if platform_info.url_suffix.endswith(".zip"): + strip_prefix = "wasm-tools-{}-{}".format(version, platform_info.url_suffix.replace(".zip", "")) + else: + strip_prefix = "wasm-tools-{}-{}".format(version, platform_info.url_suffix.replace(".tar.gz", "")) + + # Download and extract archive, letting Bazel handle the structure repository_ctx.download_and_extract( url = wasm_tools_url, sha256 = platform_info.sha256, - stripPrefix = "wasm-tools-{}-{}".format(version, platform_info.url_suffix.replace(".tar.gz", "")), + stripPrefix = strip_prefix, ) def _download_wac(repository_ctx): @@ -529,7 +535,7 @@ def _download_wit_bindgen(repository_ctx): repository_ctx.download_and_extract( url = wit_bindgen_url, sha256 = tool_info["sha256"], - stripPrefix = "wit-bindgen-{}-{}".format(wit_bindgen_version, tool_info["url_suffix"].replace(".tar.gz", "")), + stripPrefix = "wit-bindgen-{}-{}".format(wit_bindgen_version, tool_info["url_suffix"].replace(".tar.gz", "").replace(".zip", "")), ) def _download_wrpc(repository_ctx): @@ -550,79 +556,20 @@ exit 1 """, executable = True) def _download_wasmsign2(repository_ctx): - """Setup wasmsign2 placeholder - use bazel strategy for full functionality""" + """Setup wasmsign2 placeholder - not available in prebuilt downloads""" print("Setting up wasmsign2 placeholder for download strategy") - # Create a stub that explains the limitation and recommends the bazel strategy + # Create a stub explaining wasmsign2 is not included in prebuilt downloads repository_ctx.file("wasmsign2", """#!/bin/bash -# wasmsign2 stub for download strategy -# The download strategy cannot build Rust binaries from source +# wasmsign2 is not included in prebuilt binary downloads echo "wasmsign2: Not available in download strategy" >&2 -echo "For signing functionality, use strategy = 'bazel' in your MODULE.bazel:" >&2 -echo " wasm_toolchain.register(strategy = 'bazel')" >&2 -echo "This enables Bazel-native rust_binary builds with full signing support." >&2 +echo "WebAssembly component signing requires building wasmsign2 from source" >&2 +echo "For signing functionality, use @wasmsign2_src from git_repository" >&2 exit 1 """, executable = True) - print("Created wasmsign2 stub - use bazel strategy for full signing functionality") - -def _setup_bazel_native_tools(repository_ctx): - """Setup tools using Bazel-native rust_binary builds instead of cargo""" - - print("Setting up Bazel-native toolchain using rust_binary rules") - - # For Bazel-native strategy, we don't create any local binaries at all. - # Instead, we copy the BUILD files that use rust_binary rules and git_repository sources. - # This completely bypasses cargo and uses only Bazel + rules_rust. - - # Copy the wasm-tools BUILD file that uses rust_binary - repository_ctx.template( - "BUILD.wasm_tools", - Label("//toolchains:BUILD.wasm_tools_bazel"), - ) - - # Copy the wizer BUILD file that uses rust_binary - repository_ctx.template( - "BUILD.wizer", - Label("//toolchains:BUILD.wizer_bazel"), - ) - - # Create placeholder binaries for tools not yet implemented with rust_binary - # These will be updated as we add more Bazel-native builds - - # Create placeholder wac (will be updated to rust_binary later) - repository_ctx.file("wac", """#!/bin/bash -echo "wac: Bazel-native rust_binary not yet implemented" -echo "Using placeholder - switch to 'download' strategy in MODULE.bazel for full functionality" -echo "To use wac, switch to 'download' strategy in MODULE.bazel" -exit 1 -""", executable = True) - - # Create placeholder wit-bindgen (will be updated to rust_binary later) - repository_ctx.file("wit-bindgen", """#!/bin/bash -echo "wit-bindgen: Bazel-native rust_binary not yet implemented" -echo "Using download strategy fallback" -# For now, fail gracefully and suggest alternative -echo "To use wit-bindgen, switch to 'download' strategy in MODULE.bazel" -exit 1 -""", executable = True) - - # Create placeholder wrpc (complex build, keep as placeholder) - repository_ctx.file("wrpc", """#!/bin/bash -echo "wrpc: placeholder - complex dependencies" -echo "Use system wrpc or download strategy" -exit 1 -""", executable = True) - - # Create placeholder wasmsign2 (not critical for core functionality) - repository_ctx.file("wasmsign2", """#!/bin/bash -echo "wasmsign2: not critical for WebAssembly component compilation" -echo "Basic functionality available without signing" -exit 0 -""", executable = True) - - print("✅ Bazel-native strategy configured - using rust_binary rules for core tools") + print("Created wasmsign2 stub - not included in prebuilt downloads") def _get_platform_suffix(platform): """Get platform suffix for download URLs""" @@ -639,6 +586,7 @@ def _create_build_files(repository_ctx): """Create BUILD files for the toolchain""" strategy = repository_ctx.attr.strategy + platform = _detect_host_platform(repository_ctx) if strategy == "build": # For build strategy, reference external git repositories directly @@ -689,70 +637,6 @@ wasm_tools_toolchain( wasmsign2 = ":wasmsign2_binary", ) -# Toolchain registration -toolchain( - name = "wasm_tools_toolchain", - toolchain = ":wasm_tools_impl", - toolchain_type = "@rules_wasm_component//toolchains:wasm_tools_toolchain_type", - exec_compatible_with = [], - target_compatible_with = [], -) -""" - elif strategy == "bazel": - # For Bazel-native strategy, reference rust_binary builds from git repositories - build_content = """ -load("@rules_wasm_component//toolchains:wasm_toolchain.bzl", "wasm_tools_toolchain") - -package(default_visibility = ["//visibility:public"]) - -# File targets for executables - use Bazel-native rust_binary builds -alias( - name = "wasm_tools_binary", - actual = "@wasm_tools_src//:wasm_tools_bazel", - visibility = ["//visibility:public"], -) - -alias( - name = "wizer_binary", - actual = "@wizer_src//:wizer_bazel", - visibility = ["//visibility:public"], -) - -# Remaining tools use local fallback files until rust_binary implementations added -filegroup( - name = "wac_binary", - srcs = ["wac"], - visibility = ["//visibility:public"], -) - -filegroup( - name = "wit_bindgen_binary", - srcs = ["wit-bindgen"], - visibility = ["//visibility:public"], -) - -filegroup( - name = "wrpc_binary", - srcs = ["wrpc"], - visibility = ["//visibility:public"], -) - -alias( - name = "wasmsign2_binary", - actual = "@wasmsign2_src//:wasmsign2_bazel", - visibility = ["//visibility:public"], -) - -# Toolchain implementation -wasm_tools_toolchain( - name = "wasm_tools_impl", - wasm_tools = ":wasm_tools_binary", - wac = ":wac_binary", - wit_bindgen = ":wit_bindgen_binary", - wrpc = ":wrpc_binary", - wasmsign2 = ":wasmsign2_binary", -) - # Toolchain registration toolchain( name = "wasm_tools_toolchain", @@ -763,7 +647,9 @@ toolchain( ) """ else: - # For other strategies (download, system, hybrid), use local files + # For download strategy, use local downloaded files + # Windows binaries need .exe extension + exe_suffix = ".exe" if platform == "windows_amd64" else "" build_content = """ load("@rules_wasm_component//toolchains:wasm_toolchain.bzl", "wasm_tools_toolchain") @@ -772,31 +658,31 @@ package(default_visibility = ["//visibility:public"]) # File targets for executables filegroup( name = "wasm_tools_binary", - srcs = ["wasm-tools"], + srcs = ["{wasm_tools_bin}"], visibility = ["//visibility:public"], ) filegroup( name = "wac_binary", - srcs = ["wac"], + srcs = ["{wac_bin}"], visibility = ["//visibility:public"], ) filegroup( name = "wit_bindgen_binary", - srcs = ["wit-bindgen"], + srcs = ["{wit_bindgen_bin}"], visibility = ["//visibility:public"], ) filegroup( name = "wrpc_binary", - srcs = ["wrpc"], + srcs = ["{wrpc_bin}"], visibility = ["//visibility:public"], ) filegroup( name = "wasmsign2_binary", - srcs = ["wasmsign2"], + srcs = ["{wasmsign2_bin}"], visibility = ["//visibility:public"], ) @@ -823,7 +709,13 @@ toolchain( # Use the direct target name for explicit, clear toolchain registration # Note: Other aliases removed to prevent dependency cycles # Use the _binary targets directly: wasm_tools_binary, wac_binary, wit_bindgen_binary -""" +""".format( + wasm_tools_bin = "wasm-tools{}".format(exe_suffix), + wac_bin = "wac{}".format(exe_suffix), + wit_bindgen_bin = "wit-bindgen{}".format(exe_suffix), + wrpc_bin = "wrpc{}".format(exe_suffix), + wasmsign2_bin = "wasmsign2{}".format(exe_suffix), + ) # Create main BUILD file with strategy-specific content repository_ctx.file("BUILD.bazel", build_content) @@ -832,9 +724,9 @@ wasm_toolchain_repository = repository_rule( implementation = _wasm_toolchain_repository_impl, attrs = { "strategy": attr.string( - doc = "Tool acquisition strategy: 'download', 'build', 'bazel', or 'hybrid'. All strategies now modernized to eliminate ctx.execute() calls.", - default = "hybrid", # Hybrid is most robust with git_repository approach - values = ["download", "build", "bazel", "hybrid"], + doc = "Tool acquisition strategy: 'download' only (other strategies removed in dependency management cleanup)", + default = "download", + values = ["download"], ), "version": attr.string( doc = "Version to use (for download/build strategies)", diff --git a/toolchains/wasmtime_toolchain.bzl b/toolchains/wasmtime_toolchain.bzl index 1b0bd75c..c2231b60 100644 --- a/toolchains/wasmtime_toolchain.bzl +++ b/toolchains/wasmtime_toolchain.bzl @@ -30,9 +30,15 @@ def _detect_host_platform(repository_ctx): os_name = repository_ctx.os.name.lower() arch = repository_ctx.os.arch.lower() - if os_name == "mac os x": + # Normalize platform names for cross-platform compatibility + if "mac" in os_name or "darwin" in os_name: os_name = "darwin" + elif "windows" in os_name: + os_name = "windows" + elif "linux" in os_name: + os_name = "linux" + # Normalize architecture names if arch == "x86_64": arch = "amd64" elif arch == "aarch64": diff --git a/toolchains/wkg_toolchain.bzl b/toolchains/wkg_toolchain.bzl index 0a049e06..1616cd78 100644 --- a/toolchains/wkg_toolchain.bzl +++ b/toolchains/wkg_toolchain.bzl @@ -90,7 +90,7 @@ def _wkg_toolchain_repository_impl(ctx): "darwin_arm64": "0048768e7046a5df7d8512c4c87c56cbf66fc12fa8805e8fe967ef2118230f6f", "linux_amd64": "444e568ce8c60364b9887301ab6862ef382ac661a4b46c2f0d2f0f254bd4e9d4", "linux_arm64": "ebd6ffba1467c16dba83058a38e894496247fc58112efd87d2673b40fc406652", - "windows_amd64": "0019dfc4b32d63c1392aa264aed2253c1e0c2fb09216f8e2cc269bbfb8bb49b5", + "windows_amd64": "930adea31da8d2a572860304c00903f7683966e722591819e99e26787e58416b", }, } diff --git a/wasm/extensions.bzl b/wasm/extensions.bzl index 5fbcb044..1623929f 100644 --- a/wasm/extensions.bzl +++ b/wasm/extensions.bzl @@ -41,7 +41,7 @@ def _wasm_toolchain_extension_impl(module_ctx): if not registrations: wasm_toolchain_repository( name = "wasm_tools_toolchains", - strategy = "hybrid", + strategy = "download", version = "1.235.0", git_commit = "main", wasm_tools_commit = "", @@ -65,9 +65,9 @@ wasm_toolchain = module_extension( default = "wasm_tools", ), "strategy": attr.string( - doc = "Tool acquisition strategy: 'download', 'build', 'bazel', or 'hybrid'", - default = "hybrid", - values = ["download", "build", "bazel", "hybrid"], + doc = "Tool acquisition strategy: 'download' (prebuilt binaries from GitHub releases)", + default = "download", + values = ["download"], ), "version": attr.string( doc = "Version to use (for download/build strategies)", @@ -188,7 +188,7 @@ def _wkg_extension_impl(module_ctx): if not registrations: wkg_toolchain_repository( name = "wkg_toolchain", - strategy = "source", + strategy = "download", version = "0.11.0", ) @@ -203,9 +203,9 @@ wkg = module_extension( default = "wkg", ), "strategy": attr.string( - doc = "Tool acquisition strategy: 'download', 'build', or 'source'", - default = "source", - values = ["download", "build", "source"], + doc = "Tool acquisition strategy: 'download' (prebuilt binaries from GitHub releases)", + default = "download", + values = ["download"], ), "version": attr.string( doc = "Version to use (for download/build strategies)", @@ -390,7 +390,7 @@ def _wizer_extension_impl(module_ctx): wizer_toolchain_repository( name = "wizer_toolchain", version = "9.0.0", - strategy = "source", + strategy = "download", ) # Module extension for Wizer WebAssembly pre-initialization @@ -408,9 +408,9 @@ wizer = module_extension( default = "9.0.0", ), "strategy": attr.string( - doc = "Installation strategy: 'build' (build from source), 'cargo' (install via cargo), 'source' (git repository), or 'download' (download prebuilt binary)", - default = "source", - values = ["build", "cargo", "source", "download"], + doc = "Installation strategy: 'download' (download prebuilt binary from GitHub releases)", + default = "download", + values = ["download"], ), }, ),