1
Fork 0
mirror of https://github.com/RGBCube/embd-rs synced 2025-06-02 20:18:14 +00:00

Use everything through embed crate

This commit is contained in:
RGBCube 2024-01-04 14:51:58 +03:00
parent 55390702a5
commit 1d0900938d
No known key found for this signature in database
3 changed files with 8 additions and 3 deletions

View file

@ -61,7 +61,8 @@ fn read_dir(path: &PathBuf) -> Vec<DirEntry> {
entries entries
} }
pub fn __include_dir(caller: &str, path: &str) -> Dir { #[doc(hidden)]
pub fn __include_dir_runtime(caller: &str, path: &str) -> Dir {
let path = PathBuf::from(caller) let path = PathBuf::from(caller)
.parent() .parent()
.expect("Failed to get the parent of file") .expect("Failed to get the parent of file")
@ -77,11 +78,11 @@ macro_rules! dir {
($path:literal) => {{ ($path:literal) => {{
#[cfg(debug_assertions)] #[cfg(debug_assertions)]
{ {
::embed::__include_dir(file!(), $path) ::embed::__include_dir_runtime(file!(), $path)
} }
#[cfg(not(debug_assertions))] #[cfg(not(debug_assertions))]
{ {
::embed_macros::__include_dir!($path) ::embed::__include_dir!($path)
} }
}}; }};
} }

View file

@ -2,3 +2,6 @@ mod dir;
pub use dir::*; pub use dir::*;
mod file; mod file;
#[doc(hidden)]
pub use embed_macros::__include_dir;

View file

@ -14,6 +14,7 @@ use syn::{
LitStr, LitStr,
}; };
#[doc(hidden)]
#[proc_macro] #[proc_macro]
pub fn __include_dir(input: pm1::TokenStream) -> pm1::TokenStream { pub fn __include_dir(input: pm1::TokenStream) -> pm1::TokenStream {
let caller = TokenStream::from(input).span().source_file().path(); let caller = TokenStream::from(input).span().source_file().path();