File tree 2 files changed +30
-1
lines changed
2 files changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -76,3 +76,32 @@ cfg_async! {
76
76
#[ doc( hidden) ]
77
77
pub use asynchronous as r#async;
78
78
}
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
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 26
26
//! ```
27
27
//! If there's no out_dir and use 'gen_mod' feature
28
28
//! You can use the following method to include the target file
29
- //! include!(concat!(env!("OUT_DIR"), "/mod.rs") );
29
+ //! ttrpc::include_mod!( );
30
30
31
31
pub use protobuf_codegen:: {
32
32
Customize as ProtobufCustomize , CustomizeCallback as ProtobufCustomizeCallback ,
You can’t perform that action at this time.
0 commit comments