Skip to content

Commit f9fbdab

Browse files
committed
fix: correct archive prefix for download toolchain strategy
Fix toolchain download failures by using correct archive prefix that includes the platform suffix. The archives have structure like: wasm-tools-1.235.0-aarch64-macos/... But we were using stripPrefix "wasm-tools-1.235.0" which doesn't match. Changes: - Update stripPrefix for wasm-tools to include platform suffix - Update stripPrefix for wac to include platform suffix - Update stripPrefix for wit-bindgen to include platform suffix Example fix for macOS ARM64: Before: stripPrefix = "wasm-tools-1.235.0" After: stripPrefix = "wasm-tools-1.235.0-aarch64-macos" This resolves download extraction errors when using the download toolchain strategy instead of system tools.
1 parent c3edb61 commit f9fbdab

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

toolchains/wasm_toolchain.bzl

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,38 +119,39 @@ def _setup_downloaded_tools(repository_ctx):
119119

120120
# Download wasm-tools
121121
wasm_tools_url = repository_ctx.attr.wasm_tools_url
122+
platform_suffix = _get_platform_suffix(platform)
122123
if not wasm_tools_url:
123124
wasm_tools_url = "https://github.com/bytecodealliance/wasm-tools/releases/download/v{}/wasm-tools-{}-{}.tar.gz".format(
124-
version, version, _get_platform_suffix(platform)
125+
version, version, platform_suffix
125126
)
126127

127128
repository_ctx.download_and_extract(
128129
url = wasm_tools_url,
129-
stripPrefix = "wasm-tools-{}".format(version),
130+
stripPrefix = "wasm-tools-{}-{}".format(version, platform_suffix),
130131
)
131132

132133
# Download wac
133134
wac_url = repository_ctx.attr.wac_url
134135
if not wac_url:
135136
wac_url = "https://github.com/bytecodealliance/wac/releases/download/v{}/wac-{}-{}.tar.gz".format(
136-
version, version, _get_platform_suffix(platform)
137+
version, version, platform_suffix
137138
)
138139

139140
repository_ctx.download_and_extract(
140141
url = wac_url,
141-
stripPrefix = "wac-{}".format(version),
142+
stripPrefix = "wac-{}-{}".format(version, platform_suffix),
142143
)
143144

144145
# Download wit-bindgen
145146
wit_bindgen_url = repository_ctx.attr.wit_bindgen_url
146147
if not wit_bindgen_url:
147148
wit_bindgen_url = "https://github.com/bytecodealliance/wit-bindgen/releases/download/v{}/wit-bindgen-{}-{}.tar.gz".format(
148-
version, version, _get_platform_suffix(platform)
149+
version, version, platform_suffix
149150
)
150151

151152
repository_ctx.download_and_extract(
152153
url = wit_bindgen_url,
153-
stripPrefix = "wit-bindgen-{}".format(version),
154+
stripPrefix = "wit-bindgen-{}-{}".format(version, platform_suffix),
154155
)
155156

156157
def _setup_built_tools(repository_ctx):

0 commit comments

Comments
 (0)