Skip to content

Commit 1b9b093

Browse files
committed
fix(wit): correct wasi 0.2.3 dependencies and add 0.2.8
Fix incorrect WASI 0.2.3 WIT dependency definitions: - wasi:http@0.2.3: add missing deps on cli and random, fix interfaces - wasi:clocks@0.2.3: add missing dep on wasi:io (monotonic-clock uses poll) - wasi:sockets@0.2.3: add missing dep on wasi:clocks Add WASI 0.2.8 (latest stable) with correct dependency chains: - wasi:io@0.2.8 (base, no deps) - wasi:cli@0.2.8 (deps: io) - wasi:clocks@0.2.8 (deps: io) - wasi:filesystem@0.2.8 (deps: io, clocks) - wasi:sockets@0.2.8 (deps: io, clocks) - wasi:random@0.2.8 (no deps) - wasi:http@0.2.8 (deps: io, clocks, cli, random) Register new 0.2.8 repositories in MODULE.bazel use_repo().
1 parent f034afb commit 1b9b093

File tree

2 files changed

+206
-6
lines changed

2 files changed

+206
-6
lines changed

MODULE.bazel

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,36 @@ register_toolchains("@go_toolchains//:all")
8282
# WASI WIT interface definitions
8383
wasi_wit_ext = use_extension("//wasm:extensions.bzl", "wasi_wit")
8484
wasi_wit_ext.init()
85-
use_repo(wasi_wit_ext, "wasi_cli", "wasi_cli_v020", "wasi_clocks", "wasi_clocks_v020", "wasi_filesystem", "wasi_filesystem_v020", "wasi_http", "wasi_io", "wasi_io_v020", "wasi_nn", "wasi_nn_v0_2_0_rc_2024_06_25", "wasi_nn_v0_2_0_rc_2024_08_19", "wasi_random", "wasi_random_v020", "wasi_sockets", "wasi_sockets_v020") # Complete WASI ecosystem (0.2.3 + 0.2.0 + all NN versions)
85+
use_repo(
86+
wasi_wit_ext,
87+
# WASI 0.2.3 (default)
88+
"wasi_cli",
89+
"wasi_clocks",
90+
"wasi_filesystem",
91+
"wasi_http",
92+
"wasi_io",
93+
"wasi_random",
94+
"wasi_sockets",
95+
# WASI 0.2.0
96+
"wasi_cli_v020",
97+
"wasi_clocks_v020",
98+
"wasi_filesystem_v020",
99+
"wasi_io_v020",
100+
"wasi_random_v020",
101+
"wasi_sockets_v020",
102+
# WASI 0.2.8
103+
"wasi_cli_v028",
104+
"wasi_clocks_v028",
105+
"wasi_filesystem_v028",
106+
"wasi_http_v028",
107+
"wasi_io_v028",
108+
"wasi_random_v028",
109+
"wasi_sockets_v028",
110+
# WASI NN
111+
"wasi_nn",
112+
"wasi_nn_v0_2_0_rc_2024_06_25",
113+
"wasi_nn_v0_2_0_rc_2024_08_19",
114+
)
86115

87116
# WebAssembly toolchains
88117
wasm_toolchain = use_extension("//wasm:extensions.bzl", "wasm_toolchain")

wit/wasi_deps.bzl

Lines changed: 176 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33
This file provides Bazel-native http_archive rules for WASI WIT definitions,
44
following the Bazel-first approach instead of using shell scripts or wit-deps tool.
55
6-
Provides both WASI 0.2.0 (maximum compatibility) and 0.2.3 (latest features).
6+
Provides WASI versions:
7+
- 0.2.0 (maximum compatibility with older toolchains)
8+
- 0.2.3 (default - stable release with versioned dependencies)
9+
- 0.2.8 (latest stable - newest features)
10+
711
See docs-site/src/content/docs/guides/external-wit-dependencies.mdx for usage guide.
812
"""
913

@@ -15,7 +19,7 @@ def wasi_wit_dependencies():
1519
This follows the Bazel-native approach by using http_archive rules
1620
instead of shell scripts or external dependency management tools.
1721
18-
Provides both WASI 0.2.0 and 0.2.3 versions for maximum compatibility.
22+
Provides WASI 0.2.0, 0.2.3, and 0.2.8 versions with correct dependency chains.
1923
"""
2024

2125
# ========================================================================
@@ -189,6 +193,7 @@ wit_library(
189193
)
190194

