Use syn crate rather than litrs

This commit is contained in:
Gwilym Kuiper 2021-07-22 18:43:27 +01:00
parent 21a11a4e41
commit 19e0a0527b
4 changed files with 6 additions and 28 deletions

View file

@ -13,8 +13,8 @@ name = "agb_image_converter"
version = "0.4.0" version = "0.4.0"
dependencies = [ dependencies = [
"image", "image",
"litrs",
"serde", "serde",
"syn",
"toml", "toml",
] ]
@ -88,15 +88,6 @@ dependencies = [
"png", "png",
] ]
[[package]]
name = "litrs"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f9275e0933cf8bb20f008924c0cb07a0692fe54d8064996520bf998de9eb79aa"
dependencies = [
"proc-macro2",
]
[[package]] [[package]]
name = "miniz_oxide" name = "miniz_oxide"
version = "0.3.7" version = "0.3.7"

View file

@ -13,4 +13,4 @@ proc-macro = true
image = { version = "0.23.14", default-features = false, features = [ "png", "bmp" ] } image = { version = "0.23.14", default-features = false, features = [ "png", "bmp" ] }
toml = "0.5.8" toml = "0.5.8"
serde = { version = "1.0", features = ["derive"] } serde = { version = "1.0", features = ["derive"] }
litrs = "0.2.3" syn = "1.0.73"

View file

@ -1,7 +1,6 @@
use litrs::StringLit;
use proc_macro::TokenStream; use proc_macro::TokenStream;
use syn::parse_macro_input;
use std::convert::TryFrom;
use std::fmt::Write; use std::fmt::Write;
use std::path::Path; use std::path::Path;
@ -32,12 +31,9 @@ impl TileSize {
#[proc_macro] #[proc_macro]
pub fn include_gfx(input: TokenStream) -> TokenStream { pub fn include_gfx(input: TokenStream) -> TokenStream {
let first_token = input.into_iter().next().expect("no input"); let input = parse_macro_input!(input as syn::LitStr);
let filename = match StringLit::try_from(first_token) { let filename = input.value();
Err(e) => return e.to_compile_error(),
Ok(filename) => filename.into_value(),
};
let root = std::env::var("CARGO_MANIFEST_DIR").expect("Failed to get cargo manifest dir"); let root = std::env::var("CARGO_MANIFEST_DIR").expect("Failed to get cargo manifest dir");
let path = Path::new(&root).join(&*filename); let path = Path::new(&root).join(&*filename);

11
agb/Cargo.lock generated
View file

@ -21,8 +21,8 @@ name = "agb_image_converter"
version = "0.4.0" version = "0.4.0"
dependencies = [ dependencies = [
"image", "image",
"litrs",
"serde", "serde",
"syn",
"toml", "toml",
] ]
@ -96,15 +96,6 @@ dependencies = [
"png", "png",
] ]
[[package]]
name = "litrs"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f9275e0933cf8bb20f008924c0cb07a0692fe54d8064996520bf998de9eb79aa"
dependencies = [
"proc-macro2",
]
[[package]] [[package]]
name = "miniz_oxide" name = "miniz_oxide"
version = "0.3.7" version = "0.3.7"