linktime_proc_macro/
lib.rs1#![doc = include_str!("../README.md")]
2
3mod generate;
4mod hash;
5mod tokens;
6
7use proc_macro::TokenStream;
8
9macro_rules! generators {
11 ( $( ($crate_name:ident/$crate_name_str:literal: $( $macro_name:ident/$macro_name_linktime:ident ),*) )* ) => {
12 $($(
13 #[cfg(feature = $crate_name_str)]
14 #[allow(missing_docs)]
15 #[doc(hidden)]
16 #[proc_macro_attribute]
17 pub fn $macro_name(attribute: TokenStream, item: TokenStream) -> TokenStream {
18 crate::generate::generate(stringify!($crate_name), stringify!($macro_name), attribute, item)
19 }
20 )*)*
21 $($(
22 #[cfg(feature = $crate_name_str)]
23 #[allow(missing_docs)]
24 #[doc(hidden)]
25 #[proc_macro_attribute]
26 pub fn $macro_name_linktime(attribute: TokenStream, item: TokenStream) -> TokenStream {
27 crate::generate::generate("linktime", stringify!($macro_name), attribute, item)
28 }
29 )*)*
30 };
31}
32
33generators! {
34 (ctor/"ctor": ctor/ctor_linktime)
35 (dtor/"dtor": dtor/dtor_linktime)
36 (link_section/"link_section": in_section/in_section_linktime, section/section_linktime)
37}
38
39#[doc(hidden)]
40#[proc_macro]
41pub fn ident_concat(item: TokenStream) -> TokenStream {
42 hash::ident_concat(item)
43}
44
45#[doc(hidden)]
46#[proc_macro]
47pub fn hash(item: TokenStream) -> TokenStream {
48 hash::hash(item)
49}