blob: 668c5073aa21631cca964ebd723f768ea6e41757 [file] [log] [blame]
David Tolnay10227122019-02-15 20:53:45 -08001use crate::types::Definitions;
Carl Lerche9a7d5882019-02-15 12:27:04 -08002
David Tolnay10227122019-02-15 20:53:45 -08003use std::fs;
Carl Lerche9a7d5882019-02-15 12:27:04 -08004use std::path::Path;
5
David Tolnay10227122019-02-15 20:53:45 -08006pub fn generate(defs: &Definitions) {
7 let j = serde_json::to_string_pretty(&defs).unwrap();
8 let check: Definitions = serde_json::from_str(&j).unwrap();
9 assert_eq!(*defs, check);
10
Carl Lerche9a7d5882019-02-15 12:27:04 -080011 let codegen_root = Path::new(env!("CARGO_MANIFEST_DIR"));
David Tolnay07b2cca2019-02-15 18:58:27 -080012 let json_path = codegen_root.join("../syn.json");
13 fs::write(json_path, j).unwrap();
Carl Lerche9a7d5882019-02-15 12:27:04 -080014}