From 35a77f39abea761114c701cb117f239cea3fc7eb Mon Sep 17 00:00:00 2001 From: Paul Pan Date: Fri, 16 Feb 2024 20:59:09 +0800 Subject: [PATCH] feat: switch to cargo-make --- .github/workflows/rust.yml | 24 ++++++++++++++---------- .gitignore | 1 + Cargo.toml | 3 --- Makefile.toml | 18 ++++++++++++++++++ kernel/.gitignore | 2 ++ Cargo.lock => kernel/Cargo.lock | 23 +++++++++++++++-------- kernel/Cargo.toml | 5 +++-- kernel/build.rs | 4 ++-- 8 files changed, 55 insertions(+), 25 deletions(-) delete mode 100644 Cargo.toml create mode 100644 Makefile.toml create mode 100644 kernel/.gitignore rename Cargo.lock => kernel/Cargo.lock (93%) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 8839654..64f778f 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -10,17 +10,21 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: dtolnay/rust-toolchain@master + + - name: Install Qemu + uses: ConorMacBride/install-package@v1 + with: + apt: qemu-system + + - name: Install Rust + uses: dtolnay/rust-toolchain@master with: toolchain: nightly targets: riscv64imac-unknown-none-elf components: clippy - - uses: ConorMacBride/install-package@v1 - with: - apt: qemu-system - - name: Clippy - run: cargo clippy - - name: Build - run: cargo build --verbose - - name: Test - run: cargo test + + - name: Install cargo-make + run: cargo install cargo-make + + - name: Run CI Flow + run: cargo make ci-flow diff --git a/.gitignore b/.gitignore index ea8c4bf..f419dc7 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ +/.idea /target diff --git a/Cargo.toml b/Cargo.toml deleted file mode 100644 index 47c7f15..0000000 --- a/Cargo.toml +++ /dev/null @@ -1,3 +0,0 @@ -[workspace] -resolver = "2" -members = ["kernel"] diff --git a/Makefile.toml b/Makefile.toml new file mode 100644 index 0000000..44fa43a --- /dev/null +++ b/Makefile.toml @@ -0,0 +1,18 @@ +[env] +CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = true +CARGO_MAKE_WORKSPACE_EMULATION = true +CARGO_MAKE_CRATE_WORKSPACE_MEMBERS = [ + "kernel" +] + +[tasks.clipppy] +install_crate = "clippy" +command = "cargo" +args = ["clippy"] +dependencies = ["fmt"] + +[tasks.build] +args = ["build"] + +[tasks.test] +args = ["test"] diff --git a/kernel/.gitignore b/kernel/.gitignore new file mode 100644 index 0000000..f419dc7 --- /dev/null +++ b/kernel/.gitignore @@ -0,0 +1,2 @@ +/.idea +/target diff --git a/Cargo.lock b/kernel/Cargo.lock similarity index 93% rename from Cargo.lock rename to kernel/Cargo.lock index c13ef1a..996a56a 100644 --- a/Cargo.lock +++ b/kernel/Cargo.lock @@ -26,6 +26,12 @@ version = "2.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + [[package]] name = "critical-section" version = "1.1.2" @@ -42,14 +48,15 @@ checksum = "361a90feb7004eca4019fb28352a9465666b24f840f5c3cddf0ff13920590b89" name = "kernel" version = "0.1.0" dependencies = [ - "bitflags 2.4.2", - "lazy_static", - "log", - "riscv", - "sbi-rt", - "spin 0.9.8", - "static_assertions", - "uart_16550", + "bitflags 2.4.2", + "cfg-if", + "lazy_static", + "log", + "riscv", + "sbi-rt", + "spin 0.9.8", + "static_assertions", + "uart_16550", ] [[package]] diff --git a/kernel/Cargo.toml b/kernel/Cargo.toml index 878adfa..778e73c 100644 --- a/kernel/Cargo.toml +++ b/kernel/Cargo.toml @@ -13,7 +13,6 @@ arch_riscv32 = [] board_default = [] board_virt = [] -board_thead = [] log_color = [] @@ -25,9 +24,10 @@ panic = "abort" [profile.release] panic = "abort" +lto = "thin" [dependencies] -bitflags = "2.4.1" +bitflags = "2.4.2" lazy_static = { version = "1.4.0", features = ["spin_no_std"] } log = "0.4" riscv = { version = "0.11.1", features = ["s-mode"] } @@ -35,3 +35,4 @@ sbi-rt = { version = "0.0.3", features = ["legacy"] } spin = "0.9.8" static_assertions = "1.1.0" uart_16550 = "0.3" +cfg-if = "1.0.0" diff --git a/kernel/build.rs b/kernel/build.rs index 14b049a..c0ba1f6 100644 --- a/kernel/build.rs +++ b/kernel/build.rs @@ -9,11 +9,11 @@ fn main() { const TARGET_LDS: &[TargetConfig] = &[ TargetConfig { target: "riscv64", - lds: "kernel/src/arch/riscv/linker.ld", + lds: "src/arch/riscv/linker.ld", }, TargetConfig { target: "riscv32", - lds: "kernel/src/arch/riscv/linker.ld", + lds: "src/arch/riscv/linker.ld", }, ];