Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
7df9182
refactor(lang/rust): rust language guide
vados-cosmonic Aug 29, 2025
d3290a6
refactor: add new sections to contain reworked rust sections
vados-cosmonic Oct 6, 2025
24b797d
chore(lang/rust): fill out more of runnable component section
vados-cosmonic Oct 6, 2025
fad04df
chore(lang/rust): add command component section
vados-cosmonic Oct 6, 2025
196c580
chore(lang/rust): add old cargo component implementations
vados-cosmonic Oct 6, 2025
e23e453
refactor(lang/rust): WIT resources guide for rust
vados-cosmonic Oct 6, 2025
fdd7934
refactor(lang/rust): importing guide, simple build guide
vados-cosmonic Oct 6, 2025
bb60a35
fix(lang/rust): remove more references to cargo-component
vados-cosmonic Oct 6, 2025
4334bd9
fix(lang/rust): links
vados-cosmonic Oct 6, 2025
59e0efb
refactor(pl/rust): rework wasi run interface note
vados-cosmonic Oct 15, 2025
1cba12f
refactor(pl/rust): remove warning about reactor component reuse
vados-cosmonic Oct 15, 2025
e919fe2
fix(pl/rust): typos
vados-cosmonic Oct 15, 2025
2f2eb70
fix(pl/rust): add missing greet interface for runnable example
vados-cosmonic Oct 15, 2025
03e76d9
refactor(pl/rust): add note about wasi:cli/run standard interop
vados-cosmonic Oct 15, 2025
76238d7
refactor(pl/rust): discuss runnable command components first
vados-cosmonic Oct 15, 2025
aad3632
refactor(pl/rust): remove stdout print bug note
vados-cosmonic Oct 15, 2025
cc63c63
refactor(pl/rust): remove unneeded note
vados-cosmonic Oct 15, 2025
90e2f5f
refactor(pl/rust): clarify use of bindings
vados-cosmonic Oct 15, 2025
35503d1
refactor(pl/rust): improve composition ending notes
vados-cosmonic Oct 15, 2025
9cdab08
fix(pl/rust): cargo -> wkg
vados-cosmonic Oct 15, 2025
25b3b6b
refactor(lang/js): move advanced sections, rework runnable functions
vados-cosmonic Oct 15, 2025
a306584
refactor(lang/rust): add target to cargo build cmd
vados-cosmonic Oct 15, 2025
9b4e288
fix(lang/rust): target wasip1 -> wasip2
vados-cosmonic Oct 15, 2025
5dd68eb
fix(lang/rust): remove unneeded dead_code allow annotation
vados-cosmonic Oct 15, 2025
8c36f77
feat: add generic guides for other languages
vados-cosmonic Oct 15, 2025
8319b4d
chore: update wording on creating runnable components section
vados-cosmonic Oct 15, 2025
f468916
refactor(lang/rust): description of reactors vs command
vados-cosmonic Oct 15, 2025
0227de4
fix(lang/rust): add some rationale for executable libraries
vados-cosmonic Oct 15, 2025
26f52f3
fix: add redirects for moved language-support pages
vados-cosmonic Oct 15, 2025
03f9528
refactor: improve language around other languages
vados-cosmonic Oct 16, 2025
181440a
refactor: other languages contribution CTA
vados-cosmonic Oct 16, 2025
5b24600
fix: remove "not impossible" wording
vados-cosmonic Oct 22, 2025
e99de7c
fix: wording on the for other-languages.md
vados-cosmonic Oct 22, 2025
28a6721
fix: typos
vados-cosmonic Oct 22, 2025
1f8a7c1
refactor: other-languages section for building a simple component
vados-cosmonic Oct 22, 2025
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
5 changes: 0 additions & 5 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@
# Ensure binary files aren't considered as text
*.wasm binary

