update build script

This commit is contained in:
Simon Gardling 2022-04-07 09:13:29 -04:00
parent c10843140b
commit 9e07a3c981

View File

@ -16,14 +16,15 @@ fn main() {
let _ = command_run::Command::with_args("./pack_assets.sh", &[""]) let _ = command_run::Command::with_args("./pack_assets.sh", &[""])
.enable_capture() .enable_capture()
.run(); .run();
shadow_rs::new().unwrap();
shadow_rs::new().expect("Could not initialize shadow_rs");
generate_hashmap(); generate_hashmap();
} }
fn generate_hashmap() { fn generate_hashmap() {
let path = Path::new(&env::var("OUT_DIR").unwrap()).join("codegen.rs"); let path = Path::new(&env::var("OUT_DIR").unwrap()).join("codegen.rs");
let mut file = BufWriter::new(File::create(&path).unwrap()); let mut file = BufWriter::new(File::create(&path).expect("Could not create file"));
let max_len: usize = SUPPORTED_FUNCTIONS let max_len: usize = SUPPORTED_FUNCTIONS
.to_vec() .to_vec()
.iter() .iter()
@ -47,13 +48,13 @@ fn generate_hashmap() {
write!( write!(
&mut file, &mut file,
"static COMPLETION_HASHMAP: phf::Map<&'static str, HintEnum> = {}", "static COMPLETION_HASHMAP: phf::Map<&'static str, HintEnum> = {};",
hashmap.build() hashmap.build()
) )
.unwrap(); .expect("Could not write to file");
writeln!(&mut file, ";").unwrap();
writeln!(&mut file, "const MAX_COMPLETION_LEN: usize = {};", max_len).unwrap(); writeln!(&mut file, "const MAX_COMPLETION_LEN: usize = {};", max_len)
.expect("Could not write to file");
write!( write!(
&mut file, &mut file,
@ -61,7 +62,7 @@ fn generate_hashmap() {
SUPPORTED_FUNCTIONS.len(), SUPPORTED_FUNCTIONS.len(),
SUPPORTED_FUNCTIONS.to_vec() SUPPORTED_FUNCTIONS.to_vec()
) )
.unwrap(); .expect("Could not write to file");
} }
include!(concat!( include!(concat!(