#witx #webassembly #wasm #generator #bindgen

app witx-codegen

WITX code generator for WebAssembly guest modules

16 releases

0.10.4 Apr 7, 2021
0.10.3 Apr 7, 2021
0.3.8 Apr 6, 2021
0.2.1 Apr 4, 2021

#28 in WebAssembly

Download history 165/week @ 2021-03-31 116/week @ 2021-04-07

66 downloads per month

MIT license

270KB
6K SLoC

Rust 5K SLoC // 0.0% comments TypeScript 428 SLoC // 0.6% comments Zig 354 SLoC // 0.6% comments

WITX code generator

CI status crates.io

WITX-CodeGen: A WITX code and documentation generator

WITX is a way to describe types and function interfaces for WebAssembly modules.

From this, code generators can produce code to access data and call functions from different languages using the same layout and calling conventions.

The generated code is compatible with the WebAssembly standard APIs (WASI).

This tool uses the next (as on April 5th, 2021) revision of the format definition, as implemented in the forthcoming version 0.10 of the Rust witx crate.

witx-codegen is written in Rust, but is language-agnostic. The output is meant to be simple to understand.

The tool can also produce different documentation formats.

witx-codegen supersedes as-witx, zig-witx, witx-docgen, witx-overview-docgen and witx-generate-raw.

Installation

  • Via cargo:
cargo install witx-codegen
  • Precompiled binaries: tarballs and Debian/Ubuntu packages are available here.

Usage

WITX code generator for WebAssembly guest modules

USAGE:
    witx-codegen [FLAGS] [OPTIONS] <witx_files>...

FLAGS:
    -h, --help            Prints help information
    -H, --skip-header     Do not generate a header
    -I, --skip-imports    Ignores imported types and functions
    -V, --version         Prints version information

OPTIONS:
    -m, --module-name <module_name>
            Set the module name to use instead of reading it from the witx file

    -o, --output <output_file>         Output file, or - for the standard output
    -t, --output-type <output_type>
            Output type. One in: {assemblyscript, zig, rust, overview, markdown}
            [default: assemblyscript]

ARGS:
    <witx_files>...    WITX files

Backends

Example inputs

See the test folder for examples of WITX input files.

Other input formats may also be eventually supported, as well as extensions to produce more structured documentation.

Dependencies

~1.8–2.5MB
~49K SLoC