qryxip / cargo-equip

A Cargo subcommand to bundle your code into one `.rs` file for competitive programming
Apache License 2.0
76 stars 10 forks source link

Failure to bundle duplicate named targets under Virtual Workspace #204

Open tayu0110 opened 6 months ago

tayu0110 commented 6 months ago

I always use cargo-eqiup for competitive programming contests.

I want to make the following workspace

$ tree -I "target" .
.
├── Cargo.lock
├── Cargo.toml
├── first-crate
│   ├── Cargo.toml
│   └── src
│       ├── bin
│       │   └── a.rs
│       └── main.rs
└── second-crate
    ├── Cargo.toml
    └── src
        ├── bin
        │   └── a.rs
        └── main.rs
$ cat ./Cargo.toml
[workspace]
members = ["first-crate", "second-crate"]
resolver = "2"

first-crate and second-crate are the crates for each contests.

In first-crate (or second-crate), when I execute cargo equip --bin a, the following result appears.

error: multiple bin targets named `a` in this workspace

On the other hand, cargo run --bin a and cargo build --bin a succeed.
Is this expected behavior ?

If not, I would like suggest the following change

It seems that cargo run selects the targets in the current package, if neither --package, --exclude, --workspace nor --all flags are specified.
Since cargo-equip does not have these flags, I believe the natural behavior would be to select targets only from the current package rather than scanning all members in the workspace.

Thank you for your confirming.
Best Regard.

My Environment

$ cargo --version
cargo 1.75.0 (1d8b05cdd 2023-11-20)
$ rustc --version
rustc 1.75.0 (82e1608df 2023-12-21)
$ cargo equip --version
cargo-equip 0.20.1