How to describe dependencies on local packages with relative path

Offen
#120 10 Kommentare 2 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Anfängerfreundlichkeit
30/100
Issue-Typ
Dokumentation
Klarheit
Muss geklärt werden
Aktivitätsstatus
Veraltet
Tech-Stack
rust, wasm
Bereich
build-system, cli

Rechercherichtung

Beginne mit crates/core/src/registry.rs etwa in den Zeilen 394-402 und reproduziere den gemeldeten Befehl unter Verwendung des verlinkten wasm-component-example-Repositorys. Verfolge, wie die relative Abhängigkeit interpretiert wird, und dokumentiere die unterstützte Cargo.toml-Form sowie den erwarteten Abhängigkeitstyp, einschließlich dessen, wie ein erfolgreicher Abschluss aussehen sollte.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

Hello developers,

I'm trying to understand Component Model with cargo-component. To that end I have tried to create a simple example, but I have the following error and would like to discuss it if you allow me to do it here.

$ cargo component build --release
error: failed to create a target world for package `comp2` (/workspaces/wasm-component-example/comp2/Cargo.toml)

Caused by:
    0: failed to decode component dependency `newgyu:comp1`
    1: dependency is not a WebAssembly component

cargo-component version is here.

 $ cargo component --version
cargo-component-component 0.1.0 (6af088a 2023-08-16 wasi:2750b73)

My example and what I expect

https://github.com/NewGyu/wasm-component-example

image

There are two packages, then each package has a world.

  • newgyu:comp1/random-generator
    • rand func is exported.
  • newgyu:comp2/hello
    • hello-world func is exported, and that depends on rand func that is provided by newgyu:comp1.
Directory structures
$ tree -L 2.
.
├── comp1
│   ├── Cargo.toml
│   ├── src
│   │      └── lib.rs
│   └── wit
│           └── world.wit
├── comp2
│   ├── Cargo.toml
│   ├── src
│   │      └── lib.rs
│   └── wit
│           └── world.wit
Code
comp2

comp2 is specifying a dependency on comp1 as local package reference.

[package]
name = "comp2"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
cargo-component-bindings = { git = "https://github.com/bytecodealliance/cargo-component" }

[lib]
crate-type = ["cdylib"]

[package.metadata.component]
package = "newgyu:comp2"

[package.metadata.component.target]
path = "wit"

[package.metadata.component.dependencies]
"newgyu:comp1" = { path = "../comp1/wit/world.wit" }
comp1

comp1 could be built with cargo component build --release. The followings have been built.

  • target/bindings/comp1/target.wasm
  • target/bindings/comp1/world
  • target/wasm32-wasi/release/comp1.wasm
[package]
name = "comp1"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
cargo-component-bindings = { git = "https://github.com/bytecodealliance/cargo-component" }

[lib]
crate-type = ["cdylib"]

[package.metadata.component]
package = "newgyu:comp1"

[package.metadata.component.target]
path = "wit"
world = "random-generator"

[package.metadata.component.dependencies]

Points I would like to ask about

  • Is it correct tow to describe dependencies on local packages with relative path ?
  • Is the dependency type handled as Wit when described as above ?
    • Why does into_component_world respond error?
    • Should I explicitly specify Wasm as the dependency type? How to specify that in Cargo.toml?

https://github.com/bytecodealliance/cargo-component/blob/3f36696db9c39785886b0766b2b81f83cbc3d29e/crates/core/src/registry.rs#L394-L402

Vorherrschende Sprache
Rust
Sterne
593
Forks
68
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Entwicklungsumgebung

Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus bytecodealliance/cargo-component

Alle Issues in bytecodealliance/cargo-component

Ähnliche Issues

Weitere Issues zu Rust

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.