Skip to content

feat: add adapt option for build and test commands#34

Open
jamesstocktonj1 wants to merge 4 commits intobytecodealliance:mainfrom
jamesstocktonj1:feat/adapt-option
Open

feat: add adapt option for build and test commands#34
jamesstocktonj1 wants to merge 4 commits intobytecodealliance:mainfrom
jamesstocktonj1:feat/adapt-option

Conversation

@jamesstocktonj1
Copy link
Copy Markdown

Description

Example

Without flag:

$ componentize-go --world hello build
$ wash inspect main.wasm
package root:component;

world root {
  import wasi:io/poll@0.2.6;
  import wasi:clocks/monotonic-clock@0.2.6;
  import wasi:cli/environment@0.2.6;
  ...
}

With flag:

$ componentize-go --world hello build --adapt wasi_snapshot_preview1_v24.0.4.reactor.wasm
$ wash inspect main.wasm
package root:component;

world root {
  import wasi:io/poll@0.2.0;
  import wasi:clocks/monotonic-clock@0.2.0;
  import wasi:cli/environment@0.2.0;
  ...
}

@jamesstocktonj1
Copy link
Copy Markdown
Author

cc: @asteurer

src/utils.rs Outdated
encoder = encoder.module(&wasm)?;
encoder = encoder.adapter("wasi_snapshot_preview1", WASIP1_SNAPSHOT)?;
let adapt_bytes = if let Some(adapt) = adapt_file {
std::fs::read(adapt).context(format!("failed to read adapt file '{}'", adapt.display()))?
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nit: I'd recommend using with_context instead of context here to avoid allocating and formatting the string until and unless an error occurs.

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.

@jamesstocktonj1 Thanks for the PR! Once Joel's comment is resolved, I'll get this merged 😄

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thanks for the feedback!

@asteurer Just made the change 👍

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants