@@ -3,49 +3,47 @@ use std::{
33 process:: Command ,
44} ;
55
6- const BOOTLOADER_VERSION : & str = env ! ( "CARGO_PKG_VERSION" ) ;
6+ const BOOTLOADER_X86_64_UEFI_VERSION : & str = env ! ( "CARGO_PKG_VERSION" ) ;
7+
8+ const BOOTLOADER_X86_64_BIOS_BOOT_SECTOR_VERSION : & str = env ! ( "CARGO_PKG_VERSION" ) ;
9+ const BOOTLOADER_X86_64_BIOS_STAGE_2_VERSION : & str = env ! ( "CARGO_PKG_VERSION" ) ;
10+ const BOOTLOADER_X86_64_BIOS_STAGE_3_VERSION : & str = env ! ( "CARGO_PKG_VERSION" ) ;
11+ const BOOTLOADER_X86_64_BIOS_STAGE_4_VERSION : & str = env ! ( "CARGO_PKG_VERSION" ) ;
712
813fn main ( ) {
914 let out_dir = PathBuf :: from ( std:: env:: var ( "OUT_DIR" ) . unwrap ( ) ) ;
1015
11- #[ cfg( feature = "uefi" ) ]
12- {
13- let uefi_path = build_uefi_bootloader ( & out_dir) ;
14- println ! (
15- "cargo:rustc-env=UEFI_BOOTLOADER_PATH={}" ,
16- uefi_path. display( )
17- ) ;
18- }
16+ let uefi_path = build_uefi_bootloader ( & out_dir) ;
17+ println ! (
18+ "cargo:rustc-env=UEFI_BOOTLOADER_PATH={}" ,
19+ uefi_path. display( )
20+ ) ;
1921
20- #[ cfg( feature = "bios" ) ]
21- {
22- let bios_boot_sector_path = build_bios_boot_sector ( & out_dir) ;
23- println ! (
24- "cargo:rustc-env=BIOS_BOOT_SECTOR_PATH={}" ,
25- bios_boot_sector_path. display( )
26- ) ;
27- let bios_stage_2_path = build_bios_stage_2 ( & out_dir) ;
28- println ! (
29- "cargo:rustc-env=BIOS_STAGE_2_PATH={}" ,
30- bios_stage_2_path. display( )
31- ) ;
22+ let bios_boot_sector_path = build_bios_boot_sector ( & out_dir) ;
23+ println ! (
24+ "cargo:rustc-env=BIOS_BOOT_SECTOR_PATH={}" ,
25+ bios_boot_sector_path. display( )
26+ ) ;
27+ let bios_stage_2_path = build_bios_stage_2 ( & out_dir) ;
28+ println ! (
29+ "cargo:rustc-env=BIOS_STAGE_2_PATH={}" ,
30+ bios_stage_2_path. display( )
31+ ) ;
3232
33- let bios_stage_3_path = build_bios_stage_3 ( & out_dir) ;
34- println ! (
35- "cargo:rustc-env=BIOS_STAGE_3_PATH={}" ,
36- bios_stage_3_path. display( )
37- ) ;
33+ let bios_stage_3_path = build_bios_stage_3 ( & out_dir) ;
34+ println ! (
35+ "cargo:rustc-env=BIOS_STAGE_3_PATH={}" ,
36+ bios_stage_3_path. display( )
37+ ) ;
3838
39- let bios_stage_4_path = build_bios_stage_4 ( & out_dir) ;
40- println ! (
41- "cargo:rustc-env=BIOS_STAGE_4_PATH={}" ,
42- bios_stage_4_path. display( )
43- ) ;
44- }
39+ let bios_stage_4_path = build_bios_stage_4 ( & out_dir) ;
40+ println ! (
41+ "cargo:rustc-env=BIOS_STAGE_4_PATH={}" ,
42+ bios_stage_4_path. display( )
43+ ) ;
4544}
4645
4746#[ cfg( not( docsrs_dummy_build) ) ]
48- #[ cfg( feature = "uefi" ) ]
4947fn build_uefi_bootloader ( out_dir : & Path ) -> PathBuf {
5048 let cargo = std:: env:: var ( "CARGO" ) . unwrap_or_else ( |_| "cargo" . into ( ) ) ;
5149 let mut cmd = Command :: new ( cargo) ;
@@ -55,7 +53,7 @@ fn build_uefi_bootloader(out_dir: &Path) -> PathBuf {
5553 cmd. arg ( "--path" ) . arg ( "uefi" ) ;
5654 println ! ( "cargo:rerun-if-changed=uefi" ) ;
5755 } else {
58- cmd. arg ( "--version" ) . arg ( BOOTLOADER_VERSION ) ;
56+ cmd. arg ( "--version" ) . arg ( BOOTLOADER_X86_64_UEFI_VERSION ) ;
5957 }
6058 cmd. arg ( "--locked" ) ;
6159 cmd. arg ( "--target" ) . arg ( "x86_64-unknown-uefi" ) ;
@@ -80,7 +78,6 @@ fn build_uefi_bootloader(out_dir: &Path) -> PathBuf {
8078}
8179
8280#[ cfg( not( docsrs_dummy_build) ) ]
83- #[ cfg( feature = "bios" ) ]
8481fn build_bios_boot_sector ( out_dir : & Path ) -> PathBuf {
8582 let cargo = std:: env:: var ( "CARGO" ) . unwrap_or_else ( |_| "cargo" . into ( ) ) ;
8683 let mut cmd = Command :: new ( cargo) ;
@@ -93,7 +90,8 @@ fn build_bios_boot_sector(out_dir: &Path) -> PathBuf {
9390 cmd. arg ( "--path" ) . arg ( & local_path) ;
9491 println ! ( "cargo:rerun-if-changed={}" , local_path. display( ) ) ;
9592 } else {
96- cmd. arg ( "--version" ) . arg ( BOOTLOADER_VERSION ) ;
93+ cmd. arg ( "--version" )
94+ . arg ( BOOTLOADER_X86_64_BIOS_BOOT_SECTOR_VERSION ) ;
9795 }
9896 cmd. arg ( "--locked" ) ;
9997 cmd. arg ( "--target" ) . arg ( "i386-code16-boot-sector.json" ) ;
@@ -123,7 +121,6 @@ fn build_bios_boot_sector(out_dir: &Path) -> PathBuf {
123121}
124122
125123#[ cfg( not( docsrs_dummy_build) ) ]
126- #[ cfg( feature = "bios" ) ]
127124fn build_bios_stage_2 ( out_dir : & Path ) -> PathBuf {
128125 let cargo = std:: env:: var ( "CARGO" ) . unwrap_or_else ( |_| "cargo" . into ( ) ) ;
129126 let mut cmd = Command :: new ( cargo) ;
@@ -136,7 +133,8 @@ fn build_bios_stage_2(out_dir: &Path) -> PathBuf {
136133 cmd. arg ( "--path" ) . arg ( & local_path) ;
137134 println ! ( "cargo:rerun-if-changed={}" , local_path. display( ) ) ;
138135 } else {
139- cmd. arg ( "--version" ) . arg ( BOOTLOADER_VERSION ) ;
136+ cmd. arg ( "--version" )
137+ . arg ( BOOTLOADER_X86_64_BIOS_STAGE_2_VERSION ) ;
140138 }
141139 cmd. arg ( "--locked" ) ;
142140 cmd. arg ( "--target" ) . arg ( "i386-code16-stage-2.json" ) ;
@@ -164,7 +162,6 @@ fn build_bios_stage_2(out_dir: &Path) -> PathBuf {
164162}
165163
166164#[ cfg( not( docsrs_dummy_build) ) ]
167- #[ cfg( feature = "bios" ) ]
168165fn build_bios_stage_3 ( out_dir : & Path ) -> PathBuf {
169166 let cargo = std:: env:: var ( "CARGO" ) . unwrap_or_else ( |_| "cargo" . into ( ) ) ;
170167 let mut cmd = Command :: new ( cargo) ;
@@ -177,7 +174,8 @@ fn build_bios_stage_3(out_dir: &Path) -> PathBuf {
177174 cmd. arg ( "--path" ) . arg ( & local_path) ;
178175 println ! ( "cargo:rerun-if-changed={}" , local_path. display( ) ) ;
179176 } else {
180- cmd. arg ( "--version" ) . arg ( BOOTLOADER_VERSION ) ;
177+ cmd. arg ( "--version" )
178+ . arg ( BOOTLOADER_X86_64_BIOS_STAGE_3_VERSION ) ;
181179 }
182180 cmd. arg ( "--locked" ) ;
183181 cmd. arg ( "--target" ) . arg ( "i686-stage-3.json" ) ;
@@ -205,7 +203,6 @@ fn build_bios_stage_3(out_dir: &Path) -> PathBuf {
205203}
206204
207205#[ cfg( not( docsrs_dummy_build) ) ]
208- #[ cfg( feature = "bios" ) ]
209206fn build_bios_stage_4 ( out_dir : & Path ) -> PathBuf {
210207 let cargo = std:: env:: var ( "CARGO" ) . unwrap_or_else ( |_| "cargo" . into ( ) ) ;
211208 let mut cmd = Command :: new ( cargo) ;
@@ -218,7 +215,8 @@ fn build_bios_stage_4(out_dir: &Path) -> PathBuf {
218215 cmd. arg ( "--path" ) . arg ( & local_path) ;
219216 println ! ( "cargo:rerun-if-changed={}" , local_path. display( ) ) ;
220217 } else {
221- cmd. arg ( "--version" ) . arg ( BOOTLOADER_VERSION ) ;
218+ cmd. arg ( "--version" )
219+ . arg ( BOOTLOADER_X86_64_BIOS_STAGE_4_VERSION ) ;
222220 }
223221 cmd. arg ( "--locked" ) ;
224222 cmd. arg ( "--target" ) . arg ( "x86_64-stage-4.json" ) ;
@@ -246,7 +244,6 @@ fn build_bios_stage_4(out_dir: &Path) -> PathBuf {
246244 convert_elf_to_bin ( elf_path)
247245}
248246
249- #[ cfg( feature = "bios" ) ]
250247fn convert_elf_to_bin ( elf_path : PathBuf ) -> PathBuf {
251248 let flat_binary_path = elf_path. with_extension ( "bin" ) ;
252249
0 commit comments