Skip to content

feat: support WIT source inputs in component bindgen macro#1589

Open
andreiltd wants to merge 3 commits into
hyperlight-dev:mainfrom
andreiltd:wit-macro
Open

feat: support WIT source inputs in component bindgen macro#1589
andreiltd wants to merge 3 commits into
hyperlight-dev:mainfrom
andreiltd:wit-macro

Conversation

@andreiltd

Copy link
Copy Markdown
Member

Add explicit wit, wasm, and inline input forms for component bindgen macros. It is backward compatilbe. New macro arguments allow things like:

// wit file
hyperlight_component_macro::host_bindgen!(wit: "wit/world.wit");
// wit package
hyperlight_component_macro::host_bindgen!(wit: "wit");

// wasm encoded component type
hyperlight_component_macro::host_bindgen!(wasm: "wit/world.wasm");

// Inline wit
hyperlight_component_macro::host_bindgen!({
    inline: r#"
        package test:inline;

        world test {
            export run: func();
        }
    "#,
    world: "test",
});

// Select a world from a multi-world wit package
hyperlight_component_macro::host_bindgen!({
    wit: "wit",
    world: "my-world",
});

// Legacy wasm-compatible forms still work
hyperlight_component_macro::host_bindgen!("wit/world.wasm");
hyperlight_component_macro::host_bindgen!({
    path: "wit/world.wasm",
    world_name: "my-world",
});

Add explicit wit, wasm, and inline input forms for component bindgen
macros.

Signed-off-by: Tomasz Andrzejak <andreiltd@gmail.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR extends Hyperlight’s component bindgen proc-macros to accept WIT sources directly (WIT files, WIT package directories, and inline WIT), in addition to the legacy “wasm-encoded WIT” inputs, and updates tests/CI scripts to rely on WIT sources rather than pre-generated .wasm artifacts.

Changes:

  • Add a WitSource input abstraction in hyperlight_component_util and route bindgen through it (WIT file/dir, wasm, inline).
  • Extend host_bindgen! / guest_bindgen! parsing to accept wit:, wasm:, and inline: forms (plus world selection).
  • Update test fixtures, integration tests, and CI/Just recipes to use WIT inputs directly and drop the artifact upload/download flow for generated .wasm WIT containers.

Reviewed changes

Copilot reviewed 9 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/tests/rust_guests/witguest/src/bindings.rs Switch guest bindgen invocation from wasm container to wit: input.
src/tests/rust_guests/Cargo.lock Lockfile updates for rust guest workspace deps.
src/hyperlight_host/tests/wit_test.rs Update host-side bindgen tests to use wit: and add inline-WIT bindgen coverage.
src/hyperlight_component_util/tests/wasmtime_guest_codegen.rs Expand component-util tests to cover WIT/wasm/inline input handling.
src/hyperlight_component_util/src/util.rs Introduce WitSource and unify WIT type reading across input forms.
src/hyperlight_component_util/Cargo.toml Add wit-component / wit-parser dependencies to support WIT parsing/encoding.
src/hyperlight_component_macro/src/lib.rs Extend macro docs + parsing to accept explicit wit:/wasm:/inline: inputs and world selection.
Justfile Remove WIT-to-wasm generation steps; adjust clean/test/clippy targets accordingly.
Cargo.lock Workspace lockfile updates for new WIT-related dependencies.
.github/workflows/dep_build_test.yml Remove download steps for pre-generated WIT .wasm artifacts.
.github/workflows/dep_build_guests.yml Remove upload steps for pre-generated WIT .wasm artifacts.

Comment thread src/hyperlight_component_macro/src/lib.rs
Comment thread src/hyperlight_component_util/tests/wasmtime_guest_codegen.rs
@andreiltd andreiltd added the kind/enhancement For PRs adding features, improving functionality, docs, tests, etc. label Jun 26, 2026
Signed-off-by: Tomasz Andrzejak <andreiltd@gmail.com>
Signed-off-by: Tomasz Andrzejak <andreiltd@gmail.com>
@andreiltd andreiltd added the ready-for-review PR is ready for (re-)review label Jun 26, 2026

@danbugs danbugs left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Mostly LGTM, just two minor comments.

fn source_or_env(source: Option<util::WitSource>) -> util::WitSource {
source.unwrap_or_else(|| {
util::WitSource::Wasm(std::path::PathBuf::from(
std::env::var_os("WIT_WORLD").unwrap(),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If this fails, we'd just get a generic unwrap panic, might want to improve the error msg

kebab_name
},
);
std::fs::remove_file(wasm_path).expect("temporary wasm fixture should be removed");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think we reach this if the assert fails?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/enhancement For PRs adding features, improving functionality, docs, tests, etc. ready-for-review PR is ready for (re-)review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants