From 9c817a04022bfb80c7d728d75821942781b72ac1 Mon Sep 17 00:00:00 2001 From: Scott Andrews Date: Sun, 20 Sep 2026 19:59:02 -0400 Subject: [PATCH] Publish interface While we don't currently define a custom interface, it's still useful to publish an interface package. The root wit directory is now for the published interface, component specific wit used for bindgen is located in the components directory. The package version in the root interface is used for publishing pre-release builds. Bumping that version to 0.3.0-dev as the next release version will be 0.3.0 as it consumes wasi@0.3 interfaces. Signed-off-by: Scott Andrews --- Cargo.toml | 3 ++ Makefile | 12 ++++-- components/levels/src/lib.rs | 2 +- components/to-stdout/src/lib.rs | 2 +- .../wit}/deps/wasi-cli-0.3.0/package.wit | 0 .../wit}/deps/wasi-clocks-0.3.0/package.wit | 0 .../deps/wasi-config-0.2.0-rc.1/package.wit | 0 .../deps/wasi-filesystem-0.3.0/package.wit | 0 .../deps/wasi-logging-0.1.0-draft/package.wit | 36 +++++++++++++++++ .../wit}/deps/wasi-random-0.3.0/package.wit | 0 .../wit}/deps/wasi-sockets-0.3.0/package.wit | 0 components/wit/worlds.wit | 13 +++++++ components/wkg.lock | 39 +++++++++++++++++++ components/wkg.toml | 2 + wit/worlds.wit | 12 +----- wkg.lock | 27 ------------- 16 files changed, 106 insertions(+), 42 deletions(-) rename {wit => components/wit}/deps/wasi-cli-0.3.0/package.wit (100%) rename {wit => components/wit}/deps/wasi-clocks-0.3.0/package.wit (100%) rename {wit => components/wit}/deps/wasi-config-0.2.0-rc.1/package.wit (100%) rename {wit => components/wit}/deps/wasi-filesystem-0.3.0/package.wit (100%) create mode 100644 components/wit/deps/wasi-logging-0.1.0-draft/package.wit rename {wit => components/wit}/deps/wasi-random-0.3.0/package.wit (100%) rename {wit => components/wit}/deps/wasi-sockets-0.3.0/package.wit (100%) create mode 100644 components/wit/worlds.wit create mode 100644 components/wkg.lock create mode 100644 components/wkg.toml diff --git a/Cargo.toml b/Cargo.toml index 4426ec2..22732cd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,6 +3,9 @@ resolver = "2" members = [ "components/*", ] +exclude = [ + "components/wit", +] [workspace.dependencies] wit-bindgen = "0.62.0" diff --git a/Makefile b/Makefile index f0465ff..4756e51 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ SHELL := /bin/bash export RUST_BACKTRACE ?= 1 export WASMTIME_BACKTRACE_DETAILS ?= 1 -COMPONENTS = $(shell ls -1 components) +COMPONENTS = $(sort $(notdir $(patsubst %/,%,$(dir $(wildcard components/*/Cargo.toml))))) .PHONY: all all: components @@ -15,7 +15,7 @@ clean: rm -rf lib/*.wasm.md .PHONY: components -components: $(foreach component,$(COMPONENTS),lib/$(component).wasm $(foreach component,$(COMPONENTS),lib/$(component).debug.wasm)) +components: lib/interface.wasm $(foreach component,$(COMPONENTS),lib/$(component).wasm lib/$(component).debug.wasm) define BUILD_COMPONENT @@ -33,13 +33,19 @@ endef $(foreach component,$(COMPONENTS),$(eval $(call BUILD_COMPONENT,$(component)))) +lib/interface.wasm: wit/deps README.md + wkg build -o lib/interface.wasm + cp README.md lib/interface.wasm.md .PHONY: wit -wit: wit/deps +wit: wit/deps components/wit/deps wit/deps: wkg.toml $(shell find wit -type f -name "*.wit" -not -path "deps") wkg wit fetch +components/wit/deps: wit/deps components/wkg.toml $(shell find components/wit -type f -name "*.wit" -not -path "deps") + wkg wit fetch + .PHONY: publish ## Publish each component in the lib directory publish: $(shell find lib -maxdepth 1 -type f -name "*.wasm" | sed -e 's:^lib/:publish-:g') diff --git a/components/levels/src/lib.rs b/components/levels/src/lib.rs index 2db0969..d87078a 100644 --- a/components/levels/src/lib.rs +++ b/components/levels/src/lib.rs @@ -109,7 +109,7 @@ fn level_map(level: Level) -> logging::Level { } wit_bindgen::generate!({ - path: "../../wit", + path: "../wit", world: "levels", features: ["clocks-timezone"], generate_all diff --git a/components/to-stdout/src/lib.rs b/components/to-stdout/src/lib.rs index f109699..ae58ab5 100644 --- a/components/to-stdout/src/lib.rs +++ b/components/to-stdout/src/lib.rs @@ -43,7 +43,7 @@ impl Guest for LoggingToStdout { } wit_bindgen::generate!({ - path: "../../wit", + path: "../wit", world: "to-stdout", features: ["clocks-timezone"], generate_all diff --git a/wit/deps/wasi-cli-0.3.0/package.wit b/components/wit/deps/wasi-cli-0.3.0/package.wit similarity index 100% rename from wit/deps/wasi-cli-0.3.0/package.wit rename to components/wit/deps/wasi-cli-0.3.0/package.wit diff --git a/wit/deps/wasi-clocks-0.3.0/package.wit b/components/wit/deps/wasi-clocks-0.3.0/package.wit similarity index 100% rename from wit/deps/wasi-clocks-0.3.0/package.wit rename to components/wit/deps/wasi-clocks-0.3.0/package.wit diff --git a/wit/deps/wasi-config-0.2.0-rc.1/package.wit b/components/wit/deps/wasi-config-0.2.0-rc.1/package.wit similarity index 100% rename from wit/deps/wasi-config-0.2.0-rc.1/package.wit rename to components/wit/deps/wasi-config-0.2.0-rc.1/package.wit diff --git a/wit/deps/wasi-filesystem-0.3.0/package.wit b/components/wit/deps/wasi-filesystem-0.3.0/package.wit similarity index 100% rename from wit/deps/wasi-filesystem-0.3.0/package.wit rename to components/wit/deps/wasi-filesystem-0.3.0/package.wit diff --git a/components/wit/deps/wasi-logging-0.1.0-draft/package.wit b/components/wit/deps/wasi-logging-0.1.0-draft/package.wit new file mode 100644 index 0000000..164cb5b --- /dev/null +++ b/components/wit/deps/wasi-logging-0.1.0-draft/package.wit @@ -0,0 +1,36 @@ +package wasi:logging@0.1.0-draft; + +/// WASI Logging is a logging API intended to let users emit log messages with +/// simple priority levels and context values. +interface logging { + /// A log level, describing a kind of message. + enum level { + /// Describes messages about the values of variables and the flow of + /// control within a program. + trace, + /// Describes messages likely to be of interest to someone debugging a + /// program. + debug, + /// Describes messages likely to be of interest to someone monitoring a + /// program. + info, + /// Describes messages indicating hazardous situations. + warn, + /// Describes messages indicating serious errors. + error, + /// Describes messages indicating fatal errors. + critical, + } + + /// Emit a log message. + /// + /// A log message has a `level` describing what kind of message is being + /// sent, a context, which is an uninterpreted string meant to help + /// consumers group similar messages, and a string containing the message + /// text. + log: func(level: level, context: string, message: string); +} + +world imports { + import logging; +} diff --git a/wit/deps/wasi-random-0.3.0/package.wit b/components/wit/deps/wasi-random-0.3.0/package.wit similarity index 100% rename from wit/deps/wasi-random-0.3.0/package.wit rename to components/wit/deps/wasi-random-0.3.0/package.wit diff --git a/wit/deps/wasi-sockets-0.3.0/package.wit b/components/wit/deps/wasi-sockets-0.3.0/package.wit similarity index 100% rename from wit/deps/wasi-sockets-0.3.0/package.wit rename to components/wit/deps/wasi-sockets-0.3.0/package.wit diff --git a/components/wit/worlds.wit b/components/wit/worlds.wit new file mode 100644 index 0000000..ee4fdc9 --- /dev/null +++ b/components/wit/worlds.wit @@ -0,0 +1,13 @@ +package componentized:logging-components; + +world levels { + import wasi:logging/logging@0.1.0-draft; + import wasi:config/store@0.2.0-rc.1; + export wasi:logging/logging@0.1.0-draft; +} + +world to-stdout { + import wasi:cli/stdout@0.3.0; + import wasi:clocks/system-clock@0.3.0; + export wasi:logging/logging@0.1.0-draft; +} diff --git a/components/wkg.lock b/components/wkg.lock new file mode 100644 index 0000000..a315bcf --- /dev/null +++ b/components/wkg.lock @@ -0,0 +1,39 @@ +# This file is automatically generated. +# It is not intended for manual editing. +version = 1 + +[[packages]] +name = "wasi:cli" +registry = "wasi.dev" + +[[packages.versions]] +requirement = "=0.3.0" +version = "0.3.0" +digest = "sha256:3a2d58743b67a057f7210b9a73d3b21b34ec7895ffe34d1cb092927307156e40" + +[[packages]] +name = "wasi:clocks" +registry = "wasi.dev" + +[[packages.versions]] +requirement = "=0.3.0" +version = "0.3.0" +digest = "sha256:59e1f4079e64ada450e19ffc9d08854c904e356ed8cc1fda36ff4fe150264db2" + +[[packages]] +name = "wasi:config" +registry = "wasi.dev" + +[[packages.versions]] +requirement = "=0.2.0-rc.1" +version = "0.2.0-rc.1" +digest = "sha256:1b7f1b0fd07bb4cede16c6a6ec8852815dfb924639a78735fc7bdffdc164485d" + +[[packages]] +name = "wasi:logging" +registry = "wasi.dev" + +[[packages.versions]] +requirement = "=0.1.0-draft" +version = "0.1.0-draft" +digest = "sha256:09621a45b12b0a9cddc798517f778aac0e5ae4bd234077b3d70758d6cf625580" diff --git a/components/wkg.toml b/components/wkg.toml new file mode 100644 index 0000000..0f243cc --- /dev/null +++ b/components/wkg.toml @@ -0,0 +1,2 @@ +[overrides] +"componentized:logging" = { path = "../wit" } diff --git a/wit/worlds.wit b/wit/worlds.wit index b2de95a..2f564f0 100644 --- a/wit/worlds.wit +++ b/wit/worlds.wit @@ -1,13 +1,5 @@ -package componentized:logging; +package componentized:logging@0.3.0-dev; -world levels { +world imports { import wasi:logging/logging@0.1.0-draft; - import wasi:config/store@0.2.0-rc.1; - export wasi:logging/logging@0.1.0-draft; -} - -world to-stdout { - import wasi:cli/stdout@0.3.0; - import wasi:clocks/system-clock@0.3.0; - export wasi:logging/logging@0.1.0-draft; } diff --git a/wkg.lock b/wkg.lock index a315bcf..5671fb9 100644 --- a/wkg.lock +++ b/wkg.lock @@ -2,33 +2,6 @@ # It is not intended for manual editing. version = 1 -[[packages]] -name = "wasi:cli" -registry = "wasi.dev" - -[[packages.versions]] -requirement = "=0.3.0" -version = "0.3.0" -digest = "sha256:3a2d58743b67a057f7210b9a73d3b21b34ec7895ffe34d1cb092927307156e40" - -[[packages]] -name = "wasi:clocks" -registry = "wasi.dev" - -[[packages.versions]] -requirement = "=0.3.0" -version = "0.3.0" -digest = "sha256:59e1f4079e64ada450e19ffc9d08854c904e356ed8cc1fda36ff4fe150264db2" - -[[packages]] -name = "wasi:config" -registry = "wasi.dev" - -[[packages.versions]] -requirement = "=0.2.0-rc.1" -version = "0.2.0-rc.1" -digest = "sha256:1b7f1b0fd07bb4cede16c6a6ec8852815dfb924639a78735fc7bdffdc164485d" - [[packages]] name = "wasi:logging" registry = "wasi.dev"