Skip to content

Commit

Permalink
Try #378:
Browse files Browse the repository at this point in the history
  • Loading branch information
bors[bot] authored Mar 26, 2022
2 parents 032bdb4 + 1855700 commit 17e3adf
Show file tree
Hide file tree
Showing 14 changed files with 414 additions and 30 deletions.
12 changes: 2 additions & 10 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
[unstable]
# Keep in sync with CI!
build-std = ["core", "alloc"]
build-std-features = ["compiler-builtins-mem"]

[build]
target = "targets/x86_64-unknown-none-hermitkernel.json"
rustflags = [
"-Zmutable-noalias=no"
]
[alias]
xtask = "run --package xtask --"

[target.x86_64-unknown-none-hermitkernel]
runner = "tests/hermit_test_runner.py"
7 changes: 3 additions & 4 deletions .github/workflows/aarch64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,12 @@ jobs:
matrix:
os: [ubuntu-latest]
steps:
- name: Install cargo-binutils
run: cargo install cargo-binutils
- name: Checkout rusty-hermit
uses: actions/checkout@v3
with:
repository: hermitcore/rusty-hermit
submodules: true
ref: 6358817662907510d637c6f1798171eff664e60c
- name: Remove libhermit-rs submodule
run: git rm -r libhermit-rs
- name: Checkout libhermit-rs
Expand All @@ -41,9 +40,9 @@ jobs:
run: rustup show
- name: Build minimal kernel
working-directory: libhermit-rs
run: cargo build --no-default-features --target targets/aarch64-unknown-none-hermitkernel.json -Z build-std=core,alloc
run: cargo xtask build --arch aarch64 --no-default-features
- name: Build dev profile
run: cargo build --target aarch64-unknown-hermit -p hello_world
run: cargo build -Zbuild-std=core,alloc,std,panic_abort -Zbuild-std-features=compiler-builtins-mem --target aarch64-unknown-hermit --package hello_world
- name: Build loader
run: make arch=aarch64
working-directory: loader
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/clippy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on:

env:
CARGO_TERM_COLOR: always
RUSTFLAGS: -Dwarnings