191195
# WASI Clocks interfaces
196+
# Note: monotonic-clock uses wasi:io/poll@0.2.3 for pollable
192197
http_archive(
193198
name = "wasi_clocks",
194199
urls = ["https://github.com/WebAssembly/wasi-clocks/archive/refs/tags/v0.2.3.tar.gz"],
@@ -202,6 +207,7 @@ wit_library(
202207
srcs = glob(["wit/*.wit"]),
203208
package_name = "wasi:clocks@0.2.3",
204209
interfaces = ["wall-clock", "monotonic-clock"],
210+
deps = ["@wasi_io//:streams"],
205211
visibility = ["//visibility:public"],
206212
)
207213
""",
@@ -228,6 +234,7 @@ wit_library(
228234
)
229235

230236
# WASI Sockets interfaces
237+
# Note: tcp/udp use wasi:io/streams, wasi:io/poll, and wasi:clocks/monotonic-clock
231238
http_archive(
232239
name = "wasi_sockets",
233240
urls = ["https://github.com/WebAssembly/wasi-sockets/archive/refs/tags/v0.2.3.tar.gz"],
@@ -241,7 +248,7 @@ wit_library(
241248
srcs = glob(["wit/*.wit"]),
242249
package_name = "wasi:sockets@0.2.3",
243250
interfaces = ["network", "udp", "tcp", "udp-create-socket", "tcp-create-socket", "instance-network", "ip-name-lookup"],
244-
deps = ["@wasi_io//:streams"],
251+
deps = ["@wasi_io//:streams", "@wasi_clocks//:clocks"],
245252
visibility = ["//visibility:public"],
246253
)
247254
""",
@@ -267,6 +274,10 @@ wit_library(
267274
)
268275

269276
# WASI HTTP interfaces
277+
# Note: wasi:http@0.2.3 has different dependency structure than 0.2.0:
278+
# - Uses @0.2.3 version references for all WASI dependencies
279+
# - proxy world imports cli/stdout, cli/stderr, cli/stdin, random/random
280+
# - types interface uses io/streams, io/error, io/poll, clocks/monotonic-clock
270281
http_archive(
271282
name = "wasi_http",
272283
urls = ["https://github.com/WebAssembly/wasi-http/archive/refs/tags/v0.2.3.tar.gz"],
@@ -279,8 +290,168 @@ wit_library(
279290
name = "http",
280291
srcs = glob(["wit/*.wit"]),
281292
package_name = "wasi:http@0.2.3",
282-
interfaces = ["types", "handler", "outgoing-handler", "proxy"],
283-
deps = ["@wasi_io//:streams", "@wasi_clocks//:clocks"],
293+
interfaces = ["types", "incoming-handler", "outgoing-handler"],
294+
world = "proxy",
295+
deps = [
296+
"@wasi_io//:streams",
297+
"@wasi_clocks//:clocks",
298+
"@wasi_cli//:cli",
299+
"@wasi_random//:random",
300+
],
301+
visibility = ["//visibility:public"],
302+
)
303+
""",
304+
)
305+
306+
# ========================================================================
307+
# WASI 0.2.8 (Latest stable release)
308+
# ========================================================================
309+
310+
# WASI IO interfaces v0.2.8
311+
http_archive(
312+
name = "wasi_io_v028",
313+
urls = ["https://github.com/WebAssembly/wasi-io/archive/refs/tags/v0.2.8.tar.gz"],
314+
sha256 = "5e4c867b06d4e38276e9b80c80ee29dc34943e6b5db678fee8e9f9c249061b61",
315+
strip_prefix = "wasi-io-0.2.8",
316+
build_file_content = """
317+
load("@rules_wasm_component//wit:defs.bzl", "wit_library")
318+
319+
wit_library(
320+
name = "streams",
321+
srcs = glob(["wit/*.wit"]),
322+
package_name = "wasi:io@0.2.8",
323+
interfaces = ["error", "poll", "streams"],
324+
visibility = ["//visibility:public"],
325+
)
326+
""",
327+
)
328+
329+
# WASI CLI interfaces v0.2.8
330+
# Note: stdin/stdout/stderr use wasi:io/streams@0.2.8
331+
http_archive(
332+
name = "wasi_cli_v028",
333+
urls = ["https://github.com/WebAssembly/wasi-cli/archive/refs/tags/v0.2.8.tar.gz"],
334+
sha256 = "2ca56bbbf56ce30edea6aa69a2ebc43bba0138a8fccae641e6ee0902e346ead9",
335+
strip_prefix = "wasi-cli-0.2.8",
336+
build_file_content = """
337+
load("@rules_wasm_component//wit:defs.bzl", "wit_library")
338+
339+
wit_library(
340+
name = "cli",
341+
srcs = glob(["wit/*.wit"]),
342+
package_name = "wasi:cli@0.2.8",
343+
interfaces = ["environment", "exit", "stdin", "stdout", "stderr", "terminal-input", "terminal-output", "terminal-stdin", "terminal-stdout", "terminal-stderr"],
344+
deps = ["@wasi_io_v028//:streams"],
345+
visibility = ["//visibility:public"],
346+
)
347+
""",
348+
)
349+
350+
# WASI Clocks interfaces v0.2.8
351+
# Note: monotonic-clock uses wasi:io/poll@0.2.8 for pollable
352+
http_archive(
353+
name = "wasi_clocks_v028",
354+
urls = ["https://github.com/WebAssembly/wasi-clocks/archive/refs/tags/v0.2.8.tar.gz"],
355+
sha256 = "292274abf4449453bb78110dc9d93486ea4730874fcabea45b49e3311e00c625",
356+
strip_prefix = "wasi-clocks-0.2.8",
357+
build_file_content = """
358+
load("@rules_wasm_component//wit:defs.bzl", "wit_library")
359+
360+
wit_library(
361+
name = "clocks",
362+
srcs = glob(["wit/*.wit"]),
363+
package_name = "wasi:clocks@0.2.8",
364+
interfaces = ["wall-clock", "monotonic-clock"],
365+
deps = ["@wasi_io_v028//:streams"],
366+
visibility = ["//visibility:public"],
367+
)
368+
""",
369+
)
370+
371+
# WASI Filesystem interfaces v0.2.8
372+
# Note: types use wasi:io/streams@0.2.8 and wasi:clocks/wall-clock@0.2.8
373+
http_archive(
374+
name = "wasi_filesystem_v028",
375+
urls = ["https://github.com/WebAssembly/wasi-filesystem/archive/refs/tags/v0.2.8.tar.gz"],
376+
sha256 = "c0c724ff36f8a8222051e3409ca357fc0ff5c03c9b4ceadbdd9192aedba9adad",
377+
strip_prefix = "wasi-filesystem-0.2.8",
378+
build_file_content = """
379+
load("@rules_wasm_component//wit:defs.bzl", "wit_library")
380+
381+
wit_library(
382+
name = "filesystem",
383+
srcs = glob(["wit/*.wit"]),
384+
package_name = "wasi:filesystem@0.2.8",
385+
interfaces = ["types", "preopens"],
386+
deps = ["@wasi_io_v028//:streams", "@wasi_clocks_v028//:clocks"],
387+
visibility = ["//visibility:public"],
388+
)
389+
""",
390+
)
391+
392+
# WASI Sockets interfaces v0.2.8
393+
# Note: tcp/udp use wasi:io/streams, wasi:io/poll, and wasi:clocks/monotonic-clock
394+
http_archive(
395+
name = "wasi_sockets_v028",
396+
urls = ["https://github.com/WebAssembly/wasi-sockets/archive/refs/tags/v0.2.8.tar.gz"],
397+
sha256 = "b230f2968957cad739c5b86ee20cf9cc9cd5de138e50d4f67b10ad14104eca09",
398+
strip_prefix = "wasi-sockets-0.2.8",
399+
build_file_content = """
400+
load("@rules_wasm_component//wit:defs.bzl", "wit_library")
401+
402+
wit_library(
403+
name = "sockets",
404+
srcs = glob(["wit/*.wit"]),
405+
package_name = "wasi:sockets@0.2.8",
406+
interfaces = ["network", "udp", "tcp", "udp-create-socket", "tcp-create-socket", "instance-network", "ip-name-lookup"],
407+
deps = ["@wasi_io_v028//:streams", "@wasi_clocks_v028//:clocks"],
408+
visibility = ["//visibility:public"],
409+
)
410+
""",
411+
)
412+
413+
# WASI Random interfaces v0.2.8
414+
http_archive(
415+
name = "wasi_random_v028",
416+
urls = ["https://github.com/WebAssembly/wasi-random/archive/refs/tags/v0.2.8.tar.gz"],
417+
sha256 = "25970acd8089a1b3f1bf7f266ab207b5f1134a424da26a3637d7cc3dee912a3a",
418+
strip_prefix = "wasi-random-0.2.8",
419+
build_file_content = """
420+
load("@rules_wasm_component//wit:defs.bzl", "wit_library")
421+
422+
wit_library(
423+
name = "random",
424+
srcs = glob(["wit/*.wit"]),
425+
package_name = "wasi:random@0.2.8",
426+
interfaces = ["random", "insecure", "insecure-seed"],
427+
visibility = ["//visibility:public"],
428+
)
429+
""",
430+
)
431+
432+
# WASI HTTP interfaces v0.2.8
433+
# Note: proxy world imports cli/stdout, cli/stderr, cli/stdin, random/random
434+
# types interface uses io/streams, io/error, io/poll, clocks/monotonic-clock
435+
http_archive(
436+
name = "wasi_http_v028",
437+
urls = ["https://github.com/WebAssembly/wasi-http/archive/refs/tags/v0.2.8.tar.gz"],
438+
sha256 = "95a6da213c7f0e30d34e40a2032508b2281d751b6027f57521564dbb348db16f",
439+
strip_prefix = "wasi-http-0.2.8",
440+
build_file_content = """
441+
load("@rules_wasm_component//wit:defs.bzl", "wit_library")
442+
443+
wit_library(
444+
name = "http",
445+
srcs = glob(["wit/*.wit"]),
446+
package_name = "wasi:http@0.2.8",
447+
interfaces = ["types", "incoming-handler", "outgoing-handler"],
448+
world = "proxy",
449+
deps = [
450+
"@wasi_io_v028//:streams",
451+
"@wasi_clocks_v028//:clocks",
452+
"@wasi_cli_v028//:cli",
453+
"@wasi_random_v028//:random",
454+
],
284455
visibility = ["//visibility:public"],
285456
)
286457
""",

0 commit comments

Comments
 (0)