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/wit-bindgen-rt, a guest language bindings generator for WIT and the Component Model.

Build

Once functions are implemented, we can use cargo-component to generate the necessary bindings and build the component in release-mode, targeting wasm32-unknown-unknown:

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

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

We can also use the cargo-component default wasm32-wasi target:

cargo component build -p homestar-functions-test --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 or ./target/wasm32-wasi/release-wasm-fn/homestar_functions_test.wasm.

Other Helpful Repos

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.