Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ resolver = "2"
members = [
"components/*",
]
exclude = [
"components/wit",
]

[workspace.dependencies]
wit-bindgen = "0.62.0"
12 changes: 9 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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')

Expand Down
2 changes: 1 addition & 1 deletion components/levels/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion components/to-stdout/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ impl Guest for LoggingToStdout {
}

wit_bindgen::generate!({
path: "../../wit",
path: "../wit",
world: "to-stdout",
features: ["clocks-timezone"],
generate_all
Expand Down
36 changes: 36 additions & 0 deletions components/wit/deps/wasi-logging-0.1.0-draft/package.wit
Original file line number Diff line number Diff line change
@@ -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;
}
13 changes: 13 additions & 0 deletions components/wit/worlds.wit
Original file line number Diff line number Diff line change
@@ -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;
}
39 changes: 39 additions & 0 deletions components/wkg.lock
Original file line number Diff line number Diff line change
@@ -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"
2 changes: 2 additions & 0 deletions components/wkg.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[overrides]
"componentized:logging" = { path = "../wit" }
12 changes: 2 additions & 10 deletions wit/worlds.wit
Original file line number Diff line number Diff line change
@@ -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;
}
27 changes: 0 additions & 27 deletions wkg.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading