File tree Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -76,3 +76,32 @@ cfg_async! {
7676 #[ doc( hidden) ]
7777 pub use asynchronous as r#async;
7878}
79+
80+ /// Macro to include the mod.rs file from the OUT_DIR
81+ /// This is only work on out_dir not set and use 'gen_mod' feature
82+ /// ```rust,ignore
83+ /// mod protocals {
84+ /// include_mod!();
85+ /// }
86+ /// ```
87+ /// [`OUT_DIR`]: https://doc.rust-lang.org/cargo/reference/environment-variables.html#environment-variables-cargo-sets-for-build-scripts
88+ #[ macro_export]
89+ macro_rules! include_mod {
90+ ( ) => {
91+ include!( concat!( env!( "OUT_DIR" ) , concat!( "/" , "mod.rs" ) ) ) ;
92+ } ;
93+ }
94+
95+ /// Macro to include files ending with _ttrpc.rs from the OUT_DIR
96+ /// This is only work on out_dir not set and use 'gen_mod' feature
97+ /// ```rust,ignore
98+ /// mod protocals {
99+ /// include_ttrpc!("helloworld");
100+ /// }
101+ /// ```
102+ #[ macro_export]
103+ macro_rules! include_ttrpc {
104+ ( $name: expr) => {
105+ include!( concat!( env!( "OUT_DIR" ) , concat!( "/" , $name, "_ttrpc.rs" ) ) ) ;
106+ } ;
107+ }
Original file line number Diff line number Diff line change 2626//! ```
2727//! If there's no out_dir and use 'gen_mod' feature
2828//! You can use the following method to include the target file
29- //! include!(concat!(env!("OUT_DIR"), "/mod.rs") );
29+ //! ttrpc::include_mod!( );
3030
3131pub use protobuf_codegen:: {
3232 Customize as ProtobufCustomize , CustomizeCallback as ProtobufCustomizeCallback ,
You can’t perform that action at this time.
0 commit comments