-
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 #8270 - reggaemuffin:8251-binary-name-env-var, r=ehuss
Add environment variables to identify the binary and crate name Closes #8251 This adds `CARGO_BIN_NAME` and `CARGO_CRATE_NAME` to rustc/rustdoc process env. `CARGO_BIN_NAME` is added for binary compilation units, `CARGO_CRATE_NAME` is added for binary and library units. The `build::crate_env_vars` test was updated to test for this. The test is currently only checking behavior for the binary compile unit. Documentation was updated to reflect the added environment variables.
- Loading branch information
Showing
3 changed files
with
27 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1230,6 +1230,10 @@ fn crate_env_vars() { | |
homepage = "https://example.com" | ||
repository = "https://example.com/repo.git" | ||
authors = ["[email protected]"] | ||
[[bin]] | ||
name = "foo-bar" | ||
path = "src/main.rs" | ||
"#, | ||
) | ||
.file( | ||
|
@@ -1248,6 +1252,9 @@ fn crate_env_vars() { | |
static HOMEPAGE: &'static str = env!("CARGO_PKG_HOMEPAGE"); | ||
static REPOSITORY: &'static str = env!("CARGO_PKG_REPOSITORY"); | ||
static DESCRIPTION: &'static str = env!("CARGO_PKG_DESCRIPTION"); | ||
static BIN_NAME: &'static str = env!("CARGO_BIN_NAME"); | ||
static CRATE_NAME: &'static str = env!("CARGO_CRATE_NAME"); | ||
fn main() { | ||
let s = format!("{}-{}-{} @ {} in {}", VERSION_MAJOR, | ||
|
@@ -1256,6 +1263,8 @@ fn crate_env_vars() { | |
assert_eq!(s, foo::version()); | ||
println!("{}", s); | ||
assert_eq!("foo", PKG_NAME); | ||
assert_eq!("foo-bar", BIN_NAME); | ||
assert_eq!("foo_bar", CRATE_NAME); | ||
assert_eq!("https://example.com", HOMEPAGE); | ||
assert_eq!("https://example.com/repo.git", REPOSITORY); | ||
assert_eq!("This is foo", DESCRIPTION); | ||
|
@@ -1284,7 +1293,7 @@ fn crate_env_vars() { | |
p.cargo("build -v").run(); | ||
|
||
println!("bin"); | ||
p.process(&p.bin("foo")) | ||
p.process(&p.bin("foo-bar")) | ||
.with_stdout("0-5-1 @ alpha.1 in [CWD]") | ||
.run(); | ||
|
||
|