build.rs 433 B

12345678910111213141516171819202122
  1. use std::{
  2. env::var,
  3. f32::consts::TAU,
  4. fs::File,
  5. io::{Result, Write},
  6. path::PathBuf
  7. };
  8. fn main() -> Result<()> {
  9. println!("cargo:rerun-if-changed=build.rs");
  10. let mut path = PathBuf::from(var("OUT_DIR")
  11. .expect("Cargo didn't set OUT_DIR"));
  12. path.push("normals.rs");
  13. let mut f = File::create(path)?;
  14. f.write_all(b"[0.0,")?;
  15. for n in 1..256 {
  16. write!(f, "{},", (n as f32 / 255.0 * TAU).sin())?;
  17. }
  18. f.write_all(b"]")
  19. }