Skip to content

Commit 28ec75e

Browse files
committed
collector: use patch instead of git apply
so it'll be possible to run collector inside of tarball
1 parent 2120e3b commit 28ec75e

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

collector/src/compile/benchmark/patch.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,19 @@ impl Patch {
6060
pub fn apply(&self, dir: &Path) -> anyhow::Result<()> {
6161
log::debug!("applying {} to {:?}", self.name, dir);
6262

63-
let mut cmd = Command::new("git");
64-
cmd.current_dir(dir).args(["apply"]).arg(&*self.path);
63+
// It's harder to use patch(1) in pure Windows MSVC toolchain
64+
let mut cmd = if cfg!(all(windows, target_env = "msvc")) {
65+
let mut command = Command::new("git");
66+
command.current_dir(dir).args(["apply"]).arg(&*self.path);
67+
command
68+
} else {
69+
let mut command = Command::new("patch");
70+
command
71+
.current_dir(dir)
72+
.args(["-p1", "-i"])
73+
.arg(&*self.path);
74+
command
75+
};
6576

6677
command_output(&mut cmd)?;
6778

0 commit comments

Comments
 (0)