git.delta.rocks / jrsonnet / refs/commits / 7b01ecbd8fbc

difftreelog

source

crates/jrsonnet-stdlib/build.rs744 Bsourcehistory
1use std::{env, fs::File, io::Write, path::Path};23use jrsonnet_parser::{parse, ParserSettings, Source};4use structdump::CodegenResult;56fn main() {7	let parsed = parse(8		include_str!("./src/std.jsonnet"),9		&ParserSettings {10			file_name: Source::new_virtual(11				"<std>".into(),12				include_str!("./src/std.jsonnet").into(),13			),14		},15	)16	.expect("parse");1718	let mut out = CodegenResult::default();1920	let v = out.codegen(&parsed, true);2122	{23		let out_dir = env::var("OUT_DIR").unwrap();24		let dest_path = Path::new(&out_dir).join("stdlib.rs");25		let mut f = File::create(&dest_path).unwrap();26		f.write_all(27			("#[allow(clippy::redundant_clone)]".to_owned() + &v.to_string())28				.replace(';', ";\n")29				.as_bytes(),30		)31		.unwrap();32	}33}