From e3354c1496a6fd6b80ad563712edb88b12bb7372 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauren=C8=9Biu=20Nicola?= Date: Fri, 1 Nov 2019 22:20:44 +0200 Subject: Use run-time project path in xtask --- xtask/src/lib.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'xtask/src/lib.rs') 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 @@ pub mod codegen; use std::{ + env, error::Error, fs, io::{Error as IoError, ErrorKind}, @@ -17,7 +18,13 @@ pub type Result = std::result::Result>; const TOOLCHAIN: &str = "stable"; pub fn project_root() -> PathBuf { - Path::new(&env!("CARGO_MANIFEST_DIR")).ancestors().nth(1).unwrap().to_path_buf() + Path::new( + &env::var("CARGO_MANIFEST_DIR").unwrap_or_else(|_| env!("CARGO_MANIFEST_DIR").to_owned()), + ) + .ancestors() + .nth(1) + .unwrap() + .to_path_buf() } pub struct Cmd<'a> { -- cgit v1.2.3