//! Compile every script in `scripts/` against `scripts/platform.frits` and //! write its native code to `$OUT_DIR/.rs`. fn main() { let decl = std::fs::read_to_string("scripts/platform.frits").unwrap(); let plat: frits::Platform<()> = frits::Platform::new(&decl).unwrap(); let out = std::env::var("OUT_DIR").unwrap(); println!("cargo::rerun-if-changed=scripts"); for entry in std::fs::read_dir("scripts").unwrap() { let path = entry.unwrap().path(); let name = path.file_stem().unwrap().to_str().unwrap().to_string(); if name == "platform" { continue; } let src = std::fs::read_to_string(&path).unwrap(); let m = plat .compile(&src) .unwrap_or_else(|e| panic!("{}: {e:?}", path.display())); std::fs::write(format!("{out}/{name}.rs"), frits::aot::generate(&m)).unwrap(); } }