Skip to content

Commit

Permalink
Auto merge of #6096 - mathstuf:export-repository-info, r=alexcrichton
Browse files Browse the repository at this point in the history
build: export repository information

The repository string is made available via the `CARGO_PKG_REPOSITORY`
environment variable similar to other metadata.
  • Loading branch information
bors committed Oct 12, 2018
2 parents 9801c50 + ae6b2f6 commit 5fc8ac7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/cargo/core/compiler/compilation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,10 @@ impl<'cfg> Compilation<'cfg> {
"CARGO_PKG_HOMEPAGE",
metadata.homepage.as_ref().unwrap_or(&String::new()),
)
.env(
"CARGO_PKG_REPOSITORY",
metadata.repository.as_ref().unwrap_or(&String::new()),
)
.env("CARGO_PKG_AUTHORS", &pkg.authors().join(":"))
.cwd(pkg.root());
Ok(cmd)
Expand Down
5 changes: 3 additions & 2 deletions src/doc/src/reference/environment-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,9 @@ let version = env!("CARGO_PKG_VERSION");
* `CARGO_PKG_VERSION_PRE` - The pre-release version of your package.
* `CARGO_PKG_AUTHORS` - Colon separated list of authors from the manifest of your package.
* `CARGO_PKG_NAME` - The name of your package.
* `CARGO_PKG_DESCRIPTION` - The description of your package.
* `CARGO_PKG_HOMEPAGE` - The home page of your package.
* `CARGO_PKG_DESCRIPTION` - The description from the manifest of your package.
* `CARGO_PKG_HOMEPAGE` - The home page from the manifest of your package.
* `CARGO_PKG_REPOSITORY` - The repository from the manifest of your package.
* `OUT_DIR` - If the package has a build script, this is set to the folder where the build
script should place its output. See below for more information.

Expand Down
3 changes: 3 additions & 0 deletions tests/testsuite/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1368,6 +1368,7 @@ fn crate_env_vars() {
version = "0.5.1-alpha.1"
description = "This is foo"
homepage = "http://example.com"
repository = "http://example.com/repo.git"
authors = ["[email protected]"]
"#,
).file(
Expand All @@ -1384,6 +1385,7 @@ fn crate_env_vars() {
static CARGO_MANIFEST_DIR: &'static str = env!("CARGO_MANIFEST_DIR");
static PKG_NAME: &'static str = env!("CARGO_PKG_NAME");
static HOMEPAGE: &'static str = env!("CARGO_PKG_HOMEPAGE");
static REPOSITORY: &'static str = env!("CARGO_PKG_REPOSITORY");
static DESCRIPTION: &'static str = env!("CARGO_PKG_DESCRIPTION");
fn main() {
Expand All @@ -1394,6 +1396,7 @@ fn crate_env_vars() {
println!("{}", s);
assert_eq!("foo", PKG_NAME);
assert_eq!("http://example.com", HOMEPAGE);
assert_eq!("http://example.com/repo.git", REPOSITORY);
assert_eq!("This is foo", DESCRIPTION);
let s = format!("{}.{}.{}-{}", VERSION_MAJOR,
VERSION_MINOR, VERSION_PATCH, VERSION_PRE);
Expand Down

0 comments on commit 5fc8ac7

Please sign in to comment.