Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support nested vendored dependencies in bindgen! #9303

Open
MarinPostma opened this issue Sep 24, 2024 · 2 comments
Open

Support nested vendored dependencies in bindgen! #9303

MarinPostma opened this issue Sep 24, 2024 · 2 comments

Comments

@MarinPostma
Copy link

Thanks for filing a feature request! Please fill out the TODOs below.

Feature

It seems that the only way to import other packages right now is to vendor them, so I tried to do that by symlinking the dependee
into the dependant deps folder (showing dirs only for conciseness):

❯ tree -d -l wit
wit
└── deps -> ../../wasi-http/wit
   └── deps
       ├── cli
       ├── clocks
       ├── filesystem
       ├── io
       ├── random
       └── sockets

Then i attempt to generate bindings like so:

bindgen!({
    path: "../adhoc/wit",
    with: {
        "wasi:http/[email protected]": http_proxy,
    }
});

and I get the following compile error:

error: failed to resolve directory while parsing WIT for path [/Users/mpostma/Documents/code/rust/wasm-experiments/adhoc/wit]

       Caused by:
           0: failed to parse dependency directory: /Users/mpostma/Documents/code/rust/wasm-experiments/adhoc/wit/deps
           1: failed to parse package: /Users/mpostma/Documents/code/rust/wasm-experiments/adhoc/wit/deps/deps
           2: no `package` header was found in any WIT file for this package

It seems to be because the second level of deps doesn't contain any WIT file, but only directories.

Benefit

I'm not sure what's the current plan, or the recommended way to deal with imports right now. I suspect that all of this will converge to a more streamlined experience, but until then, it would be nice if we could just symlink components as dependency for other components.

@alexcrichton
Copy link
Member

Thanks for the report! The structure of the wit directory is mostly defined by the wasm-tools project at this time (and doesn't have the greatest documentation unfortunately). You might be interested in bytecodealliance/wasm-tools#1461 and bytecodealliance/wasm-tools#1462 as well.

Overall relaxing various bits of the wit directory are not the easiest thing to do as it needs to be balanced with the variety of consumers of WIT. If possible features like #9288 are intended to help with this, though.

@MarinPostma
Copy link
Author

thanks @alexcrichton 🙏

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

No branches or pull requests

2 participants