Skip to content

Commit

Permalink
[Opt] project structure refactored with workspace
Browse files Browse the repository at this point in the history
  • Loading branch information
M4tsuri committed Nov 21, 2021
1 parent 50fabe7 commit adee611
Show file tree
Hide file tree
Showing 43 changed files with 505 additions and 21 deletions.
File renamed without changes.
475 changes: 475 additions & 0 deletions Cargo.lock

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[workspace]

members = [
"bootloader/shared",
"bootloader/stage_1",
"bootloader/stage_2",
"bootloader/stage_3",
"kernel",
"i386",
"kbuild"
]
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
i386 = { path = "../../../../i386" }
i386 = { path = "../../i386" }
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
i386 = { path = "../../../../i386" }
i386 = { path = "../../i386" }
shared = { path = "../shared" }
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"features": "-mmx,-sse,+soft-float",
"pre-link-args": {
"ld.lld": [
"--script=stage_2.ld"
"--script=bootloader/stage_1/stage_1.ld"
]
}
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
i386 = { path = "../../../../i386" }
i386 = { path = "../../i386" }
shared = { path = "../shared" }
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"features": "-mmx,-sse,+soft-float",
"pre-link-args": {
"ld.lld": [
"--script=stage_1.ld"
"--script=bootloader/stage_2/stage_2.ld"
]
}
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
i386 = { path = "../../../../i386" }
i386 = { path = "../../i386" }
shared = { path = "../shared" }
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"features": "-mmx,-sse,+soft-float",
"pre-link-args": {
"ld.lld": [
"--script=stage_3.ld"
"--script=bootloader/stage_3/stage_3.ld"
]
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
14 changes: 7 additions & 7 deletions kernel/kbuild/src/bootloader.rs → kbuild/src/bootloader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ lazy_static! {

pub fn build() -> Vec<PathBuf> {
[
"bios/shared/src/layout.rs.temp",
"bios/stage_1/stage_1.ld.temp",
"bios/stage_2/stage_2.ld.temp",
"bios/stage_3/stage_3.ld.temp",
"shared/src/layout.rs.temp",
"stage_1/stage_1.ld.temp",
"stage_2/stage_2.ld.temp",
"stage_3/stage_3.ld.temp",
].map(|x| PREFIX.join(x))
.map(|x| apply_template(&LAYOUT_CONF, &x));
[
"bios/stage_1",
"bios/stage_2",
"bios/stage_3",
"stage_1",
"stage_2",
"stage_3",
].map(|x| PREFIX.join(x))
.map(|x| build_subproject(&x, &x.join("target.json")))
.to_vec()
Expand Down
5 changes: 1 addition & 4 deletions kernel/kbuild/src/config.rs → kbuild/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,5 @@ lazy_static! {
.tool(&exe("llvm-objcopy"))
.expect("llvm-objcopy not found")
};
pub static ref TARGET: PathBuf = {
let cur = env::current_dir().unwrap();
cur.join("target")
};
pub static ref TARGET: PathBuf = ROOT_PROJ.join("target");
}
File renamed without changes.
5 changes: 3 additions & 2 deletions kernel/kbuild/src/main.rs → kbuild/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use std::process::Command;
use std::str::FromStr;
extern crate clap;
use clap::{Arg, value_t};
use config::ROOT_PROJ;

mod bootloader;
mod kernel;
Expand Down Expand Up @@ -78,8 +79,8 @@ fn main() {
.unwrap_or_else(|e| e.exit());

match ty {
Choice::Build => build(&kernel::PREFIX.join("target").join("orusts")),
Choice::Run => run(&kernel::PREFIX.join("target").join("orusts"))
Choice::Build => build(&ROOT_PROJ.join("target").join("orusts")),
Choice::Run => run(&ROOT_PROJ.join("target").join("orusts"))
}

println!("Build Done.");
Expand Down
2 changes: 1 addition & 1 deletion kernel/target.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"features": "-mmx,-sse,+soft-float",
"pre-link-args": {
"ld.lld": [
"--script=kernel.ld"
"--script=kernel/kernel.ld"
]
}
}
File renamed without changes.

0 comments on commit adee611

Please sign in to comment.