Hi!
I'd like to suggest that we should add --output-path option to certain Cargo commands, to make it easier to use Cargo as a part of the larger build system.
Currently, the way to get output artifacts location is to run cargo build --message-format=json and parse the resulting JSON. This is very convenient if you want to "enhance" the stuff that Cargo does. For example, IntelliJ Rust uses this feature to learn what binaries it should launch via debugger.
However, this does not work well for the case where you use Cargo as a part of larger build, and are interested only in the artifact. The main drawback here is that parsing the JSON is not that easy.
Here some implementation considerations:
- Cargo should still put all stuff into
target as usual, --output-path is only a copy at the end
- The flag works only when the build produces a single artifact. That is, you'll need
--bin name sort flags for disambiguation.
- The flag definitely should work for
cdylib, clib and bin crate types. Not sure if we'd want to support rlibs.
- It's not clear what to do with extensions. Do we add
.exe on windows automatically? Or do we use the path as-is? I think the letter is preferable.
- It's not clear what to do if the artifact consists of several files (i.e, debug info on Macs is in a separate file). Should we just place it alongside? Should we add more config?
Issue inspired by this discussion on Gitter: https://gitter.im/rust-lang/rust?at=5a468c4b0163b028108fe9b6
Hi!
I'd like to suggest that we should add
--output-pathoption to certain Cargo commands, to make it easier to use Cargo as a part of the larger build system.Currently, the way to get output artifacts location is to run
cargo build --message-format=jsonand parse the resulting JSON. This is very convenient if you want to "enhance" the stuff that Cargo does. For example, IntelliJ Rust uses this feature to learn what binaries it should launch via debugger.However, this does not work well for the case where you use Cargo as a part of larger build, and are interested only in the artifact. The main drawback here is that parsing the JSON is not that easy.
Here some implementation considerations:
targetas usual,--output-pathis only a copy at the end--bin namesort flags for disambiguation.cdylib,clibandbincrate types. Not sure if we'd want to support rlibs..exeon windows automatically? Or do we use the path as-is? I think the letter is preferable.Issue inspired by this discussion on Gitter: https://gitter.im/rust-lang/rust?at=5a468c4b0163b028108fe9b6