tss-rust 0.2.2

Generated node type enums and metadata from tree-sitter-rust
Documentation
//! Build script for generating tree-sitter node type enums and updating Cargo.toml features.
//!
//! This build script reads the `NODE_TYPES` constant from `tree-sitter-rust` and generates
//! Rust code for the `NodeType` enum with feature-gated variants. When the `REWRITE_FEATURES`
//! environment variable is set, it also updates the `Cargo.toml` with generated feature names.

#![allow(clippy::too_many_lines)]
#![allow(clippy::match_same_arms)]
#![allow(clippy::negative_feature_names)]
#![allow(clippy::redundant_feature_names)]
use std::env;
use std::fs::File;
use std::path::Path;

mod codegen;

use codegen::feature_toml::update_cargo_toml_features;
use codegen::generator::generate;

fn main() {
    let out_dir = env::var("OUT_DIR").unwrap();
    let dest_path = Path::new(&out_dir).join("generated.rs");
    let mut f = File::create(dest_path).unwrap();

    let features = generate(&mut f).unwrap();
    update_cargo_toml_features(&features).unwrap();

    println!("cargo:rerun-if-changed=build.rs");
    println!("cargo:rerun-if-changed=src/codegen.rs");
    println!("cargo:rerun-if-changed=src/codegen");
    println!("cargo:rerun-if-changed=Cargo.toml");
}