Skip to content

Latest commit

 

History

History
 
 

homestar-functions

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
Homestar logo

Homestar Functions

License Discord

This is a template-like, example-driven set of non-published crates used for building Wasm components in order to run and test them on the latest wasmtime runtime, with the component-model feature turned on.

We use the components compiled from this crate as fixtures for our execution-and-IPLD-focused homestar-wasm crate. We currently rely on the WIT format IDL to describe exports, for example:

default world homestar {
  export add-one: func(a: s32) -> s32
  export append-string: func(a: string) -> string
  export transpose: func(matrix: list<list<u8>>) -> list<list<u8>>
}

We then implement these functions in lib.rs using wit-bindgen, a guest language bindings generator for WIT and the Component Model.

Build

Once functions are implemented, we can build the component in release-mode, targetting wasm32-unknown-unknown, :

# from this directory:
cd test && cargo build --target wasm32-unknown-unknown --profile release-wasm-fn

# or from the top-level workspace:
cargo build -p homestar-functions-test --target wasm32-unknown-unknown --profile release-wasm-fn

Guest Wasm modules will be generated in the top-level homestar directory: ./target/wasm32-unknown-unknown/release-wasm-fn/homestar_functions_test.wasm.

Sadly, this module is not yet an actual component. But, we can leverage the wasm-tools tooling (wit-component in particular) to convert the core Wasm binary to a Wasm component and place it in a different directory:

wasm-tools component new /
../target/wasm32-unknown-unknown/release-wasm-fn/homestar_functions_test.wasm -o ../homestar-wasm/fixtures/

Of note, homestar-wasm's execution model will do this conversion at runtime!

Other Helpful Repos

Coming soon

License

This project is licensed under the Apache License 2.0, or http://www.apache.org/licenses/LICENSE-2.0.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.