@@ -10,6 +10,23 @@ use std::path::{Path, PathBuf};
10
10
use std:: process:: Command ;
11
11
use walkdir:: { DirEntry , WalkDir } ;
12
12
13
+ macro_rules! forward_features {
14
+ ( $cmd: expr, $( $feature: literal, ) + ) => {
15
+ let mut features = vec![ ] ;
16
+
17
+ $(
18
+ if cfg!( feature = $feature) {
19
+ features. push( $feature) ;
20
+ }
21
+ ) +
22
+
23
+ if !features. is_empty( ) {
24
+ $cmd. arg( "--features" ) ;
25
+ $cmd. arg( features. join( " " ) ) ;
26
+ }
27
+ } ;
28
+ }
29
+
13
30
fn build_hermit ( src_dir : & Path , target_dir_opt : Option < & Path > ) {
14
31
let manifest_path = src_dir. join ( "Cargo.toml" ) ;
15
32
assert ! (
@@ -59,49 +76,17 @@ fn build_hermit(src_dir: &Path, target_dir_opt: Option<&Path>) {
59
76
cmd. arg ( "--release" ) ;
60
77
}
61
78
62
- // disable all default features
79
+ // Control enabled features via this crate's features
63
80
cmd. arg ( "--no-default-features" ) ;
64
-
65
- #[ cfg( feature = "aarch64-qemu-stdout" ) ]
66
- {
67
- cmd. arg ( "--features" ) ;
68
- cmd. arg ( "aarch64-qemu-stdout" ) ;
69
- }
70
-
71
- // do we have to enable PCI support?
72
- #[ cfg( feature = "pci" ) ]
73
- {
74
- cmd. arg ( "--features" ) ;
75
- cmd. arg ( "pci" ) ;
76
- }
77
-
78
- // do we have to enable acpi support?
79
- #[ cfg( feature = "acpi" ) ]
80
- {
81
- cmd. arg ( "--features" ) ;
82
- cmd. arg ( "acpi" ) ;
83
- }
84
-
85
- // do we have to enable FSGSBASE support?
86
- #[ cfg( feature = "fsgs_base" ) ]
87
- {
88
- cmd. arg ( "--features" ) ;
89
- cmd. arg ( "fsgs_base" ) ;
90
- }
91
-
92
- // do we support multi-processor systems?
93
- #[ cfg( feature = "smp" ) ]
94
- {
95
- cmd. arg ( "--features" ) ;
96
- cmd. arg ( "smp" ) ;
97
- }
98
-
99
- // do we have to enable VGA support
100
- #[ cfg( feature = "vga" ) ]
101
- {
102
- cmd. arg ( "--features" ) ;
103
- cmd. arg ( "vga" ) ;
104
- }
81
+ forward_features ! (
82
+ cmd,
83
+ "aarch64-qemu-stdout" ,
84
+ "acpi" ,
85
+ "fsgsbase" ,
86
+ "pci" ,
87
+ "smp" ,
88
+ "vga" ,
89
+ ) ;
105
90
106
91
let mut rustflags = vec ! [ "-Zmutable-noalias=no" . to_string( ) ] ;
107
92
let outer_rustflags = env:: var ( "CARGO_ENCODED_RUSTFLAGS" ) . unwrap ( ) ;
0 commit comments