git.delta.rocks / jrsonnet / refs/commits / 0831da3ed8d9

difftreelog

source

crates/jrsonnet-stdlib/build.rs696 Bsourcehistory
1use std::{borrow::Cow, 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				Cow::Borrowed("<std>"),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(v.to_string().replace(';', ";\n").as_bytes())27			.unwrap();28	}29}