Skip to content

Commit ef36571

Browse files
Refactoring arch-specific subcrates
1 parent 87673c8 commit ef36571

File tree

25 files changed

+126
-157
lines changed

25 files changed

+126
-157
lines changed

.cargo/config

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
[alias]
2-
xbuild = "build -Zbuild-std=core"
1+
[build]
2+
target = "src/real/x86_64-real_mode.json"

Cargo.lock

Lines changed: 2 additions & 118 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,11 @@
1-
[workspace]
2-
members = [
3-
"src/shared",
4-
"src/v86",
5-
"src/bootsector",
6-
"src/stage_2",
7-
"example-kernel",
8-
"test-kernel",
9-
]
1+
[package]
2+
name = "bootloader"
3+
version = "0.1.0"
4+
authors = ["Ryland Morgan <[email protected]>"]
5+
edition = "2018"
6+
build = "build.rs"
107

11-
[profile.release]
12-
opt-level = "z"
13-
panic = "abort"
14-
lto = true
8+
[dependencies]
159

16-
[profile.release.package.bootsector]
17-
opt-level = "s"
18-
codegen-units = 1
10+
[build-dependencies]
11+
llvm-tools = "0.1"

src/stage_2/build.rs renamed to build.rs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,28 @@ fn main() {
1111
.expect("llvm-objcopy not found");
1212

1313
build_subproject(
14-
Path::new("../bootsector"),
14+
Path::new("src/real/bootsector"),
1515
&[
1616
"_start",
1717
"real_mode_println",
1818
"no_int13h_extensions",
1919
"dap_load_failed",
2020
],
21-
"x86_64-real_mode.json",
21+
"real/x86_64-real_mode.json",
2222
&out_dir,
2323
&objcopy,
2424
);
25+
26+
build_subproject(
27+
Path::new("src/real/stage2"),
28+
&[
29+
"second_stage",
30+
],
31+
"real/x86_64-real_mode.json",
32+
&out_dir,
33+
&objcopy,
34+
);
35+
2536
}
2637

2738
fn build_subproject(
@@ -42,11 +53,13 @@ fn build_subproject(
4253
// build
4354
let mut cmd = Command::new("cargo");
4455
cmd.arg("xbuild").arg("--release");
56+
4557
cmd.arg("--verbose");
58+
4659
cmd.arg(format!("--manifest-path={}", manifest_path.display()));
4760
cmd.arg(format!(
4861
"--target={}",
49-
dir.join("../..").join(target).display()
62+
dir.join("..").join("..").join(target).display()
5063
));
5164
cmd.arg("-Z").arg("unstable-options");
5265
cmd.arg("--out-dir").arg(&out_dir);
@@ -58,7 +71,7 @@ fn build_subproject(
5871
out_path.join("target").join(dir_name).join("sysroot"),
5972
);
6073
let status = cmd.status().unwrap();
61-
assert!(status.success());
74+
assert!(status.success(), "Subcrate build failed!");
6275

6376
// localize symbols
6477
let mut cmd = Command::new(objcopy);

src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#![no_std]
2+
#![no_main]

src/v86/Cargo.toml renamed to src/protected/v86/Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,3 @@ authors = ["Ryland Morgan <[email protected]>"]
55
edition = "2018"
66

77
[dependencies]
8-
bitflags = "1.2.1"
9-
bit_field = "0.10.0"

src/v86/src/lib.rs renamed to src/protected/v86/src/lib.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
1-
#![feature(abi_x86_interrupt)]
2-
#![feature(const_fn)]
3-
#![feature(llvm_asm)]
41
#![no_std]
2+
53
// FIXME
64
#![allow(dead_code, unused_imports)]
75

86
use core::slice;
97

10-
pub mod gdt;
11-
pub mod idt;
12-
138
const EFLAG_IF: u32 = 0x00000200;
149
const EFLAG_VM: u32 = 0x00020000;
1510
/*

src/real/Cargo.lock

Lines changed: 58 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/real/Cargo.toml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[workspace]
2+
members = [
3+
"bootsector",
4+
"stage_2"
5+
]
6+
7+
[profile.release]
8+
opt-level = "z"
9+
panic = "abort"
10+
lto = true
11+
12+
[profile.release.package.bootsector]
13+
opt-level = "s"
14+
codegen-units = 1

src/bootsector/Cargo.toml renamed to src/real/bootsector/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ name = "bootsector"
1111
crate-type = ["staticlib"]
1212

1313
[dependencies]
14-
shared = { path = "../shared" }
14+
shared = { path = "../../shared" }

0 commit comments

Comments
 (0)