Skip to content

Commit 8629e9c

Browse files
committed
fix: Do not resolve build-dir if template variables are present
1 parent 15cc626 commit 8629e9c

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/easy.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,9 @@ pub struct BuildConfig {
514514
/// specified is the value of build.target-dir
515515
///
516516
/// [Cargo Reference](https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#build-dir)
517+
///
518+
/// **Note:** If a template variable is used the path will be unresolved. For available template
519+
/// variables see the Cargo reference.
517520
#[cfg(feature = "unstable")]
518521
#[serde(skip_serializing_if = "Option::is_none")]
519522
pub build_dir: Option<PathBuf>,
@@ -582,7 +585,16 @@ impl BuildConfig {
582585
});
583586
let target_dir = de.target_dir.map(|v| v.resolve_as_path(current_dir).into_owned());
584587
#[cfg(feature = "unstable")]
585-
let build_dir = de.build_dir.map(|v| v.resolve_as_path(current_dir).into_owned());
588+
let build_dir = de.build_dir.map(|v| {
589+
if v.val.starts_with("{workspace-root}")
590+
|| v.val.starts_with("{cargo-cache-home}")
591+
|| v.val.contains("{workspace-path-hash}")
592+
{
593+
return PathBuf::from(v.val);
594+
}
595+
596+
v.resolve_as_path(current_dir).into_owned()
597+
});
586598
let de_rustflags = de.rustflags.clone();
587599
let rustflags =
588600
de.rustflags.map(|v| Flags { flags: v.flags.into_iter().map(|v| v.val).collect() });

0 commit comments

Comments
 (0)