jobs:
clippy:
Expand All @@ -24,4 +25,4 @@ jobs:
sudo apt-get update
sudo apt-get install nasm
- name: Clippy
run: cargo clippy -- -D warnings
run: cargo xtask clippy
4 changes: 2 additions & 2 deletions .github/workflows/doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ jobs:
env:
RUSTDOCFLAGS: -D warnings
run: |
cargo doc --no-deps --document-private-items --target targets/x86_64-unknown-none-hermitkernel.json
cargo doc --no-deps --document-private-items --target targets/aarch64-unknown-none-hermitkernel.json
cargo doc -Z build-std=core,alloc --package rusty-hermit --no-deps --document-private-items --target targets/x86_64-unknown-none-hermitkernel.json
cargo doc -Z build-std=core,alloc --package rusty-hermit --no-deps --document-private-items --target targets/aarch64-unknown-none-hermitkernel.json
2 changes: 1 addition & 1 deletion .github/workflows/publish_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
sudo apt-get update
sudo apt-get install nasm
- name: Generate documentation
run: cargo doc
run: cargo doc -Z build-std=core,alloc --package rusty-hermit
- name: Generate index.html
run: |
cat > target/x86_64-unknown-none-hermitkernel/doc/index.html <<EOL
Expand Down
13 changes: 5 additions & 8 deletions .github/workflows/x86.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,12 @@ jobs:
choco install qemu nasm make
echo "C:\Program Files\qemu" >> $GITHUB_PATH
echo "C:\Program Files\NASM" >> $GITHUB_PATH
- name: Install cargo-binutils
run: cargo install cargo-binutils
- name: Checkout rusty-hermit
uses: actions/checkout@v3
with:
repository: hermitcore/rusty-hermit
submodules: true
ref: 6358817662907510d637c6f1798171eff664e60c
- name: Remove libhermit-rs submodule
run: git rm -r libhermit-rs
- name: Checkout libhermit-rs
Expand All @@ -57,9 +56,9 @@ jobs:
run: rustup show
- name: Build minimal kernel
working-directory: libhermit-rs
run: cargo build --no-default-features -Z build-std=core,alloc
run: cargo xtask build --arch x86_64 --no-default-features
- name: Build dev profile
run: cargo build
run: cargo build -Zbuild-std=core,alloc,std,panic_abort -Zbuild-std-features=compiler-builtins-mem --target x86_64-unknown-hermit
- name: Unittests on host (ubuntu)
if: ${{ matrix.os == 'ubuntu-latest' }}
working-directory: libhermit-rs
Expand All @@ -81,7 +80,7 @@ jobs:
run: cargo test --tests --no-fail-fast -- --bootloader_path=../loader/target/x86_64-unknown-hermit-loader/release/rusty-loader
continue-on-error: true
- name: Build release profile
run: cargo build --release
run: cargo build -Zbuild-std=core,alloc,std,panic_abort -Zbuild-std-features=compiler-builtins-mem --target x86_64-unknown-hermit --release
- name: Test release profile
run: |
qemu-system-x86_64 -display none -smp 1 -m 128M -serial stdio \
Expand All @@ -91,9 +90,7 @@ jobs:
-initrd target/x86_64-unknown-hermit/release/rusty_demo
- name: Build minimal profile
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
cargo clean
cargo build --no-default-features --release -p hello_world
run: cargo build -Zbuild-std=core,alloc,std,panic_abort -Zbuild-std-features=compiler-builtins-mem --target x86_64-unknown-hermit --no-default-features --release --package hello_world
- name: Test minimal profile
id: minimal
if: ${{ matrix.os == 'ubuntu-latest' }}
Expand Down
5 changes: 3 additions & 2 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,15 @@ build:demo:
- if [ -d "$HOME/tmp_libhermit-rs/target" ]; then rm -rf $HOME/tmp_libhermit-rs/target; fi
- git clone https://github.com/hermitcore/rusty-hermit.git
- cd rusty-hermit
- git checkout 6358817662907510d637c6f1798171eff664e60c
- echo "rusty-hermit at commit $(git rev-parse HEAD)"
# Ensure that libhermit-rs is empty - This shouldn't be necessary since we don't initialize the submodules
# But let's do it anyway to be safe
- if [ -d "libhermit-rs" ]; then rm -rf libhermit-rs; fi
- mkdir libhermit-rs
- shopt -s dotglob nullglob && mv $HOME/tmp_libhermit-rs/* libhermit-rs/.
- cargo build -p rusty_demo
- cargo build -p rusty_demo --release
- cargo build -Zbuild-std=core,alloc,std,panic_abort -Zbuild-std-features=compiler-builtins-mem --target x86_64-unknown-hermit --package rusty_demo
- cargo build -Zbuild-std=core,alloc,std,panic_abort -Zbuild-std-features=compiler-builtins-mem --target x86_64-unknown-hermit --package rusty_demo --release
artifacts:
paths:
- rusty-hermit/target/x86_64-unknown-hermit/debug/rusty_demo
Expand Down
5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,8 @@ x86 = { version = "0.47", default-features = false }
[target.'cfg(target_arch = "aarch64")'.dependencies.aarch64]
version = "0.0.7"
default-features = false

[workspace]
members = [
"xtask",
]
2 changes: 0 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ RUN set -eux; \
# Build dependencies with stable toolchain channel
FROM rust:bullseye as stable-deps
RUN set -eux; \
cargo install cargo-binutils; \
cargo install cargo-download; \
cargo install --git https://github.com/hermitcore/uhyve.git --locked uhyve;

Expand All @@ -62,7 +61,6 @@ RUN set -eux; \
qemu-system-x86 \
; \
rm -rf /var/lib/apt/lists/*;
COPY --from=stable-deps $CARGO_HOME/bin/rust-objcopy $CARGO_HOME/bin/rust-objcopy
COPY --from=stable-deps $CARGO_HOME/bin/cargo-download $CARGO_HOME/bin/cargo-download
COPY --from=stable-deps $CARGO_HOME/bin/uhyve $CARGO_HOME/bin/uhyve
COPY --from=hermit-deps rusty-loader/target/x86_64-unknown-hermit-loader/release/rusty-loader /usr/local/bin/rusty-loader
1 change: 1 addition & 0 deletions xtask/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/target
11 changes: 11 additions & 0 deletions xtask/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[package]
name = "xtask"
version = "0.1.0"
edition = "2021"

[dependencies]
anyhow = "1.0"
goblin = { version = "0.5", default-features = false, features = ["archive", "std"] }
rustc_version = "0.4"
xflags = "0.2"
xshell = "0.2"
84 changes: 84 additions & 0 deletions xtask/src/flags.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
use std::path::PathBuf;

xflags::xflags! {
src "./src/flags.rs"

/// Run custom build command.
cmd xtask {
default cmd help {
/// Print help information.
optional -h, --help
}

/// Build the kernel.
cmd build
{
/// Build for the architecture.
required --arch arch: String
/// Directory for all generated artifacts.
optional --target-dir target_dir: PathBuf
/// Do not activate the `default` feature.
optional --no-default-features
/// Space or comma separated list of features to activate.
repeated --features features: String
/// Build artifacts in release mode, with optimizations.
optional -r, --release
/// Build artifacts with the specified profile.
optional --profile profile: String
/// Enable the `-Z instrument-mcount` flag.
optional --instrument-mcount
}

/// Run clippy for all targets.
cmd clippy {}
}
}

// generated start
// The following code is generated by `xflags` macro.
// Run `env UPDATE_XFLAGS=1 cargo build` to regenerate.
#[derive(Debug)]
pub struct Xtask {
pub subcommand: XtaskCmd,
}

#[derive(Debug)]
pub enum XtaskCmd {
Help(Help),
Build(Build),
Clippy(Clippy),
}

#[derive(Debug)]
pub struct Help {
pub help: bool,
}

#[derive(Debug)]
pub struct Build {
pub arch: String,
pub target_dir: Option<PathBuf>,
pub no_default_features: bool,
pub features: Vec<String>,
pub release: bool,
pub profile: Option<String>,
pub instrument_mcount: bool,
}

#[derive(Debug)]
pub struct Clippy;

impl Xtask {
pub const HELP: &'static str = Self::HELP_;

#[allow(dead_code)]
pub fn from_env() -> xflags::Result<Self> {
Self::from_env_()
}

#[allow(dead_code)]
pub fn from_vec(args: Vec<std::ffi::OsString>) -> xflags::Result<Self> {
Self::from_vec_(args)
}
}
// generated end
Loading

0 comments on commit 17e3adf

Please sign in to comment.