cargo-component icon indicating copy to clipboard operation
cargo-component copied to clipboard

request: Support multiple package in a single WIT

Open Mossaka opened this issue 1 year ago • 4 comments

relevent upstream work:

https://github.com/bytecodealliance/wasm-tools/pull/1577 https://github.com/bytecodealliance/wit-bindgen/pull/978

It seems like the latest research of cargo-component does not support multi-packages in WITs.

Caused by:
    0: failed to parse local target from directory `/Users/mossaka/Developer/mossaka/hello-component-wasi-http-part2/wit`
    1: expected ';', found '{'
            --> /Users/mossaka/Developer/mossaka/hello-component-wasi-http-part2/wit/wasi_http.wit:1:23
             |
           1 | package wasi:[email protected] {
             |                       ^
(base) ➜  hello-component-wasi-http-part2 

Mossaka avatar Jul 28 '24 20:07 Mossaka

I am happy to take a look at this

kate-goldenring avatar Aug 30 '24 16:08 kate-goldenring

Also happy to help out with this. I helped a bit with some of the more recent changes for multi-package WIT stuff. I wouldn't be surprised if there are additional changes that need to be made in wit-bindgen.

macovedj avatar Sep 11 '24 15:09 macovedj

Also looking again, I'm curious if the example was written before or after this change. It looks like this example may not have a root package declaration, which is required after the linked change.

macovedj avatar Sep 11 '24 18:09 macovedj

It may have been from before; however, even with the root package declaration, cargo component fails to compile the app, in part because it assumes the name of each dependency is that of the package group's root package: https://github.com/bytecodealliance/cargo-component/blob/faf251f74909f086ae3ef85858e11c612ae25b94/crates/core/src/registry.rs#L387

error: failed to create a target world for package `baz` (/Users/kagold/Programs/cargo-component/_scratch/baz/Cargo.toml)

Caused by:
    duplicate definitions of package `root:root` found while decoding target dependency `bar:baz`

kate-goldenring avatar Sep 11 '24 20:09 kate-goldenring