[rust] bindgen path supports env!() macro#1569
Open
kvcache wants to merge 1 commit intobytecodealliance:mainfrom
Open
[rust] bindgen path supports env!() macro#1569kvcache wants to merge 1 commit intobytecodealliance:mainfrom
kvcache wants to merge 1 commit intobytecodealliance:mainfrom
Conversation
This makes it possible to refer to a wit path by a path that includes things like OUT_DIR or CARGO_MANIFEST_DIR. Relative paths that navigate up, like `../wit/`, don't work well with cargo publish, and symlinks have difficulties between git and cargo. Using [macro-string](https://github.com/dtolnay/macro-string), this replaces the `path` option's `syn::LitStr` with MacroString.
Author
|
For context, this is the expression I'm able to compile locally with this change: wit_bindgen::generate!({
world: "momento:bytes/imports",
path: [ concat!(env!("OUT_DIR"), "/wit/host") ],
}); |
kvcache
added a commit
to kvcache/functions
that referenced
this pull request
Mar 14, 2026
The workspace folders aren't accessible at publish or docs.rs time. Pulling the wits into OUT_DIR makes them accessible to bindgen during those build phases. Depends on: bytecodealliance/wit-bindgen#1569
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This makes it possible to refer to a wit path by a path that includes
things like OUT_DIR or CARGO_MANIFEST_DIR. Relative paths that navigate
up, like
../wit/, don't work well with cargo publish, and symlinkshave difficulties between git and cargo.
Using macro-string, this replaces the
pathoption'ssyn::LitStrwith MacroString.See the example
crates/guest-rust/src/examples/_5_import_directory.rsforhow this can be used. I need this capability so I can write separate crates for
a partially inter-related set of WIT's without having to copy/paste the whole
WIT tree for each package.
Before:
error: expected string literalAfter: Example 5 compiles.