build.rs 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. use std::env;
  2. use std::fs::File;
  3. use std::io::Write;
  4. use std::path::Path;
  5. use std::process::Command;
  6. fn main() {
  7. println!("cargo:rerun-if-changed=tests/generate_tile_connection_array_cases.py");
  8. let status = Command::new("python3.11")
  9. .arg("tests/generate_tile_connection_array_cases.py")
  10. .status()
  11. .expect("failed to execute Python script generate_tile_connection_array_cases.py");
  12. if !status.success() {
  13. panic!("failed to execute Python script generate_tile_connection_array_cases.py");
  14. }
  15. // Code generation for tile_grid.rs
  16. println!("cargo:rerun-if-changed=src/neighbor_associations_match_generation.py");
  17. let out_dir = env::var("OUT_DIR").unwrap();
  18. let dest_path = Path::new(&out_dir).join("neighbor_associations_match.rs");
  19. let mut file = File::create(&dest_path).unwrap();
  20. let output = Command::new("python3.11")
  21. .arg("src/neighbor_associations_match_generation.py")
  22. .output()
  23. .expect("failed to execute Python script neighbor_associations_match_generation.py");
  24. file.write_all(output.stdout.as_slice()).unwrap();
  25. }