Skip to content

Support lists of WIT directories on the CLI.#1368

Merged
alexcrichton merged 1 commit intobytecodealliance:mainfrom
sunfishcode:sunfishcode/lists-of-wits
Aug 26, 2025
Merged

Support lists of WIT directories on the CLI.#1368
alexcrichton merged 1 commit intobytecodealliance:mainfrom
sunfishcode:sunfishcode/lists-of-wits

Conversation

@sunfishcode
Copy link
Member

@sunfishcode sunfishcode commented Aug 26, 2025

Accept multiple WIT paths in the wit-bindgen CLI, using the same logic as the multiple WIT paths accepted by the path parameter in the Rust bindgen macro.

Also, document that list-of-WIT interfaces, in the Rust macro and now the wit-bindgen CLI, have a topological ordering requirement which may be lifted in the future.

@sunfishcode sunfishcode force-pushed the sunfishcode/lists-of-wits branch from f53bc1c to a598bb2 Compare August 26, 2025 16:56
Comment on lines +222 to +230
let mut main_packages = Vec::new();
for wit in &opts.wit {
let (pkg, _files) = resolve.push_path(wit)?;
main_packages.push(pkg);
}
Copy link
Member

Choose a reason for hiding this comment

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

Ah this reminds me one of the reasons I found this tricky to do before. The ideal implementation in my head is such that there's no order dependency of arguments on the CLI and the implementation internally would figure out how to slurp up all the WITs. As-implemented here, however, while later arguments could refer to WITs of earlier arguments it's not possible the other way around due to the explicit order of push_path.

Internally Resolve has everything necessary to do all the topo-sorting and everything, but it's not exposed currently through a push_many support or anything like that.

This is probably fine to have as a TODO, however, as this equally affects the paths argument in the Rust macro. Perhaps worth documenting though in the meantime and having an issue on wasm-tools to fill out at some point?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah. In my current use cases, this ordering requirement isn't a problem, but I agree we should think about lifting this requirement. I've now added documentation to this PR, and filed bytecodealliance/wasm-tools#2292.

@alexcrichton
Copy link
Member

I think you should be able to fix most CI by switching to a git dep instead of using [patch] (the test framework makes its own workspace effectively), but that'll probably cause the publish-related steps to fail.

Would you like to have a release of wasm-tools to keep on the path of integrating this?

@sunfishcode sunfishcode force-pushed the sunfishcode/lists-of-wits branch from a598bb2 to 67217f6 Compare August 26, 2025 17:51
Accept multiple WIT paths in the wit-bindgen CLI, using the same logic
as the multiple WIT paths accepted by the `path` parameter in the
Rust bindgen macro.

Also, document that list-of-WIT interfaces, in the Rust macro and now
the wit-bindgen CLI, have a topological ordering requirement which may
be lifted in the future.
@alexcrichton alexcrichton added this pull request to the merge queue Aug 26, 2025
Merged via the queue into bytecodealliance:main with commit 05249c3 Aug 26, 2025
20 checks passed
@sunfishcode sunfishcode deleted the sunfishcode/lists-of-wits branch September 1, 2025 18:59
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.

2 participants