Skip to content

Commit 9be5ca8

Browse files
Merge branch 'rewrite-arch-dirs' into rewrite
2 parents 3f6ff29 + 21acd1b commit 9be5ca8

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

build.rs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,18 @@ use std::process::Command;
88

99
fn main() {
1010
// Read environment variables set by cargo
11-
let out_dir_path = env::var("OUT_DIR").expect("Missing OUT_DIR environment variable");
12-
let out_dir = Path::new(&out_dir_path);
13-
1411
let cargo_path = env::var("CARGO").expect("Missing CARGO environment variable");
1512
let cargo = Path::new(&cargo_path);
1613

1714
let manifest_dir_path =
1815
env::var("CARGO_MANIFEST_DIR").expect("Missing CARGO_MANIFEST_DIR environment variable");
1916
let manifest_dir = Path::new(&manifest_dir_path);
2017

18+
// Find the root project target dir
19+
let current_dir = env::current_dir().expect("Couldn't get current directory");
20+
let target_dir_rel = manifest_dir.join("target");
21+
let target_dir = current_dir.join(target_dir_rel);
22+
2123
// Find the objcopy binary
2224
let llvm_tools = LlvmTools::new().expect("LLVM tools not found");
2325
let objcopy = llvm_tools
@@ -34,7 +36,7 @@ fn main() {
3436
"dap_load_failed",
3537
],
3638
"../i8086-real_mode.json",
37-
&out_dir,
39+
&target_dir,
3840
&objcopy,
3941
&cargo,
4042
);
@@ -44,7 +46,7 @@ fn main() {
4446
Path::new("src/real/stage_2"),
4547
&["second_stage"],
4648
"../i8086-real_mode.json",
47-
&out_dir,
49+
&target_dir,
4850
&objcopy,
4951
&cargo,
5052
);
@@ -54,7 +56,7 @@ fn build_subproject(
5456
subproject_dir: &Path,
5557
global_symbols: &[&str],
5658
target_file_path: &str,
57-
root_out_dir: &Path,
59+
root_target_dir: &Path,
5860
objcopy: &Path,
5961
cargo: &Path,
6062
) {
@@ -66,7 +68,8 @@ fn build_subproject(
6668
let target_file = Path::new(&target_file_path)
6769
.file_stem()
6870
.expect("Couldn't get target file stem");
69-
let target_dir = root_out_dir.join("target").join(&subproject_name);
71+
72+
let target_dir = root_target_dir.join(&subproject_name);
7073

7174
// We have to export at least 1 symbol
7275
assert!(
@@ -83,6 +86,9 @@ fn build_subproject(
8386
// Build in release mode
8487
build_cmd.arg("build").arg("--release");
8588

89+
// Very verbose (build script output only shows if you use `-vv` or it fails anyway)
90+
build_cmd.arg("-vv");
91+
8692
// Cross-compile core (cargo-xbuild no longer needed)
8793
build_cmd.arg("-Zbuild-std=core");
8894

0 commit comments

Comments
 (0)