lib.rs 884 B

12345678910111213141516171819202122232425262728293031
  1. // Copyright 2019-2021 Tauri Programme within The Commons Conservancy
  2. // SPDX-License-Identifier: Apache-2.0
  3. // SPDX-License-Identifier: MIT
  4. extern crate proc_macro;
  5. use crate::context::ContextItems;
  6. use proc_macro::TokenStream;
  7. use syn::parse_macro_input;
  8. mod command;
  9. #[macro_use]
  10. mod context;
  11. #[proc_macro_attribute]
  12. pub fn command(attributes: TokenStream, item: TokenStream) -> TokenStream {
  13. command::wrapper(attributes, item)
  14. }
  15. #[proc_macro]
  16. pub fn generate_handler(item: TokenStream) -> TokenStream {
  17. parse_macro_input!(item as command::Handler).into()
  18. }
  19. /// Reads a Tauri config file and generates a `::tauri::Context` based on the content.
  20. #[proc_macro]
  21. pub fn generate_context(items: TokenStream) -> TokenStream {
  22. // this macro is exported from the context module
  23. let path = parse_macro_input!(items as ContextItems);
  24. context::generate_context(path).into()
  25. }