git.delta.rocks / jrsonnet / refs/commits / b5d51b90d7ba

difftreelog

source

crates/jrsonnet-stdlib/build.rs819 Bsourcehistory
1fn main() {2	#[cfg(feature = "codegenerated-stdlib")]3	{4		use std::{env, fs::File, io::Write, path::Path};56		use jrsonnet_parser::{parse, ParserSettings, Source};7		use structdump::CodegenResult;89		let parsed = parse(10			include_str!("./src/std.jsonnet"),11			&ParserSettings {12				source: Source::new_virtual(13					"<std>".into(),14					include_str!("./src/std.jsonnet").into(),15				),16			},17		)18		.expect("parse");1920		let mut out = CodegenResult::default();2122		let v = out.codegen(&parsed, true);2324		{25			let out_dir = env::var("OUT_DIR").unwrap();26			let dest_path = Path::new(&out_dir).join("stdlib.rs");27			let mut f = File::create(dest_path).unwrap();28			f.write_all(29				("#[allow(clippy::redundant_clone, clippy::similar_names)]".to_owned()30					+ &v.to_string())31					.as_bytes(),32			)33			.unwrap();34		}35	}36}