Description
openedon Nov 19, 2020
Describe the problem you are trying to solve
I have a build.rs
file using a rust cli program. For simplicity of use for other developers I would like the cli program to automatically be installed when building, but I don't want to run cargo commands to do so, as this will ignore their wishes (such as --offline
or --locked
).
Describe the solution you'd like
I would like to be able to install bin programs in the Cargo.toml
. Suggestions:
[build-dependencies]
some_cli_program = { version = "1.0", install_binaries = true }
[build-bin-dependencies]
some_cli_program = "1.0"
Notes
There are some obvious issues here. This program will be added to the users PATH (which should not be done automatically by a simple build) and risk colliding with other programs in .cargo/bin
. A nice way of solving this would be that the binary isn't installed in .cargo/bin
but in <target>/build/bin
and are executed by running cargo build-dep [flags] <program-name> [args...]
or $CARGO_TARGET_DIR/build/bin/<program-name>
. This means that the function build-dep
or the inclusion of $CARGO_TARGET_DIR
as input to build.rs
would also have to be included in this ticket.
This could be solved by running cargo install some_cli_program --root .dependencies/
in build.rs
, but this will not reuse any build progress of dependencies shared with the libraries built for the project (which in my case would be almost all of them), and it will update crates.io every time it's run.