Skip to content

wit/bindgen: generate pruned WIT file for each WIT world in the relevant Go package directory#206

Merged
ydnar merged 5 commits intomainfrom
ydnar/wit-in-go
Oct 10, 2024
Merged

wit/bindgen: generate pruned WIT file for each WIT world in the relevant Go package directory#206
ydnar merged 5 commits intomainfrom
ydnar/wit-in-go

Conversation

@ydnar
Copy link
Copy Markdown
Collaborator

@ydnar ydnar commented Oct 9, 2024

This is a step towards embedding textual WIT in a WebAssembly module generated by TinyGo (and eventually Go), for consumption by downstream programs like wasm-tools or for use as runtime metadata.

This can be verified by running go test ./wit/bindgen -write and examining the contents of the generated directory.

Inspired by #179.

@ydnar ydnar requested review from Mossaka and lxfontes October 9, 2024 18:56
@ydnar ydnar self-assigned this Oct 9, 2024
Comment thread CHANGELOG.md
### Added

- Go [type aliases](https://go.dev/ref/spec#Alias_declarations) are now generated for each WIT type alias (`type foo = bar`). Deep chains of type aliases (`type b = a; type c = b;`) are fully supported. Generated documentation now reflects whether a type is an alias. Fixes [#204](https://github.com/bytecodealliance/wasm-tools-go/issues/204).
- `wit-bindgen-go generate` now generates a WIT file for each WIT world in its corresponding Go package directory. For example the `wasi:http/proxy` world would generate `wasi/http/proxy/proxy.wit`.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

thoughts on renaming the wit file to proxy@0.2.2.wit?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

⚖️
I think keeping <world>.wit is ok cause we'd never have proxy@0.2.2.wit & proxy@0.2.0.wit in the same directory, but am not strong about it.
What's the motivation @Mossaka ?

Copy link
Copy Markdown
Collaborator Author

@ydnar ydnar Oct 10, 2024

Choose a reason for hiding this comment

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

The Go package directory can be versioned, e.g. wasi/http/v0.2.2/proxy/proxy.wit

@ydnar
Copy link
Copy Markdown
Collaborator Author

ydnar commented Oct 10, 2024

Merging, we can continue to iterate.

@ydnar ydnar merged commit ebcb14a into main Oct 10, 2024
@ydnar ydnar deleted the ydnar/wit-in-go branch October 10, 2024 20:42
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