parse sound category at compile time
This commit is contained in:
1 parent
82386a57c4
commit
c95b27eafb
14 files changed
+59
-69
No files matched your search
@@ -0,0 +1,20 @@
|
||||
use proc_macro2::TokenStream;
|
||||
use quote::quote;
|
||||
|
||||
use crate::array_to_tokenstream;
|
||||
|
||||
pub(crate) fn build() -> TokenStream {
|
||||
println!("cargo:rerun-if-changed=assets/sound_category.json");
|
||||
|
||||
let sound_categories: Vec<String> =
|
||||
serde_json::from_str(include_str!("../../assets/sound_category.json"))
|
||||
.expect("Failed to parse sound_category.json");
|
||||
let variants = array_to_tokenstream(sound_categories);
|
||||
|
||||
quote! {
|
||||
#[repr(u8)]
|
||||
pub enum SoundCategory {
|
||||
#variants
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user