use std::fs;
use std::io::{self, Write};
use std::path::Path;

fn main() -> io::Result<()> {
    println!("cargo::rerun-if-changed=build.rs");
    let out_dir_raw = std::env::var("OUT_DIR").unwrap();
    let out_dir = Path::new(&out_dir_raw);
    fs::File::create(out_dir.join("my_file.txt"))?.write_all(b"Generated by a build script.\n")?;

    let sub_dir = out_dir.join("dir");
    fs::create_dir_all(&sub_dir)?;
    fs::File::create(sub_dir.join("a.txt"))?.write_all(b"This is file A.\n")?;
    fs::File::create(sub_dir.join("b.txt"))?.write_all(b"This is file B.\n")?;
    Ok(())
}
