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

metadata in library mode #23

Open
fruzitent opened this issue Mar 17, 2024 · 1 comment
Open

metadata in library mode #23

fruzitent opened this issue Mar 17, 2024 · 1 comment

Comments

@fruzitent
Copy link

When using Cargo multi-crate workspaces, cargo-run-bin will read metadata only from the root Cargo.toml

let toml_str: String = fs::read_to_string(get_project_root()?.join("Cargo.toml"))?.parse()?;

Would it be possible to limit scope to the current crate, so they can be feature-toggled?

Example

// ./bin/wasm-pack/src/main.rs
fn main() {
    let packages = cargo_run_bin::metadata::get_binary_packages().unwrap();
    let binary = packages.iter().find(|e| e.package == "wasm-pack").unwrap();
    let path = cargo_run_bin::binary::install(binary.clone()).unwrap();
    cargo_run_bin::binary::run(path.clone(), std::env::args().collect()).unwrap();
}
# ./bin/wasm-pack/Cargo.toml
[package]
name = "wasm-pack"
version = "0.1.0"
edition = "2021"

# TODO: this does not work
# [package.metadata.bin]
# wasm-pack = { version = "0.12.1" }

[dependencies]
cargo-run-bin.workspace = true
# ./Cargo.toml
[workspace]
default-members = []
members = ["./bin/wasm-pack/"]
resolver = "2"

[workspace.dependencies]
cargo-run-bin = { version = "1.7.2", default-features = false }

# TODO: this does work
[workspace.metadata.bin]
wasm-pack = { version = "0.12.1" }

image
image

@LuisDuarte1
Copy link

A small bump in this - I have kind of a big monorepo where the tools themselves can have different versions (due to forks, mostly). I'm fine with helping with this feature, what do you think @dustinblackman?

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