Skip to content

Commit bc1a4e3

Browse files
committed
Fix build.rs to rebuild if the Python script changes
1 parent 32d40b2 commit bc1a4e3

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

rust/tvm/examples/resnet/build.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,25 @@ use std::{io::Write, path::Path, process::Command};
2222

2323
fn main() -> Result<()> {
2424
let out_dir = std::env::var("CARGO_MANIFEST_DIR")?;
25+
let python_script = concat!(env!("CARGO_MANIFEST_DIR"), "/src/build_resnet.py");
26+
let synset_txt = concat!(env!("CARGO_MANIFEST_DIR"), "/synset.txt");
27+
28+
println!("cargo:rerun-if-changed={}", python_script);
29+
println!("cargo:rerun-if-changed={}", synset_txt);
30+
2531
let output = Command::new("python3")
26-
.arg(concat!(env!("CARGO_MANIFEST_DIR"), "/src/build_resnet.py"))
32+
.arg(python_script)
2733
.arg(&format!("--build-dir={}", out_dir))
2834
.output()
2935
.with_context(|| anyhow::anyhow!("failed to run python3"))?;
36+
3037
if !output.status.success() {
3138
std::io::stdout()
3239
.write_all(&output.stderr)
3340
.context("Failed to write error")?;
3441
panic!("Failed to execute build script");
3542
}
43+
3644
assert!(
3745
Path::new(&format!("{}/deploy_lib.o", out_dir)).exists(),
3846
"Could not prepare demo: {}",

rust/tvm/examples/resnet/src/build_resnet.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,9 @@ def download_img_labels():
115115
f.write(synset[key])
116116
f.write("\n")
117117

118+
print(synset_path)
119+
print(synset_name)
120+
118121
return synset
119122

120123

0 commit comments

Comments
 (0)