@@ -14,6 +14,7 @@ pub struct BuildConfig {
1414 target_dir : PathBuf ,
1515 kernel_bin_path : PathBuf ,
1616 kernel_manifest_path : PathBuf ,
17+ build_std : Option < String > ,
1718}
1819
1920impl BuildConfig {
@@ -54,6 +55,19 @@ impl BuildConfig {
5455 . into ( ) ,
5556 )
5657 } ) ?;
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+ } ;
5771
5872 let binary_feature = cargo_toml
5973 . get ( "features" )
@@ -90,14 +104,19 @@ impl BuildConfig {
90104 target_dir,
91105 kernel_manifest_path : kernel_pkg. manifest_path . clone ( ) ,
92106 kernel_bin_path : kernel_bin_path. to_owned ( ) ,
107+ build_std,
93108 } )
94109 }
95110
96111 /// Creates the cargo build command for building the bootloader.
97112 pub fn build_command ( & self ) -> Command {
98113 let cargo = std:: env:: var ( "CARGO" ) . unwrap_or_else ( |_| "cargo" . to_owned ( ) ) ;
99114 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+ }
101120 cmd. arg ( "--manifest-path" ) ;
102121 cmd. arg ( & self . manifest_path ) ;
103122 cmd. arg ( "--bin" ) . arg ( & self . bootloader_name ) ;
0 commit comments