diff --git a/agb-image-converter/src/aseprite.rs b/agb-image-converter/src/aseprite.rs index cd2db333..72a6cbb4 100644 --- a/agb-image-converter/src/aseprite.rs +++ b/agb-image-converter/src/aseprite.rs @@ -62,10 +62,11 @@ pub struct Frame2 { pub h: u32, } -pub fn generate_from_file(filename: &str) -> (Aseprite, DynamicImage) { +pub fn generate_from_file(filename: &Path) -> (Aseprite, DynamicImage) { let out_dir = std::env::var("OUT_DIR").expect("Expected OUT_DIR"); - let output_filename = Path::new(&out_dir).join(&*filename); + let output_filename = Path::new(&out_dir).join(filename.file_name().unwrap()); + let image_output = output_filename.with_extension("png"); let json_output = output_filename.with_extension("json"); diff --git a/agb-image-converter/src/lib.rs b/agb-image-converter/src/lib.rs index 35e658d8..4c1a93ae 100644 --- a/agb-image-converter/src/lib.rs +++ b/agb-image-converter/src/lib.rs @@ -4,6 +4,7 @@ use proc_macro2::Literal; use syn::parse::Parser; use syn::{parse_macro_input, punctuated::Punctuated, LitStr}; +use std::path::PathBuf; use std::{iter, path::Path, str}; use quote::{format_ident, quote, ToTokens}; @@ -97,16 +98,10 @@ pub fn include_aseprite_inner(input: TokenStream) -> TokenStream { let root = std::env::var("CARGO_MANIFEST_DIR").expect("Failed to get cargo manifest dir"); - let filenames: Vec = parsed + let filenames: Vec = parsed .iter() .map(|s| s.value()) - .map(|s| { - Path::new(&root) - .join(&*s) - .as_path() - .to_string_lossy() - .into_owned() - }) + .map(|s| Path::new(&root).join(&*s)) .collect(); for filename in filenames.iter() { @@ -184,6 +179,7 @@ pub fn include_aseprite_inner(input: TokenStream) -> TokenStream { .flatten(); let include_paths = filenames.iter().map(|s| { + let s = s.as_os_str().to_string_lossy(); quote! { const _: &[u8] = include_bytes!(#s); }