Skip to content

Commit 1795b7a

Browse files
committed
fix(windows): correct wasm-tools download URL for Windows
Windows releases of wasm-tools use .zip format, not .tar.gz format. This was causing 404 errors when trying to download wasm-tools on Windows. Changes: - Update wasm-tools.json: Change url_suffix from .tar.gz to .zip for all Windows entries - Update checksums to match actual Windows .zip files: - v1.235.0: ecf9f2064c2096df134c39c2c97af2c025e974cc32e3c76eb2609156c1690a74 (unchanged) - v1.239.0: 039b1eaa170563f762355a23c5ee709790199433e35e5364008521523e9e3398 (updated) - v1.240.0: 81f012832e80fe09d384d86bb961d4779f6372a35fa965cc64efe318001ab27e (updated) - Update _download_wasm_tools() to handle both .zip and .tar.gz archives Fixes: bytecodealliance/wasm-tools Windows download errors in BCR CI
1 parent e7a277e commit 1795b7a

File tree

3 files changed

+40
-23
lines changed

3 files changed

+40
-23
lines changed

checksums/registry.bzl

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,27 @@
11
"""Centralized checksum registry API for WebAssembly toolchain
22
3-
This module provides a unified API for accessing tool checksums. Checksum data is
4-
embedded in this file and kept synchronized with checksums/tools/*.json files, which
5-
serve as the canonical source for checksum updater tools and external documentation.
6-
7-
The embedded approach is used because Bazel rules don't have built-in JSON parsing
8-
capabilities, making direct JSON loading impractical in the build system.
3+
This module provides a unified API for accessing tool checksums from JSON files.
94
"""
105

