Skip to content

Commit 073b903

Browse files
Nemo157Joshua Nelson
authored andcommitted
Use walkdir to ensure all style files trigger rebuilding
1 parent 1d3d23a commit 073b903

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ time = "0.1"
100100
git2 = { version = "0.13", default-features = false }
101101
sass-rs = "0.2.2"
102102
string_cache_codegen = "0.5.1"
103+
walkdir = "2"
103104

104105
[[bench]]
105106
name = "html_parsing"

build.rs

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,6 @@ use git2::Repository;
22
use std::{env, error::Error, fs::File, io::Write, path::Path};
33

44
fn main() {
5-
// Don't rerun anytime a single change is made
6-
println!("cargo:rerun-if-changed=templates/style/vendored.scss");
7-
println!("cargo:rerun-if-changed=templates/style/base.scss");
8-
println!("cargo:rerun-if-changed=templates/style/_rustdoc.scss");
9-
println!("cargo:rerun-if-changed=templates/style/_vars.scss");
10-
println!("cargo:rerun-if-changed=templates/style/_utils.scss");
11-
println!("cargo:rerun-if-changed=templates/style/_navbar.scss");
12-
println!("cargo:rerun-if-changed=templates/style/_themes.scss");
13-
println!("cargo:rerun-if-changed=vendor/");
14-
// TODO: are these right?
15-
println!("cargo:rerun-if-changed=.git/HEAD");
16-
println!("cargo:rerun-if-changed=.git/index");
17-
185
write_git_version();
196
if let Err(sass_err) = compile_sass() {
207
panic!("Error compiling sass: {}", sass_err);
@@ -31,6 +18,10 @@ fn write_git_version() {
3118

3219
let mut file = File::create(&dest_path).unwrap();
3320
write!(file, "({} {})", git_hash, build_date).unwrap();
21+
22+
// TODO: are these right?
23+
println!("cargo:rerun-if-changed=.git/HEAD");
24+
println!("cargo:rerun-if-changed=.git/index");
3425
}
3526

3627
fn get_git_hash() -> Option<String> {
@@ -59,6 +50,12 @@ fn compile_sass_file(
5950
paths
6051
};
6152

53+
for path in &include_paths {
54+
for entry in walkdir::WalkDir::new(path) {
55+
println!("cargo:rerun-if-changed={}", entry?.path().display());
56+
}
57+
}
58+
6259
// Compile base.scss
6360
let mut context = Context::new_file(format!("{}/{}.scss", STYLE_DIR, name))?;
6461
context.set_options(Options {

0 commit comments

Comments
 (0)