diff options
| author | Edvard Thörnros <edvard.thornros@gmail.com> | 2021-03-01 19:57:59 +0100 |
|---|---|---|
| committer | Edvard Thörnros <edvard.thornros@gmail.com> | 2021-03-01 19:57:59 +0100 |
| commit | d90db967bcc46ef4ae3d8d25755655da5b578073 (patch) | |
| tree | 14e38537683c6dd67ae5fd2f0e78a76c362ccdbe /build.rs | |
| parent | 9415c7db1cd00b530f82f673efc32a459a4ae789 (diff) | |
| download | sylt-d90db967bcc46ef4ae3d8d25755655da5b578073.tar.gz | |
reading all scripts into a variable
Diffstat (limited to 'build.rs')
| -rw-r--r-- | build.rs | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..92b63ab --- /dev/null +++ b/build.rs @@ -0,0 +1,28 @@ +use std::path::{Path, PathBuf}; + +fn find_tests(directory: &Path) -> Vec<PathBuf> { + let mut tests = Vec::new(); + + for entry in std::fs::read_dir(directory).unwrap() { + let path = entry.unwrap().path(); + + if path.file_name().unwrap().to_str().unwrap().starts_with("_") { + continue; + } + + if path.is_dir() { + tests.append(&mut find_tests(&path)); + } else { + assert!(!path.to_str().unwrap().contains(","), "You should be ashamed."); + tests.push(path); + } + } + + tests +} + +fn main() { + let tests = find_tests(Path::new("progs/")); + let files = tests.iter().fold(String::new(), |a, b| format!("{},{}", a, b.display())); + println!("cargo:rustc-env=SCRIPTS={}", &files[1..]); +} |