# Genrated code from cargo-component
component-model/examples/tutorial/*/src/bindings.rs linguist-generated

# Generated code from JS tutorial
component-model/examples/tutorial/jco/package-lock.json linguist-generated

Cargo-component.lock linguist-language=toml

14 changes: 6 additions & 8 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,20 @@ jobs:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Install Rust
run: rustup update stable --no-self-update

- uses: taiki-e/cache-cargo-install-action@5c9abe9a3f79d831011df7c47177debbeb320405 # v2.1.2
with:
tool: cargo-component
run: |
rustup update stable --no-self-update
rustup target add wasm32-wasip2

- uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2.7.8
with:
shared-key: ${{ hashFiles('${{ matrix.projects.folder }}/Cargo.lock') }}

- name: Cargo bulid the package
- name: Cargo build the package
working-directory: ${{ matrix.projects.folder }}
if: ${{ matrix.projects.type != 'component' }}
run: cargo build

- name: Cargo component build
- name: Cargo build
working-directory: ${{ matrix.projects.folder }}
if: ${{ matrix.projects.type == 'component' }}
run: cargo component build
run: cargo build
13 changes: 13 additions & 0 deletions component-model/book.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ git-repository-url = "https://github.com/bytecodealliance/component-docs/tree/ma
edit-url-template = "https://github.com/bytecodealliance/component-docs/tree/main/component-model/{path}"
additional-css = ["theme/head.hbs"]

[output.html.fold]
enable = true
level = 1

[output.html.redirect]
"/creating-and-consuming/composing.html" = "/composing-and-distributing/composing.html"
"/creating-and-consuming/distributing.html" = "/composing-and-distributing/distributing.html"
Expand All @@ -18,6 +22,15 @@ additional-css = ["theme/head.hbs"]
"/creating-and-consuming.html" = "/language-support.html"
"/runtimes/wasmtime.html" = "/running-components/wasmtime.html"
"/runtimes/jco.html" = "/running-components/jco.html"
"/language-support/csharp.html" = "/language-support/building-a-simple-component/csharp.html"
"/language-support/c.html" = "/language-support/building-a-simple-component/c.html"
"/language-support/go.html" = "/language-support/building-a-simple-component/go.html"
"/language-support/javascript.html" = "/language-support/building-a-simple-component/javascript.html"
"/language-support/moonbit.html" = "/language-support/building-a-simple-component/moonbit.html"
"/language-support/other-languages.html" = "/language-support/building-a-simple-component/other-languages.html"
"/language-support/python.html" = "/language-support/building-a-simple-component/python.html"
"/language-support/rust.html" = "/language-support/building-a-simple-component/rust.html"
"/language-support/wat.html" = "/language-support/building-a-simple-component/wat.html"

[preprocessor.alerts]

Expand Down
28 changes: 14 additions & 14 deletions component-model/examples/tutorial/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ To expand the exercise to add more components, add another operator world, expan

## Building and running the example

Use [`cargo-component`](https://github.com/bytecodealliance/cargo-component) and [`wac`](https://github.com/bytecodealliance/wac) to build and compose the calculator component.
Use [`wac`](https://github.com/bytecodealliance/wac) to build and compose the calculator component.

```sh
(cd calculator && cargo component build --release)
(cd adder && cargo component build --release)
(cd command && cargo component build --release)
wac plug calculator/target/wasm32-wasip1/release/calculator.wasm --plug adder/target/wasm32-wasip1/release/adder.wasm -o composed.wasm
wac plug command/target/wasm32-wasip1/release/command.wasm --plug composed.wasm -o final.wasm
(cd calculator && cargo build --target=wasm32-wasip2 --release)
(cd adder && cargo build --target=wasm32-wasip2 --release)
(cd command && cargo build --target=wasm32-wasip2 --release)
wac plug calculator/target/wasm32-wasip2/release/calculator.wasm --plug adder/target/wasm32-wasip2/release/adder.wasm -o composed.wasm
wac plug command/target/wasm32-wasip2/release/command.wasm --plug composed.wasm -o final.wasm
```

Now, run the component with Wasmtime:
Expand All @@ -67,9 +67,9 @@ wasmtime run final.wasm 1 2 add

```sh
mkdir -p deps/docs
cp adder/target/wasm32-wasip1/release/adder.wasm deps/docs/adder-impl.wasm
cp calculator/target/wasm32-wasip1/release/calculator.wasm deps/docs/calculator-impl.wasm
cp command/target/wasm32-wasip1/release/command.wasm deps/docs/command-impl.wasm
cp adder/target/wasm32-wasip2/release/adder.wasm deps/docs/adder-impl.wasm
cp calculator/target/wasm32-wasip2/release/calculator.wasm deps/docs/calculator-impl.wasm
cp command/target/wasm32-wasip2/release/command.wasm deps/docs/command-impl.wasm
```

Now we are ready to construct a WAC file to define our composition. Ours instantiates our three components, declaring
Expand All @@ -84,12 +84,12 @@ package example:composition;
let adder-instance = new docs:adder-impl { };

// Instantiate the calculator-impl component that implements the calculator world.
// In the `new` expression, specify the source of the `add` import to be `adder-instance`'s `add` export.
// In the `new` expression, specify the source of the `add` import to be `adder-instance`'s `add` export.
let calculator-instance = new docs:calculator-impl { add: adder-instance.add };

// Instantiate a command-impl component that implements the app world.
// The command component might import other interfaces, such as WASI interfaces, but we want to leave
// those as imports in the final component, so supply `...` to allow those other imports to remain unresolved.
// The command component might import other interfaces, such as WASI interfaces, but we want to leave
// those as imports in the final component, so supply `...` to allow those other imports to remain unresolved.
// The command's exports (in this case, `wasi:cli/run`) remain unaffected in the resulting instance.
let command-instance = new docs:command-impl { calculate: calculator-instance.calculate,... };

Expand All @@ -101,12 +101,12 @@ export command-instance["wasi:cli/run@0.2.0"];
Now, perform your composition by passing the WAC file to `wac compose`.

```sh
wac compose composition.wac -o final.wasm
wac compose composition.wac -o final.wasm
```

> Note, instead of moving all the components to a `deps/docs` directory, you can pass the paths to the components inline
> ```sh
> wac compose --dep docs:adder-impl=./adder/target/wasm32-wasip1/release/adder.wasm --dep docs:calculator-impl=./calculator/target/wasm32-wasip1/release/calculator.wasm --dep docs:command-impl=./command/target/wasm32-wasip1/release/command.wasm -o final.wasm composition.wac
> wac compose --dep docs:adder-impl=./adder/target/wasm32-wasip2/release/adder.wasm --dep docs:calculator-impl=./calculator/target/wasm32-wasip2/release/calculator.wasm --dep docs:command-impl=./command/target/wasm32-wasip2/release/command.wasm -o final.wasm composition.wac
> ```

Run the component with Wasmtime:
Expand Down
2 changes: 2 additions & 0 deletions component-model/examples/tutorial/adder/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[build]
target = "wasm32-wasip2"
Loading