Automatic Dependency Screening and Patching
theduke opened this issue · 0 comments
theduke commented
Problem Statement
Currently many common crates are not compatible with WASIX and require forks to work properly.
This results in a very suboptimal user experience.
cargo wasix
should check for the presence of such dependencies in Cargo.lock
, and either apply automatic fixes or inform the user.
This should apply to cargo wasix {check,build,run}
.
Implementation
cargo wasix {check,build,run}
should:
- make sure the
Cargo.lock
has been generated - Check the
Cargo.lock
for well-known incompatible crates - In case a fork exists:
automatically extend the[patch.crates-io]
section with the appropriate patches - In case no fork exists:
Fail the build with a concrete error, likecrate XXX is not compatible with WASIX yet
Care must be taken to pick branches that match the semver constraints for the patches, otherwise the patch will just be silently ignored.
List of crates
- https://github.com/wasix-org/libc
- https://github.com/wasix-org/socket2
- https://github.com/wasix-org/tokio
- https://github.com/wasix-org/mio
- ...
Example
A good example is the WASIX Axum example found here: http://wasix.org/docs/language-guide/rust/tutorials/wasix-axum
It requires the below Cargo.toml to work properly:
[package]
name = "wasix-axum"
version = "0.1.0"
edition = "2021"
[dependencies]
axum = { version = "=0.6.9", features = ["tokio"] } # ← Updated Line
tokio = { version = "=1.24.2", default-features = false, features = ["full"] } # ← Updated Line
parking_lot = { version = "=0.12.1", features = ["nightly"] } # ← Added Line
[patch.crates-io]
socket2 = { git = "https://github.com/wasix-org/socket2.git", branch = "v0.4.7" } # ← Added Line
libc = { git = "https://github.com/wasix-org/libc.git" } # ← Added Line
tokio = { git = "https://github.com/wasix-org/tokio.git", branch = "wasix-1.24.2" }