Skip to content

Commit

Permalink
Copy if AFLplusplus is not a git repository
Browse files Browse the repository at this point in the history
  • Loading branch information
smoelius committed Sep 2, 2022
1 parent 9bb8edb commit ff8d1c8
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Expand Up @@ -11,6 +11,7 @@ homepage = "https://github.com/rust-fuzz/afl.rs"
edition = "2018"

[build-dependencies]
fs_extra = "1.2"
rustc_version = "0.4"
tempfile = "3.3"
xdg = "2.4"
Expand Down
22 changes: 17 additions & 5 deletions build.rs
Expand Up @@ -17,11 +17,23 @@ fn main() {
let (work_dir, base) = if env::var("DOCS_RS").is_ok() {
let out_dir = env::var("OUT_DIR").unwrap();
let tempdir = tempfile::tempdir_in(&out_dir).unwrap();
let output = Command::new("git")
.args(["clone", AFL_SRC_PATH, &*tempdir.path().to_string_lossy()])
.output()
.expect("could not run 'git'");
assert!(output.status.success(), "{:#?}", output);
if Path::new(AFL_SRC_PATH).join(".git").is_dir() {
let output = Command::new("git")
.args(["clone", AFL_SRC_PATH, &*tempdir.path().to_string_lossy()])
.output()
.expect("could not run 'git'");
assert!(output.status.success(), "{:#?}", output);
} else {
fs_extra::dir::copy(
AFL_SRC_PATH,
tempdir.path(),
&fs_extra::dir::CopyOptions {
content_only: true,
..Default::default()
},
)
.unwrap();
}
(tempdir.into_path(), Some(PathBuf::from(out_dir)))
} else {
(PathBuf::from(AFL_SRC_PATH), None)
Expand Down

0 comments on commit ff8d1c8

Please sign in to comment.