Skip to content

Restructure lang support#44

Merged
kate-goldenring merged 5 commits intobytecodealliance:mainfrom
macovedj:restucture-lang-support
Sep 11, 2023
Merged

Restructure lang support#44
kate-goldenring merged 5 commits intobytecodealliance:mainfrom
macovedj:restucture-lang-support

Conversation

@macovedj
Copy link
Contributor

@macovedj macovedj commented Sep 8, 2023

Implements changes described here

@macovedj macovedj force-pushed the restucture-lang-support branch from fbbc4b6 to 11a38c9 Compare September 8, 2023 18:36
@macovedj macovedj marked this pull request as ready for review September 8, 2023 19:33
Copy link
Collaborator

@itowlson itowlson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM except two small things that now need linking. Thanks!

OK Successfully written add.wasm with imports ().
```

Now, run the component using the Rust `add` host:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This probably needs a link or other pointer to the Add host (previously the Add host was mentioned earlier on the same page but now that's split away).

Component built successfully
```

To test the component, run it using the Rust `add` host:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again maybe add a link?

[`cargo-component`](https://github.com/bytecodealliance/cargo-component) is a `cargo` subcommand for
creating WebAssembly components using Rust as the component's implementation language.

Let's create the same `add` component using the `cargo-component` tooling. First scaffold a project:
Copy link
Collaborator

@kate-goldenring kate-goldenring Sep 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Someone could land on this page before the language-support.md page. Should we say "add function in the example
world
" as we do in Python

Comment on lines 18 to 19
[`cargo-component`](https://github.com/bytecodealliance/cargo-component) is a `cargo` subcommand for
creating WebAssembly components using Rust as the component's implementation language.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is redundant with the paragraph a few paragraphs above. I think we can remove this.

Suggested change
[`cargo-component`](https://github.com/bytecodealliance/cargo-component) is a `cargo` subcommand for
creating WebAssembly components using Rust as the component's implementation language.

Copy link
Collaborator

@kate-goldenring kate-goldenring left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My comments echo Ivans. Just a couple small changes.

@macovedj
Copy link
Contributor Author

Think I addressed your comments @kate-goldenring and @itowlson. Sorry for the delay with addressing these... some other things grabbed my attention at the event.

$ npm install @bytecodealliance/componentize-js
```

Create a JavaScript module that implements the `add` function in [`add.wit`](../examples/example-host/add.wit):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this link (and others that reference this WIT in this PR) needs to be one parent directory higher. If you use VSCode, you could run this extension on each file you've changed to make sure the relative links are adjusted: https://marketplace.visualstudio.com/items?itemName=blackmist.LinkCheckMD

Suggested change
Create a JavaScript module that implements the `add` function in [`add.wit`](../examples/example-host/add.wit):
Create a JavaScript module that implements the `add` function in [`add.wit`](../../examples/example-host/add.wit):

application to a WebAssembly component.

Create a Python program that implements the `add` function in the [`example`
world](../examples/example-host/add.wit). Note that it imports the bindings that will be created by
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
world](../examples/example-host/add.wit). Note that it imports the bindings that will be created by
world](../../examples/example-host/add.wit). Note that it imports the bindings that will be created by


```sh
$ pip install componentize-py
$ componentize-py -d ../examples/example-host/add.wit -w example componentize guest -o add.wasm
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$ componentize-py -d ../examples/example-host/add.wit -w example componentize guest -o add.wasm
$ componentize-py -d /path/to/examples/example-host/add.wit -w example componentize guest -o add.wasm

## Building a Component with `cargo component`

Create a Rust program that implements the `add` function in the [`example`
world](../examples/example-host/add.wit). Note that it imports the bindings that will be created by
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
world](../examples/example-host/add.wit). Note that it imports the bindings that will be created by
world](../../examples/example-host/add.wit). Note that it imports the bindings that will be created by

### Running a Component from Rust Applications

To verify that our component works, lets run it from a Rust application that knows how to import a
component of the [`example` world](../examples/example-host/add.wit).
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
component of the [`example` world](../examples/example-host/add.wit).
component of the [`example` world](../../examples/example-host/add.wit).

Copy link
Collaborator

@kate-goldenring kate-goldenring left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @macovedj!

@kate-goldenring kate-goldenring merged commit 2aae118 into bytecodealliance:main Sep 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants