diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-11-01 20:25:17 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2019-11-01 20:25:17 +0000 |
commit | eb8f76a86fe88fcad370577b344f397dd6118cfd (patch) | |
tree | 15d83ef7447ab95014047985dddbf1ff3c529e7b /xtask/src | |
parent | 9db97820f4c1c38110175f4efda2702356a4199a (diff) | |
parent | e3354c1496a6fd6b80ad563712edb88b12bb7372 (diff) |
Merge #2152
2152: Use run-time project path in xtask r=matklad a=lnicola
Fixes #2131.
Co-authored-by: Laurențiu Nicola <[email protected]>
Diffstat (limited to 'xtask/src')
-rw-r--r-- | xtask/src/lib.rs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/xtask/src/lib.rs b/xtask/src/lib.rs index cc69463a9..bae4c4650 100644 --- a/xtask/src/lib.rs +++ b/xtask/src/lib.rs | |||
@@ -3,6 +3,7 @@ | |||
3 | pub mod codegen; | 3 | pub mod codegen; |
4 | 4 | ||
5 | use std::{ | 5 | use std::{ |
6 | env, | ||
6 | error::Error, | 7 | error::Error, |
7 | fs, | 8 | fs, |
8 | io::{Error as IoError, ErrorKind}, | 9 | io::{Error as IoError, ErrorKind}, |
@@ -17,7 +18,13 @@ pub type Result<T> = std::result::Result<T, Box<dyn Error>>; | |||
17 | const TOOLCHAIN: &str = "stable"; | 18 | const TOOLCHAIN: &str = "stable"; |
18 | 19 | ||
19 | pub fn project_root() -> PathBuf { | 20 | pub fn project_root() -> PathBuf { |
20 | Path::new(&env!("CARGO_MANIFEST_DIR")).ancestors().nth(1).unwrap().to_path_buf() | 21 | Path::new( |
22 | &env::var("CARGO_MANIFEST_DIR").unwrap_or_else(|_| env!("CARGO_MANIFEST_DIR").to_owned()), | ||
23 | ) | ||
24 | .ancestors() | ||
25 | .nth(1) | ||
26 | .unwrap() | ||
27 | .to_path_buf() | ||
21 | } | 28 | } |
22 | 29 | ||
23 | pub struct Cmd<'a> { | 30 | pub struct Cmd<'a> { |