From e93361ead22f51fcd3ef0bd4ba86544e68ca4deb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Kr=C3=B6ning?= Date: Wed, 15 May 2024 19:19:37 +0200 Subject: [PATCH 1/5] refactor(xtask): add `Arch::all` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Kröning --- xtask/src/arch.rs | 4 ++++ xtask/src/clippy.rs | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/xtask/src/arch.rs b/xtask/src/arch.rs index 52c743eb6f..90da9898c3 100644 --- a/xtask/src/arch.rs +++ b/xtask/src/arch.rs @@ -15,6 +15,10 @@ pub enum Arch { } impl Arch { + pub fn all() -> &'static [Self] { + &[Self::X86_64, Self::Aarch64, Self::Riscv64] + } + pub fn install(&self) -> Result<()> { let sh = crate::sh()?; let triple = self.triple(); diff --git a/xtask/src/clippy.rs b/xtask/src/clippy.rs index b241ed53a0..0d68b4d11e 100644 --- a/xtask/src/clippy.rs +++ b/xtask/src/clippy.rs @@ -12,7 +12,7 @@ impl Clippy { pub fn run(self) -> Result<()> { let sh = crate::sh()?; - for target in [Arch::X86_64, Arch::Aarch64, Arch::Riscv64] { + for target in Arch::all() { target.install()?; let triple = target.triple(); @@ -29,7 +29,7 @@ impl Clippy { .arg("--features=acpi,fsgsbase,pci,smp,vga") .run()?; - if target == Arch::Riscv64 { + if *target == Arch::Riscv64 { cmd!(sh, "cargo clippy --target={triple}") .arg("--no-default-features") .arg("--features=gem-net,tcp") From a461947c097200a489c03da5bb5669e2d23eec15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Kr=C3=B6ning?= Date: Wed, 15 May 2024 19:19:53 +0200 Subject: [PATCH 2/5] feat(xtask): add `xtask doc` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Kröning --- xtask/src/doc.rs | 30 ++++++++++++++++++++++++++++++ xtask/src/main.rs | 3 +++ 2 files changed, 33 insertions(+) create mode 100644 xtask/src/doc.rs diff --git a/xtask/src/doc.rs b/xtask/src/doc.rs new file mode 100644 index 0000000000..7d7adddcb9 --- /dev/null +++ b/xtask/src/doc.rs @@ -0,0 +1,30 @@ +use anyhow::Result; +use clap::Args; +use xshell::cmd; + +use crate::arch::Arch; + +/// Run rustdoc for all targets. +#[derive(Args)] +pub struct Doc; + +impl Doc { + pub fn run(self) -> Result<()> { + let sh = crate::sh()?; + + let mut doc = cmd!( + sh, + "cargo doc --package hermit-kernel --no-deps --document-private-items" + ); + + for arch in Arch::all() { + arch.install()?; + let triple = arch.triple(); + doc = doc.arg(format!("--target={triple}")); + } + + doc.run()?; + + Ok(()) + } +} diff --git a/xtask/src/main.rs b/xtask/src/main.rs index af71cf868c..f8a6df8271 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -8,6 +8,7 @@ mod build; mod cargo_build; mod ci; mod clippy; +mod doc; use std::path::Path; @@ -22,6 +23,7 @@ enum Cli { #[command(subcommand)] Ci(ci::Ci), Clippy(clippy::Clippy), + Doc(doc::Doc), } impl Cli { @@ -30,6 +32,7 @@ impl Cli { Self::Build(build) => build.run(), Self::Ci(ci) => ci.run(), Self::Clippy(clippy) => clippy.run(), + Self::Doc(doc) => doc.run(), } } } From e70b0f1ef3158f666b0c86c7c4406b3a9f230747 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Kr=C3=B6ning?= Date: Wed, 15 May 2024 19:28:26 +0200 Subject: [PATCH 3/5] refactor(xtask/clippy): rename `target` to `arch` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Kröning --- xtask/src/clippy.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/xtask/src/clippy.rs b/xtask/src/clippy.rs index 0d68b4d11e..34c5dc464e 100644 --- a/xtask/src/clippy.rs +++ b/xtask/src/clippy.rs @@ -12,10 +12,10 @@ impl Clippy { pub fn run(self) -> Result<()> { let sh = crate::sh()?; - for target in Arch::all() { - target.install()?; + for arch in Arch::all() { + arch.install()?; - let triple = target.triple(); + let triple = arch.triple(); cmd!(sh, "cargo clippy --target={triple}").run()?; cmd!(sh, "cargo clippy --target={triple}") .arg("--no-default-features") @@ -29,7 +29,7 @@ impl Clippy { .arg("--features=acpi,fsgsbase,pci,smp,vga") .run()?; - if *target == Arch::Riscv64 { + if *arch == Arch::Riscv64 { cmd!(sh, "cargo clippy --target={triple}") .arg("--no-default-features") .arg("--features=gem-net,tcp") From 0ae465a4fa088b694badcefeef83723423e4b963 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Kr=C3=B6ning?= Date: Wed, 15 May 2024 19:20:50 +0200 Subject: [PATCH 4/5] ci: use xtask for doc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Kröning --- .github/workflows/ci.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f95064be82..30a35c6400 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -63,14 +63,10 @@ jobs: steps: - uses: actions/checkout@v4 - uses: mkroening/rust-toolchain-toml@main - - run: rustup target add x86_64-unknown-none aarch64-unknown-none-softfloat - uses: Swatinem/rust-cache@v2 with: save-if: ${{ github.ref == 'refs/heads/main' }} - - name: Check docs - run: | - cargo doc --package hermit-kernel --no-deps --document-private-items --target x86_64-unknown-none - cargo doc --package hermit-kernel --no-deps --document-private-items --target aarch64-unknown-none-softfloat --no-default-features + - run: cargo xtask doc build: name: Build From 4b0bbd6e5dc00e78dd3347ff6c6d8f2db9a17cd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Kr=C3=B6ning?= Date: Wed, 15 May 2024 19:23:07 +0200 Subject: [PATCH 5/5] ci: rename `check-docs` job to `doc` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Kröning --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 30a35c6400..554985ecef 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -57,8 +57,8 @@ jobs: - run: rustup component add rustfmt - run: cargo fmt -- --check - check-docs: - name: Check docs + doc: + name: Doc runs-on: ubuntu-latest steps: - uses: actions/checkout@v4