swc/crates/swc_atoms/build.rs

20 lines
614 B
Rust
Raw Normal View History

use std::{env, path::Path};
2017-12-22 15:51:36 +03:00
#[cfg(all(feature = "rkyv-impl", feature = "rkyv-bytecheck-impl"))]
compile_error!("Cannot enable bytechcked, non-bytechecked rkyv both");
2017-12-22 15:51:36 +03:00
fn main() {
let strs = include_str!("words.txt")
.lines()
.map(|l| l.trim())
.collect::<Vec<_>>();
gen("js_word", "JsWord", &strs);
2017-12-22 15:51:36 +03:00
}
fn gen(mac_name: &str, type_name: &str, atoms: &[&str]) {
string_cache_codegen::AtomType::new(type_name, &format!("{}!", mac_name))
.atoms(atoms)
.write_to_file(&Path::new(&env::var("OUT_DIR").unwrap()).join(format!("{}.rs", mac_name)))
.unwrap();
}