Skip to content

Commit ff8d1c8

Browse files
committedSep 2, 2022
Copy if AFLplusplus is not a git repository
1 parent 9bb8edb commit ff8d1c8

File tree

3 files changed

+25
-5
lines changed

3 files changed

+25
-5
lines changed
 

‎Cargo.lock

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ homepage = "https://github.com/rust-fuzz/afl.rs"
1111
edition = "2018"
1212

1313
[build-dependencies]
14+
fs_extra = "1.2"
1415
rustc_version = "0.4"
1516
tempfile = "3.3"
1617
xdg = "2.4"

‎build.rs

+17-5
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,23 @@ fn main() {
1717
let (work_dir, base) = if env::var("DOCS_RS").is_ok() {
1818
let out_dir = env::var("OUT_DIR").unwrap();
1919
let tempdir = tempfile::tempdir_in(&out_dir).unwrap();
20-
let output = Command::new("git")
21-
.args(["clone", AFL_SRC_PATH, &*tempdir.path().to_string_lossy()])
22-
.output()
23-
.expect("could not run 'git'");
24-
assert!(output.status.success(), "{:#?}", output);
20+
if Path::new(AFL_SRC_PATH).join(".git").is_dir() {
21+
let output = Command::new("git")
22+
.args(["clone", AFL_SRC_PATH, &*tempdir.path().to_string_lossy()])
23+
.output()
24+
.expect("could not run 'git'");
25+
assert!(output.status.success(), "{:#?}", output);
26+
} else {
27+
fs_extra::dir::copy(
28+
AFL_SRC_PATH,
29+
tempdir.path(),
30+
&fs_extra::dir::CopyOptions {
31+
content_only: true,
32+
..Default::default()
33+
},
34+
)
35+
.unwrap();
36+
}
2537
(tempdir.into_path(), Some(PathBuf::from(out_dir)))
2638
} else {
2739
(PathBuf::from(AFL_SRC_PATH), None)

0 commit comments

Comments
 (0)
Please sign in to comment.