Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions hermit-builtins/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ libm = "0.2"

[lib]
crate-type = ["staticlib"]
harness = false

[workspace]
1 change: 1 addition & 0 deletions hermit-builtins/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![no_std]
#![no_main]
#![feature(linkage)]

pub mod math;
Expand Down
7 changes: 3 additions & 4 deletions xtask/src/arch.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::fmt;
use std::{fmt, io};

use anyhow::Result;
use clap::ValueEnum;

/// Target architecture.
Expand All @@ -22,7 +21,7 @@ impl Arch {
&[Self::X86_64, Self::Aarch64, Self::Riscv64]
}

pub fn install(&self) -> Result<()> {
pub fn install(&self) -> io::Result<()> {
if self.tier() > 2 {
return Ok(());
}
Expand All @@ -37,7 +36,7 @@ impl Arch {
Ok(())
}

pub fn install_for_build(&self) -> Result<()> {
pub fn install_for_build(&self) -> io::Result<()> {
if self == &Self::X86_64 {
self.install()?;
}
Expand Down
78 changes: 42 additions & 36 deletions xtask/src/clippy.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use std::ffi::OsStr;
use std::io;

use anyhow::Result;
use clap::Args;
use xshell::cmd;

use crate::arch::Arch;

Expand All @@ -10,56 +12,60 @@ pub struct Clippy;

impl Clippy {
pub fn run(self) -> Result<()> {
let sh = crate::sh()?;

for arch in Arch::all() {
arch.install()?;

let triple = arch.triple();
let clippy = || cmd!(sh, "cargo clippy --target={triple} --all-targets");
let target = format!("--target={triple}");
let target = target.as_str();

clippy().run()?;
clippy().arg("--features=common-os").run()?;
clippy()
.arg("--features=acpi,dns,fsgsbase,pci,smp,vga")
.run()?;
clippy().arg("--no-default-features").run()?;
clippy().arg("--all-features").run()?;
clippy()
.arg("--no-default-features")
.arg("--features=tcp")
.run()?;
clippy()
.arg("--no-default-features")
.arg("--features=acpi,fsgsbase,pci,smp,vga")
.run()?;
clippy([target])?;
clippy([target, "--features=common-os"])?;
clippy([target, "--features=acpi,dns,fsgsbase,pci,smp,vga"])?;
clippy([target, "--no-default-features"])?;
clippy([target, "--all-features"])?;
clippy([target, "--no-default-features", "--features=tcp"])?;
clippy([
target,
"--no-default-features",
"--features=acpi,fsgsbase,pci,smp,vga",
])?;

match *arch {
Arch::X86_64 => {
clippy().arg("--features=shell").run()?;
}
Arch::X86_64 => clippy([target, "--features=shell"])?,
Arch::Aarch64 | Arch::Aarch64Be => {}
Arch::Riscv64 => {
clippy()
.arg("--no-default-features")
.arg("--features=gem-net,tcp")
.run()?;
clippy([target, "--no-default-features", "--features=gem-net,tcp"])?;
}
}

clippy()
.arg("--no-default-features")
.arg("--features=acpi,fsgsbase,newlib,smp,vga")
.run()?;
clippy([
target,
"--no-default-features",
"--features=acpi,fsgsbase,newlib,smp,vga",
])?;
}

cmd!(sh, "cargo clippy")
.arg("--manifest-path=hermit-builtins/Cargo.toml")
.arg("--target=x86_64-unknown-none")
.run()?;
clippy([
"--manifest-path=hermit-builtins/Cargo.toml",
"--target=x86_64-unknown-none",
])?;

cmd!(sh, "cargo clippy --package xtask").run()?;
clippy(["--package=xtask"])?;

Ok(())
}
}

fn clippy<I, S>(args: I) -> io::Result<()>
where
I: IntoIterator<Item = S>,
S: AsRef<OsStr>,
{
let mut cmd = crate::cargo();
cmd.arg("clippy").arg("--all-targets").args(args);

eprintln!("$ {cmd:?}");
cmd.spawn()?.wait()?;

Ok(())
}
45 changes: 25 additions & 20 deletions xtask/src/doc.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use std::ffi::OsStr;
use std::io;

use anyhow::Result;
use clap::Args;
use xshell::cmd;

use crate::arch::Arch;

Expand All @@ -10,31 +12,34 @@ pub struct Doc;

impl Doc {
pub fn run(self) -> Result<()> {
let sh = crate::sh()?;

for arch in Arch::all() {
arch.install()?;
let triple = arch.triple();
let target = format!("--target={triple}");
let target = target.as_str();

cmd!(sh, "cargo doc --target={triple}")
.arg("--no-deps")
.arg("--document-private-items")
.arg("--package=hermit-kernel")
.run()?;

cmd!(sh, "cargo doc --target={triple}")
.arg("--no-deps")
.arg("--document-private-items")
.arg("--manifest-path=hermit-builtins/Cargo.toml")
.run()?;
doc([target, "--package=hermit-kernel"])?;
doc([target, "--manifest-path=hermit-builtins/Cargo.toml"])?;
}

cmd!(sh, "cargo doc")
.arg("--no-deps")
.arg("--document-private-items")
.arg("--package=xtask")
.run()?;

doc(["--package=xtask"])?;
Ok(())
}
}

fn doc<I, S>(args: I) -> io::Result<()>
where
I: IntoIterator<Item = S>,
S: AsRef<OsStr>,
{
let mut cmd = crate::cargo();
cmd.arg("doc");
cmd.arg("--no-deps");
cmd.arg("--document-private-items");
cmd.args(args);

eprintln!("$ {cmd:?}");
cmd.spawn()?.wait()?;

Ok(())
}