-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #11705 - t-rapp:env-cargo-bin-name, r=epage
Set CARGO_BIN_NAME environment variable also for binary examples ### What does this PR try to resolve? The existing CARGO_BIN_NAME environment variable is useful when building command-line programs. It lets the command know its binary name, e.g. for printing out simple usage instructions. This PR extends the CARGO_BIN_NAME environment variable to be set when building binary example targets, additional to "normal" binary targets. Fixes #11689. ### How should we test and review this PR? Create a new binary project with `cargo new hello-env`. Add a new file "examples/foo-bar.rs" with the following lines: ``` fn main() { let program = env!("CARGO_BIN_NAME"); println!("{program}"); } ``` Building and running the example with `cargo run --example foo-bar` should print a line with the string "foo-bar". Note that this PR extends the existing testcase for the CARGO_BIN_NAME environment variable with an example target.
- Loading branch information
Showing
3 changed files
with
26 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters