<commit_before>use std::env;
use std::process::Command;
use std::fs::File;
use std::path::Path;

fn main() {
    let decoders = [
        "src/cpu/arm.decoder",
        "src/cpu/thumb.decoder"
    ];

    for decoder in decoders.iter() {
        let out_dir = env::var("OUT_DIR").unwrap();
        let filename = Path::new(decoder).file_name().unwrap();
        let out = format!("{}/{}.rs", out_dir, filename.to_os_string().to_str().unwrap());

        Command::new("python3")
            .arg("tools/decoder-gen/decoder-gen.py")
            .arg(decoder)
            .stdout(File::create(out).unwrap())
            .spawn()
            .expect("failed to execute child");
        
        println!("cargo:rerun-if-changed={}", decoder);
    }
}<commit_msg>build.rs: Fail on decoder-gen failure<commit_after>use std::env;
use std::process::Command;
use std::fs::File;
use std::path::Path;

fn main() {
    let decoders = [
        "src/cpu/arm.decoder",
        "src/cpu/thumb.decoder"
    ];

    for decoder in decoders.iter() {
        let out_dir = env::var("OUT_DIR").unwrap();
        let filename = Path::new(decoder).file_name().unwrap();
        let out = format!("{}/{}.rs", out_dir, filename.to_os_string().to_str().unwrap());

        let decoder_stat = Command::new("python3")
            .arg("tools/decoder-gen/decoder-gen.py")
            .arg(decoder)
            .stdout(File::create(&out).unwrap())
            .output()
            .expect("failed to execute child");

        if !decoder_stat.status.success() {
            use std::io::{stderr, Write};

            eprintln!("ERROR: decoder generation failed on {}!", out);
            eprintln!("Script stderr:");
            stderr().write_all(&decoder_stat.stderr).unwrap();
        }
        
        println!("cargo:rerun-if-changed={}", decoder);
    }
}
{'fraction_non_alphanumeric': 0.1826608505997819, 'fraction_numerical': 0.0010905125408942203, 'mean_word_length': 2.3981481481481484, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5128714', 'n_tokens_mistral': 591, 'n_tokens_neox': 580, 'n_words': 100}