windjammer 0.48.0

A simple language inspired by Go, Ruby, and Elixir that transpiles to Rust - 80% of Rust's power with 20% of the complexity
Documentation
/// Auto-generate the consolidated test module list from all `tests/*.rs` files.
///
/// Consolidating into a single binary eliminates ~800 separate link operations,
/// reducing full test suite time from 14+ minutes to 2-3 minutes. Adding a new
/// test file to `tests/` is all that's needed — no manual registration.
fn generate_test_all_rs() {
    use std::fs;
    use std::path::Path;

    let tests_dir = Path::new("tests");
    if !tests_dir.is_dir() {
        return;
    }

    let mut modules: Vec<String> = Vec::new();
    if let Ok(entries) = fs::read_dir(tests_dir) {
        for entry in entries.flatten() {
            let path = entry.path();
            if path.extension().is_some_and(|e| e == "rs") {
                let name = path.file_stem().unwrap().to_string_lossy().to_string();
                if name == "all" || name == "common" || name == "lib" {
                    continue;
                }
                modules.push(name);
            }
        }
    }
    modules.sort();

    let out_dir = std::env::var("OUT_DIR").unwrap_or_else(|_| "target".to_string());
    let generated_path = Path::new(&out_dir).join("all_tests_generated.rs");

    let manifest_dir = std::env::var("CARGO_MANIFEST_DIR").unwrap_or_else(|_| ".".to_string());
    let tests_dir_abs = Path::new(&manifest_dir).join("tests");

    /// Absolute path for `#[path = "..."]` in generated test modules.
    /// Forward slashes only; strip Windows `\\?\` prefix from canonicalize().
    fn path_for_attr(base: &Path, relative: &str) -> String {
        let path = base.join(relative);
        let abs = fs::canonicalize(&path).unwrap_or(path);
        let mut s = abs.display().to_string();
        if s.starts_with(r"\\?\") {
            s = s[4..].to_string();
        }
        s.replace('\\', "/")
    }

    let mut content = String::new();
    content.push_str("// AUTO-GENERATED by build.rs — do not edit.\n");
    content.push_str("// Consolidates all *_test.rs / *_tests.rs files into one binary\n");
    content.push_str("// to avoid ~800 separate link operations.\n\n");
    content
        .push_str("// Absolute paths with forward slashes — relative paths resolve from OUT_DIR\n");
    content.push_str(
        "// (not tests/), and Windows canonicalize() adds \\\\?\\ which breaks escapes.\n\n",
    );

    content.push_str(&format!(
        "#[path = \"{}\"]\nmod test_utils;\n\n",
        path_for_attr(&tests_dir_abs, "common/test_utils.rs")
    ));

    for module in &modules {
        content.push_str(&format!(
            "#[path = \"{}\"]\nmod {module};\n\n",
            path_for_attr(&tests_dir_abs, &format!("{module}.rs"))
        ));
    }

    let existing = fs::read_to_string(&generated_path).unwrap_or_default();
    if existing != content {
        fs::write(&generated_path, &content).expect("write generated all_tests_generated.rs");
    }
}

fn main() {
    println!("cargo:rerun-if-changed=build.rs");
    println!("cargo:rerun-if-changed=tests");
    println!("cargo::rustc-check-cfg=cfg(tarpaulin)");

    generate_test_all_rs();

    let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap_or_default();

    if target_os == "windows" {
        let target_env = std::env::var("CARGO_CFG_TARGET_ENV").unwrap_or_default();
        let profile = std::env::var("PROFILE").unwrap_or_default();
        let crate_name = std::env::var("CARGO_PKG_NAME").unwrap_or_default();

        // 64MB stack - if this doesn't work, problem is structural
        let stack_size = 67108864;

        eprintln!("========================================");
        eprintln!("BUILD SCRIPT: Setting Windows stack size");
        eprintln!("  Package: {}", crate_name);
        eprintln!("  Profile: {}", profile);
        eprintln!("  Stack: {}MB", stack_size / 1048576);
        eprintln!("========================================");

        match target_env.as_str() {
            "msvc" => {
                println!("cargo:rustc-link-arg=/STACK:{}", stack_size);
                println!("cargo:rustc-link-arg=/DEBUG"); // Include debug info
            }
            "gnu" => {
                println!("cargo:rustc-link-arg=-Wl,--stack,{}", stack_size);
            }
            _ => {
                eprintln!("Warning: Unknown target environment: {}", target_env);
            }
        }
    }
}