File tree 5 files changed +23
-0
lines changed
5 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,8 @@ fn main() {
24
24
}
25
25
" ) ;
26
26
println ! ( "cargo:rustc-env=GENERATED_ENV={}" , gen_dir. display( ) ) ;
27
+
28
+ println ! ( "cargo:rustc-cfg=has_generated_feature" )
27
29
}
28
30
29
31
fn generate_file < P : AsRef < Path > > ( path : P , text : & [ u8 ] ) {
Original file line number Diff line number Diff line change
1
+ use code_generation_example:: function_under_cfg;
2
+
3
+ fn main ( ) {
4
+ function_under_cfg ( ) ;
5
+ }
Original file line number Diff line number Diff line change
1
+ pub fn function_under_cfg ( ) {
2
+ println ! ( "'has_generated_feature' is disabled" )
3
+ }
Original file line number Diff line number Diff line change
1
+ pub fn function_under_cfg ( ) {
2
+ println ! ( "'has_generated_feature' is enabled" )
3
+ }
Original file line number Diff line number Diff line change 1
1
include ! ( concat!( env!( "OUT_DIR" ) , "/hello.rs" ) ) ;
2
2
include ! ( concat!( env!( "GENERATED_ENV" ) , "/hello2.rs" ) ) ;
3
+
4
+ #[ cfg( not( has_generated_feature) ) ]
5
+ mod disabled;
6
+ #[ cfg( has_generated_feature) ]
7
+ mod enabled;
8
+
9
+ #[ cfg( not( has_generated_feature) ) ]
10
+ pub use disabled:: function_under_cfg;
11
+ #[ cfg( has_generated_feature) ]
12
+ pub use enabled:: function_under_cfg;
You can’t perform that action at this time.
0 commit comments