-
Notifications
You must be signed in to change notification settings - Fork 45
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
Use main binary if nothing else is specified #39
Comments
Thing is A simpler alternative may be to ship |
Was thinking about this issue today and realized that this statement:
is not true. What $ tree
.
├── Cargo.toml
├── examples
│ └── baz.rs
└── src
├── bin
│ └── bar.rs
├── lib.rs
└── main.rs
$ cargo build -v
Compiling foo v0.1.0 (/tmp/foo)
Running `rustc --edition=2018 --crate-name foo src/lib.rs --color always --crate-type lib --emit=dep-info,metadata,link -C debuginfo=2 -C metadata=71740c4f2a453aee -C extra-filename=-71740c4f2a453aee --out-dir /tmp/foo/target/debug/deps -C incremental=/tmp/foo/target/debug/incremental -L dependency=/tmp/foo/target/debug/deps`
Running `rustc --edition=2018 --crate-name foo src/main.rs --color always --crate-type bin --emit=dep-info,link -C debuginfo=2 -C metadata=5d315b79c4d3a0f2 -C extra-filename=-5d315b79c4d3a0f2 --out-dir /tmp/foo/target/debug/deps -C incremental=/tmp/foo/target/debug/incremental -L dependency=/tmp/foo/target/debug/deps --extern foo=/tmp/foo/target/debug/deps/libfoo-71740c4f2a453aee.rlib`
Running `rustc --edition=2018 --crate-name bar src/bin/bar.rs --color always --crate-type bin --emit=dep-info,link -C debuginfo=2 -C metadata=22dbb2ea0ec0271e -C extra-filename=-22dbb2ea0ec0271e --out-dir /tmp/foo/target/debug/deps -C incremental=/tmp/foo/target/debug/incremental -L dependency=/tmp/foo/target/debug/deps --extern foo=/tmp/foo/target/debug/deps/libfoo-71740c4f2a453aee.rlib`
Finished dev [unoptimized + debuginfo] target(s) in 0.31s
$ cargo check -v
cargo check -v
Checking foo v0.1.0 (/tmp/foo)
Running `rustc --edition=2018 --crate-name foo src/lib.rs --color always --crate-type lib --emit=dep-info,metadata -C debuginfo=2 -C metadata=4af807af49468713 -C extra-filename=-4af807af49468713 --out-dir /tmp/foo/target/debug/deps -C incremental=/tmp/foo/target/debug/incremental -L dependency=/tmp/foo/target/debug/deps`
Running `rustc --edition=2018 --crate-name foo src/main.rs --color always --crate-type bin --emit=dep-info,metadata -C debuginfo=2 -C metadata=3fc606d28351772e -C extra-filename=-3fc606d28351772e --out-dir /tmp/foo/target/debug/deps -C incremental=/tmp/foo/target/debug/incremental -L dependency=/tmp/foo/target/debug/deps --extern foo=/tmp/foo/target/debug/deps/libfoo-4af807af49468713.rmeta`
Running `rustc --edition=2018 --crate-name bar src/bin/bar.rs --color always --crate-type bin --emit=dep-info,metadata -C debuginfo=2 -C metadata=09a17f670d00aa41 -C extra-filename=-09a17f670d00aa41 --out-dir /tmp/foo/target/debug/deps -C incremental=/tmp/foo/target/debug/incremental -L dependency=/tmp/foo/target/debug/deps --extern foo=/tmp/foo/target/debug/deps/libfoo-4af807af49468713.rmeta`
Finished dev [unoptimized + debuginfo] target(s) in 0.12s So before this can be implemented it needs to be defined what a Cargo subcommand should do on a Cargo project like the one shown above. Run the llvm tool on all the artifacts? With the exact same user arguments? That wouldn't make much sense for subcommands like |
Fair enough, but isn't the interesting question what |
Is it? In my example, it throws an error: $ cargo run -v
error: `cargo run` could not determine which binary to run. Use the `--bin` option to specify a binary, or (on nightly) the `default-run` manifest key.
available binaries: foo, bar The |
Yes, that's exactly what we want. If there's no choice, do the obvious thing; if there is a choice, explain the options. |
This has been fixed in release 0.2.0. |
Usually a
cargo
command will automatically use the main binary if no binary or example is specified. This does not work forcargo-binutils
and instead requires to specify the binary name which for a single binary crate is the project name and thus a bit clunky.The text was updated successfully, but these errors were encountered: