mirror of
https://github.com/RGBCube/embd-rs
synced 2025-05-31 19:18:12 +00:00
Use everything through embed crate
This commit is contained in:
parent
55390702a5
commit
1d0900938d
3 changed files with 8 additions and 3 deletions
|
@ -61,7 +61,8 @@ fn read_dir(path: &PathBuf) -> Vec<DirEntry> {
|
|||
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)
|
||||
.parent()
|
||||
.expect("Failed to get the parent of file")
|
||||
|
@ -77,11 +78,11 @@ macro_rules! dir {
|
|||
($path:literal) => {{
|
||||
#[cfg(debug_assertions)]
|
||||
{
|
||||
::embed::__include_dir(file!(), $path)
|
||||
::embed::__include_dir_runtime(file!(), $path)
|
||||
}
|
||||
#[cfg(not(debug_assertions))]
|
||||
{
|
||||
::embed_macros::__include_dir!($path)
|
||||
::embed::__include_dir!($path)
|
||||
}
|
||||
}};
|
||||
}
|
||||
|
|
|
@ -2,3 +2,6 @@ mod dir;
|
|||
pub use dir::*;
|
||||
|
||||
mod file;
|
||||
|
||||
#[doc(hidden)]
|
||||
pub use embed_macros::__include_dir;
|
||||
|
|
|
@ -14,6 +14,7 @@ use syn::{
|
|||
LitStr,
|
||||
};
|
||||
|
||||
#[doc(hidden)]
|
||||
#[proc_macro]
|
||||
pub fn __include_dir(input: pm1::TokenStream) -> pm1::TokenStream {
|
||||
let caller = TokenStream::from(input).span().source_file().path();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue