rylev / wac

WebAssembly Composition (WAC) tooling

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

WebAssembly Compositions (WAC)

A Bytecode Alliance project

A tool for composing WebAssembly components together.

build status Crates.io version Download docs.rs docs

Overview

wac is a tool for composing WebAssembly Components together.

The tool uses the WAC (pronounced "whack") language to define how components composed together.

Language

See the language documentation for more information on the syntax of WAC.

Installation

cargo install --git https://github.com/peterhuene/wac --locked

To enable support Warg component registries, specify the registry feature:

cargo install --git https://github.com/peterhuene/wac --locked --features registry

Usage

The wac CLI tool has three commands:

  • wac parse - Parses a composition into a JSON representation of the AST.
  • wac resolve - Resolves a composition into a JSON representation.
  • wac encode - Encodes a WAC source file as a WebAssembly component.

Encoding Compositions

To encode a composition, use the wac encode command:

wac encode -t input.wac

This will encode input.wac as a WebAssembly component and write the text representation of the component to stdout.

wac encode -o output.wasm input.wac

This will encode input.wac as a WebAssembly component named output.wasm.

By default, wac will import dependencies rather than defining (i.e. embedding) them in the output component; to define dependencies in the output component, use the --define flag:

wac encode --define -o output.wasm input.wac

Dependencies

Dependencies (i.e. packages referenced in a WAC source file) may be located within a deps subdirectory, with an expected structure of:

deps/
├─ <namespace>/
│  ├─ <package>.wasm

If the wit build-time feature is enabled, the dependency may be a directory containing a WIT package:

deps/
├─ <namespace>/
│  ├─ <package>/
│  │  ├─ a.wit
│  │  ├─ ...

The --deps-dir CLI option may be used to specify a different directory to search for dependencies.

Dependencies may also be specified with the --dep CLI option:

wac encode --dep foo:bar=./baz.wasm -o output.wasm input.wac

By default, dependencies must be binary-encoded WebAssembly components; to enable support for WAT files, use the wat build-time feature.

If the registry build-time feature is enabled, then dependencies may be automatically resolved from a Warg registry and do not need to exist in the deps subdirectory or specified via the --dep CLI option.

About

WebAssembly Composition (WAC) tooling

License:Apache License 2.0


Languages

Language:Rust 98.4%Language:WebAssembly 1.6%