@@ -3,49 +3,47 @@ use std::{
3
3
process:: Command ,
4
4
} ;
5
5
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" ) ;
7
12
8
13
fn main ( ) {
9
14
let out_dir = PathBuf :: from ( std:: env:: var ( "OUT_DIR" ) . unwrap ( ) ) ;
10
15
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
+ ) ;
19
21
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
+ ) ;
32
32
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
+ ) ;
38
38
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
+ ) ;
45
44
}
46
45
47
46
#[ cfg( not( docsrs_dummy_build) ) ]
48
- #[ cfg( feature = "uefi" ) ]
49
47
fn build_uefi_bootloader ( out_dir : & Path ) -> PathBuf {
50
48
let cargo = std:: env:: var ( "CARGO" ) . unwrap_or_else ( |_| "cargo" . into ( ) ) ;
51
49
let mut cmd = Command :: new ( cargo) ;
@@ -55,7 +53,7 @@ fn build_uefi_bootloader(out_dir: &Path) -> PathBuf {
55
53
cmd. arg ( "--path" ) . arg ( "uefi" ) ;
56
54
println ! ( "cargo:rerun-if-changed=uefi" ) ;
57
55
} else {
58
- cmd. arg ( "--version" ) . arg ( BOOTLOADER_VERSION ) ;
56
+ cmd. arg ( "--version" ) . arg ( BOOTLOADER_X86_64_UEFI_VERSION ) ;
59
57
}
60
58
cmd. arg ( "--locked" ) ;
61
59
cmd. arg ( "--target" ) . arg ( "x86_64-unknown-uefi" ) ;
@@ -80,7 +78,6 @@ fn build_uefi_bootloader(out_dir: &Path) -> PathBuf {
80
78
}
81
79
82
80
#[ cfg( not( docsrs_dummy_build) ) ]
83
- #[ cfg( feature = "bios" ) ]
84
81
fn build_bios_boot_sector ( out_dir : & Path ) -> PathBuf {
85
82
let cargo = std:: env:: var ( "CARGO" ) . unwrap_or_else ( |_| "cargo" . into ( ) ) ;
86
83
let mut cmd = Command :: new ( cargo) ;
@@ -93,7 +90,8 @@ fn build_bios_boot_sector(out_dir: &Path) -> PathBuf {
93
90
cmd. arg ( "--path" ) . arg ( & local_path) ;
94
91
println ! ( "cargo:rerun-if-changed={}" , local_path. display( ) ) ;
95
92
} else {
96
- cmd. arg ( "--version" ) . arg ( BOOTLOADER_VERSION ) ;
93
+ cmd. arg ( "--version" )
94
+ . arg ( BOOTLOADER_X86_64_BIOS_BOOT_SECTOR_VERSION ) ;
97
95
}
98
96
cmd. arg ( "--locked" ) ;
99
97
cmd. arg ( "--target" ) . arg ( "i386-code16-boot-sector.json" ) ;
@@ -123,7 +121,6 @@ fn build_bios_boot_sector(out_dir: &Path) -> PathBuf {
123
121
}
124
122
125
123
#[ cfg( not( docsrs_dummy_build) ) ]
126
- #[ cfg( feature = "bios" ) ]
127
124
fn build_bios_stage_2 ( out_dir : & Path ) -> PathBuf {
128
125
let cargo = std:: env:: var ( "CARGO" ) . unwrap_or_else ( |_| "cargo" . into ( ) ) ;
129
126
let mut cmd = Command :: new ( cargo) ;
@@ -136,7 +133,8 @@ fn build_bios_stage_2(out_dir: &Path) -> PathBuf {
136
133
cmd. arg ( "--path" ) . arg ( & local_path) ;
137
134
println ! ( "cargo:rerun-if-changed={}" , local_path. display( ) ) ;
138
135
} else {
139
- cmd. arg ( "--version" ) . arg ( BOOTLOADER_VERSION ) ;
136
+ cmd. arg ( "--version" )
137
+ . arg ( BOOTLOADER_X86_64_BIOS_STAGE_2_VERSION ) ;
140
138
}
141
139
cmd. arg ( "--locked" ) ;
142
140
cmd. arg ( "--target" ) . arg ( "i386-code16-stage-2.json" ) ;
@@ -164,7 +162,6 @@ fn build_bios_stage_2(out_dir: &Path) -> PathBuf {
164
162
}
165
163
166
164
#[ cfg( not( docsrs_dummy_build) ) ]
167
- #[ cfg( feature = "bios" ) ]
168
165
fn build_bios_stage_3 ( out_dir : & Path ) -> PathBuf {
169
166
let cargo = std:: env:: var ( "CARGO" ) . unwrap_or_else ( |_| "cargo" . into ( ) ) ;
170
167
let mut cmd = Command :: new ( cargo) ;
@@ -177,7 +174,8 @@ fn build_bios_stage_3(out_dir: &Path) -> PathBuf {
177
174
cmd. arg ( "--path" ) . arg ( & local_path) ;
178
175
println ! ( "cargo:rerun-if-changed={}" , local_path. display( ) ) ;
179
176
} else {
180
- cmd. arg ( "--version" ) . arg ( BOOTLOADER_VERSION ) ;
177
+ cmd. arg ( "--version" )
178
+ . arg ( BOOTLOADER_X86_64_BIOS_STAGE_3_VERSION ) ;
181
179
}
182
180
cmd. arg ( "--locked" ) ;
183
181
cmd. arg ( "--target" ) . arg ( "i686-stage-3.json" ) ;
@@ -205,7 +203,6 @@ fn build_bios_stage_3(out_dir: &Path) -> PathBuf {
205
203
}
206
204
207
205
#[ cfg( not( docsrs_dummy_build) ) ]
208
- #[ cfg( feature = "bios" ) ]
209
206
fn build_bios_stage_4 ( out_dir : & Path ) -> PathBuf {
210
207
let cargo = std:: env:: var ( "CARGO" ) . unwrap_or_else ( |_| "cargo" . into ( ) ) ;
211
208
let mut cmd = Command :: new ( cargo) ;
@@ -218,7 +215,8 @@ fn build_bios_stage_4(out_dir: &Path) -> PathBuf {
218
215
cmd. arg ( "--path" ) . arg ( & local_path) ;
219
216
println ! ( "cargo:rerun-if-changed={}" , local_path. display( ) ) ;
220
217
} else {
221
- cmd. arg ( "--version" ) . arg ( BOOTLOADER_VERSION ) ;
218
+ cmd. arg ( "--version" )
219
+ . arg ( BOOTLOADER_X86_64_BIOS_STAGE_4_VERSION ) ;
222
220
}
223
221
cmd. arg ( "--locked" ) ;
224
222
cmd. arg ( "--target" ) . arg ( "x86_64-stage-4.json" ) ;
@@ -246,7 +244,6 @@ fn build_bios_stage_4(out_dir: &Path) -> PathBuf {
246
244
convert_elf_to_bin ( elf_path)
247
245
}
248
246
249
- #[ cfg( feature = "bios" ) ]
250
247
fn convert_elf_to_bin ( elf_path : PathBuf ) -> PathBuf {
251
248
let flat_binary_path = elf_path. with_extension ( "bin" ) ;
252
249
0 commit comments