@@ -14,6 +14,7 @@ pub struct BuildConfig {
14
14
target_dir : PathBuf ,
15
15
kernel_bin_path : PathBuf ,
16
16
kernel_manifest_path : PathBuf ,
17
+ build_std : Option < String > ,
17
18
}
18
19
19
20
impl BuildConfig {
@@ -54,6 +55,19 @@ impl BuildConfig {
54
55
. into ( ) ,
55
56
)
56
57
} ) ?;
58
+ let build_std = {
59
+ let key = metadata
60
+ . and_then ( |t| t. get ( "bootloader" ) )
61
+ . and_then ( |t| t. get ( "build-std" ) ) ;
62
+ if let Some ( key) = key {
63
+ let err_msg = "A non-string `package.metadata.bootloader.build-std` key found in \
64
+ Cargo.toml of bootloader";
65
+ let err = || BootloaderError :: BootloaderInvalid ( err_msg. into ( ) ) ;
66
+ Some ( key. as_str ( ) . ok_or_else ( err) ?. into ( ) )
67
+ } else {
68
+ None
69
+ }
70
+ } ;
57
71
58
72
let binary_feature = cargo_toml
59
73
. get ( "features" )
@@ -90,14 +104,19 @@ impl BuildConfig {
90
104
target_dir,
91
105
kernel_manifest_path : kernel_pkg. manifest_path . clone ( ) ,
92
106
kernel_bin_path : kernel_bin_path. to_owned ( ) ,
107
+ build_std,
93
108
} )
94
109
}
95
110
96
111
/// Creates the cargo build command for building the bootloader.
97
112
pub fn build_command ( & self ) -> Command {
98
113
let cargo = std:: env:: var ( "CARGO" ) . unwrap_or_else ( |_| "cargo" . to_owned ( ) ) ;
99
114
let mut cmd = Command :: new ( & cargo) ;
100
- cmd. arg ( "xbuild" ) ;
115
+ if let Some ( build_std) = & self . build_std {
116
+ cmd. arg ( "build" ) . arg ( & format ! ( "-Zbuild-std={}" , build_std) ) ;
117
+ } else {
118
+ cmd. arg ( "xbuild" ) ;
119
+ }
101
120
cmd. arg ( "--manifest-path" ) ;
102
121
cmd. arg ( & self . manifest_path ) ;
103
122
cmd. arg ( "--bin" ) . arg ( & self . bootloader_name ) ;
0 commit comments