6+
def _load_tool_checksums_from_json(repository_ctx, tool_name):
7+
"""Load checksums for a tool from JSON file
8+
9+
Args:
10+
repository_ctx: Repository context for file operations
11+
tool_name: Name of the tool (e.g., 'wasm-tools', 'wit-bindgen')
12+
13+
Returns:
14+
Dict: Tool data from JSON file, or None if file not found
15+
"""
16+
json_file = repository_ctx.path(Label("@rules_wasm_component//checksums/tools:{}.json".format(tool_name)))
17+
if not json_file.exists:
18+
return None
19+
20+
content = repository_ctx.read(json_file)
21+
return json.decode(content)
22+
1123
def _load_tool_checksums(tool_name):
12-
"""Load checksums for a tool from embedded registry data
24+
"""Load checksums for a tool from embedded fallback data
1325
1426
Args:
1527
tool_name: Name of the tool (e.g., 'wasm-tools', 'wit-bindgen')
@@ -18,10 +30,8 @@ def _load_tool_checksums(tool_name):
1830
Dict: Tool data from embedded registry, or empty dict if not found
1931
2032
Note:
21-
This function uses embedded data rather than JSON file loading because
22-
Bazel rules don't have built-in JSON parsing capabilities. The embedded
23-
data is kept synchronized with checksums/tools/*.json files, which serve
24-
as the canonical source for checksum updater tools and documentation.
33+
This is fallback data for non-repository contexts.
34+
Use _load_tool_checksums_from_json() in repository rules for up-to-date data.
2535
"""
2636

2737
tool_data = _get_fallback_checksums(tool_name)
@@ -61,7 +71,7 @@ def _get_fallback_checksums(tool_name):
6171
},
6272
"windows_amd64": {
6373
"sha256": "ecf9f2064c2096df134c39c2c97af2c025e974cc32e3c76eb2609156c1690a74",
64-
"url_suffix": "x86_64-windows.tar.gz",
74+
"url_suffix": "x86_64-windows.zip",
6575
},
6676
},
6777
},
@@ -106,8 +116,8 @@ def _get_fallback_checksums(tool_name):
106116
"url_suffix": "aarch64-linux.tar.gz",
107117
},
108118
"windows_amd64": {
109-
"sha256": "0019dfc4b32d63c1392aa264aed2253c1e0c2fb09216f8e2cc269bbfb8bb49b5",
110-
"url_suffix": "x86_64-windows.tar.gz",
119+
"sha256": "039b1eaa170563f762355a23c5ee709790199433e35e5364008521523e9e3398",
120+
"url_suffix": "x86_64-windows.zip",
111121
},
112122
},
113123
},
@@ -131,8 +141,8 @@ def _get_fallback_checksums(tool_name):
131141
"url_suffix": "aarch64-linux.tar.gz",
132142
},
133143
"windows_amd64": {
134-
"sha256": "0019dfc4b32d63c1392aa264aed2253c1e0c2fb09216f8e2cc269bbfb8bb49b5",
135-
"url_suffix": "x86_64-windows.tar.gz",
144+
"sha256": "81f012832e80fe09d384d86bb961d4779f6372a35fa965cc64efe318001ab27e",
145+
"url_suffix": "x86_64-windows.zip",
136146
},
137147
},
138148
},

checksums/tools/wasm-tools.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"platforms": {
1717
"windows_amd64": {
1818
"sha256": "ecf9f2064c2096df134c39c2c97af2c025e974cc32e3c76eb2609156c1690a74",
19-
"url_suffix": "x86_64-windows.tar.gz"
19+
"url_suffix": "x86_64-windows.zip"
2020
},
2121
"linux_arm64": {
2222
"sha256": "384ca3691502116fb6f48951ad42bd0f01f9bf799111014913ce15f4f4dde5a2",
@@ -77,8 +77,8 @@
7777
"url_suffix": "aarch64-linux.tar.gz"
7878
},
7979
"windows_amd64": {
80-
"sha256": "0019dfc4b32d63c1392aa264aed2253c1e0c2fb09216f8e2cc269bbfb8bb49b5",
81-
"url_suffix": "x86_64-windows.tar.gz"
80+
"sha256": "039b1eaa170563f762355a23c5ee709790199433e35e5364008521523e9e3398",
81+
"url_suffix": "x86_64-windows.zip"
8282
}
8383
}
8484
},
@@ -102,8 +102,8 @@
102102
"url_suffix": "aarch64-linux.tar.gz"
103103
},
104104
"windows_amd64": {
105-
"sha256": "0019dfc4b32d63c1392aa264aed2253c1e0c2fb09216f8e2cc269bbfb8bb49b5",
106-
"url_suffix": "x86_64-windows.tar.gz"
105+
"sha256": "81f012832e80fe09d384d86bb961d4779f6372a35fa965cc64efe318001ab27e",
106+
"url_suffix": "x86_64-windows.zip"
107107
}
108108
}
109109
}

toolchains/wasm_toolchain.bzl

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -487,11 +487,18 @@ def _download_wasm_tools(repository_ctx):
487487
platform_info.url_suffix,
488488
)
489489

490-
# Download and extract tarball, letting Bazel handle the structure
490+
# Determine stripPrefix based on archive format
491+
# Windows uses .zip, others use .tar.gz
492+
if platform_info.url_suffix.endswith(".zip"):
493+
strip_prefix = "wasm-tools-{}-{}".format(version, platform_info.url_suffix.replace(".zip", ""))
494+
else:
495+
strip_prefix = "wasm-tools-{}-{}".format(version, platform_info.url_suffix.replace(".tar.gz", ""))
496+
497+
# Download and extract archive, letting Bazel handle the structure
491498
repository_ctx.download_and_extract(
492499
url = wasm_tools_url,
493500
sha256 = platform_info.sha256,
494-
stripPrefix = "wasm-tools-{}-{}".format(version, platform_info.url_suffix.replace(".tar.gz", "")),
501+
stripPrefix = strip_prefix,
495502
)
496503

497504
def _download_wac(repository_ctx):

0 commit comments

Comments
 (0)