Files
ic10emu/ic10emu_wasm/build.rs
2024-03-31 16:12:21 -07:00

24 lines
598 B
Rust

use std::{
env,
fs::{self, File},
io::{BufWriter, Write},
path::Path,
};
fn main() {
let out_dir = env::var_os("OUT_DIR").unwrap();
let dest_path = Path::new(&out_dir).join("ts_types.rs");
let output_file = File::create(dest_path).unwrap();
let mut writer = BufWriter::new(&output_file);
let infile = Path::new("src/types.ts");
let contents = fs::read_to_string(infile).unwrap();
write!(
&mut writer,
"#[wasm_bindgen(typescript_custom_section)]\n\
const TYPES: &'static str = r#\"{contents}\"#;
"
)
.unwrap();
}