aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2017-02-08 16:39:53 +0100
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2017-02-08 16:39:53 +0100
commit1dc554fafc8a97c211d35e7d756c04bc0dc93c1c (patch)
treed716055df4bbbab1ca14b2b4b482ddf7add41355
parenta3844f8ce58f16b6787f356e1adf5c7f59855ac2 (diff)
downloadaskama-1dc554fafc8a97c211d35e7d756c04bc0dc93c1c.tar.gz
askama-1dc554fafc8a97c211d35e7d756c04bc0dc93c1c.tar.bz2
askama-1dc554fafc8a97c211d35e7d756c04bc0dc93c1c.zip
Add build script to force rebuild on template changes
-rw-r--r--testing/Cargo.toml1
-rw-r--r--testing/build.rs26
2 files changed, 27 insertions, 0 deletions
diff --git a/testing/Cargo.toml b/testing/Cargo.toml
index 8e7c0f3..6acdaf5 100644
--- a/testing/Cargo.toml
+++ b/testing/Cargo.toml
@@ -3,6 +3,7 @@ name = "askama_testing"
version = "0.1.0"
authors = ["Dirkjan Ochtman <dirkjan@ochtman.nl>"]
workspace = ".."
+build = "build.rs"
[dependencies]
askama = { path = "../askama" }
diff --git a/testing/build.rs b/testing/build.rs
new file mode 100644
index 0000000..2f868f4
--- /dev/null
+++ b/testing/build.rs
@@ -0,0 +1,26 @@
+use std::env;
+use std::fs::{self, DirEntry};
+use std::io;
+use std::path::Path;
+
+fn visit_dirs(dir: &Path, cb: &Fn(&DirEntry)) -> io::Result<()> {
+ if dir.is_dir() {
+ for entry in try!(fs::read_dir(dir)) {
+ let entry = try!(entry);
+ let path = entry.path();
+ if path.is_dir() {
+ try!(visit_dirs(&path, cb));
+ } else {
+ cb(&entry);
+ }
+ }
+ }
+ Ok(())
+}
+
+fn main() {
+ let root = env::var("CARGO_MANIFEST_DIR").unwrap();
+ visit_dirs(&Path::new(&root).join("templates"), &|e: &DirEntry| {
+ println!("cargo:rerun-if-changed={}", e.path().to_str().unwrap());
+ }).unwrap();
+}