Skip to content

Commit 5f38961

Browse files
authored
Use local directories when building for docs.rs (#185)
I haven't tested it, but this code should be enough to get `afl` to compile for docs.rs See https://docs.rs/crate/afl/0.10.0/builds/351937 for the current errors.
1 parent aad1eec commit 5f38961

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/common.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,29 @@ fn pkg_version() -> String {
3232
ret
3333
}
3434

35+
// Place directories inside the crate when building for docs.rs.
36+
// (Modifying system paths are forbidden.)
37+
38+
#[cfg(docsrs)]
39+
pub fn afl_dir() -> PathBuf {
40+
let path = PathBuf::from("./afl");
41+
std::fs::create_dir_all(&path).unwrap();
42+
path
43+
}
44+
45+
#[cfg(not(docsrs))]
3546
pub fn afl_dir() -> PathBuf {
3647
xdg_dir().create_data_directory("afl").unwrap()
3748
}
3849

50+
#[cfg(docsrs)]
51+
pub fn afl_llvm_rt_dir() -> PathBuf {
52+
let path = PathBuf::from("./afl-llvm-rt");
53+
std::fs::create_dir_all(&path).unwrap();
54+
path
55+
}
56+
57+
#[cfg(not(docsrs))]
3958
pub fn afl_llvm_rt_dir() -> PathBuf {
4059
xdg_dir().create_data_directory("afl-llvm-rt").unwrap()
4160
}

0 commit comments

Comments
 (0)