Use the recommended layout for proc macros

This commit is contained in:
Gwilym Inzani 2023-07-12 12:33:15 +01:00
parent af0cf7170e
commit f3e3c243a4
5 changed files with 44 additions and 14 deletions

View file

@ -6,7 +6,11 @@ license = "MPL-2.0"
description = "Library for playing tracker music. Designed for use with the agb library for the Game Boy Advance." description = "Library for playing tracker music. Designed for use with the agb library for the Game Boy Advance."
repository = "https://github.com/agbrs/agb" repository = "https://github.com/agbrs/agb"
[features]
default = ["xm"]
xm = ["dep:agb_xm"]
[dependencies] [dependencies]
agb_xm = { version = "0.15.0", path = "../agb-xm" } agb_xm = { version = "0.15.0", path = "../agb-xm", optional = true }
agb = { version = "0.15.0", path = "../../agb" } agb = { version = "0.15.0", path = "../../agb" }
agb_tracker_interop = { version = "0.15.0", path = "../agb-tracker-interop", default-features = false } agb_tracker_interop = { version = "0.15.0", path = "../agb-tracker-interop", default-features = false }

View file

@ -0,0 +1,15 @@
[package]
name = "agb_xm_core"
version = "0.15.0"
authors = ["Gwilym Kuiper <gw@ilym.me>"]
edition = "2021"
license = "MPL-2.0"
description = "Library for converting XM tracker files for use with agb-tracker on the Game Boy Advance. You shouldn't use this package directly"
repository = "https://github.com/agbrs/agb"
[dependencies]
proc-macro-error = "1"
proc-macro2 = "1"
quote = "1"
agb_tracker_interop = { version = "0.15.0", path = "../agb-tracker-interop" }

View file

@ -0,0 +1,14 @@
use proc_macro2::TokenStream;
use proc_macro_error::abort;
use quote::quote;
pub fn agb_xm_core(args: TokenStream) -> TokenStream {
if args.is_empty() {
abort!(args, "must pass a filename");
}
quote! {
fn hello_world() {}
}
}

View file

@ -4,10 +4,13 @@ version = "0.15.0"
authors = ["Gwilym Kuiper <gw@ilym.me>"] authors = ["Gwilym Kuiper <gw@ilym.me>"]
edition = "2021" edition = "2021"
license = "MPL-2.0" license = "MPL-2.0"
description = "Library for converting XM tracker files for use with agb-tracker on the Game Boy Advance" description = "Library for converting XM tracker files for use with agb-tracker on the Game Boy Advance. You shouldn't use this package directly"
repository = "https://github.com/agbrs/agb" repository = "https://github.com/agbrs/agb"
[lib] [lib]
proc-macro = true proc-macro = true
[dependencies] [dependencies]
agb_xm_core = { version = "0.15.0", path = "../agb-xm-core" }
proc-macro-error = "1"
proc-macro2 = "1"

View file

@ -1,14 +1,8 @@
fn add(left: usize, right: usize) -> usize { use proc_macro::TokenStream;
left + right use proc_macro_error::proc_macro_error;
}
#[cfg(test)] #[proc_macro_error]
mod tests { #[proc_macro]
use super::*; pub fn import_xm(args: TokenStream) -> TokenStream {
agb_xm_core::agb_xm_core(args.into()).into()
#[test]
fn it_works() {
let result = add(2, 2);
assert_eq!(result, 4);
}
} }