Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
coolyjg committed Sep 8, 2023
0 parents commit 6a4b056
Show file tree
Hide file tree
Showing 640 changed files with 54,744 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
Language: Cpp
BasedOnStyle: LLVM
IndentWidth: 4
ColumnLimit: 100
AllowShortBlocksOnASingleLine: Empty
AllowShortFunctionsOnASingleLine: Inline
AllowShortLoopsOnASingleLine: true
AllowShortIfStatementsOnASingleLine: Never
AlignConsecutiveMacros: true
AlignEscapedNewlines: Left
BreakBeforeBraces: Custom
BraceWrapping:
AfterFunction: true
PointerAlignment: Right
---
38 changes: 38 additions & 0 deletions .github/workflows/actions/setup-musl/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Download musl toolchain

inputs:
arch:
description: 'Architecture'
required: true
type: string

runs:
using: "composite"
steps:
- name: Cache musl
id: cache-musl
uses: actions/cache/restore@v3
with:
path: ${{ inputs.arch }}-linux-musl-cross
key: ${{ inputs.arch }}-linux-musl-cross
- name: Download musl toolchain
if: steps.cache-musl.outputs.cache-hit != 'true'
shell: bash
run: |
MUSL_PATH=${{ inputs.arch }}-linux-musl-cross
wget https://musl.cc/${MUSL_PATH}.tgz
tar -xf ${MUSL_PATH}.tgz
- uses: actions/cache/save@v3
if: steps.cache-musl.outputs.cache-hit != 'true'
with:
path: ${{ inputs.arch }}-linux-musl-cross
key: ${{ inputs.arch }}-linux-musl-cross

- name: Add to PATH environment variable
shell: bash
run: |
echo "$PWD/${{ inputs.arch }}-linux-musl-cross/bin" >> $GITHUB_PATH
- name: Verify installation
shell: bash
run: |
${{ inputs.arch }}-linux-musl-gcc --version
46 changes: 46 additions & 0 deletions .github/workflows/actions/setup-qemu/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Download and build QEMU

inputs:
qemu-version:
description: 'QEMU version'
required: true
type: string

runs:
using: "composite"
steps:
- name: Cache QEMU
id: cache-qemu
uses: actions/cache/restore@v3
with:
path: qemu_build
key: qemu-${{ inputs.qemu-version }}
- name: Download and build QEMU
if: steps.cache-qemu.outputs.cache-hit != 'true'
env:
QEMU_PATH: qemu-${{ inputs.qemu-version }}
PREFIX: ${{ github.workspace }}/qemu_build
shell: bash
run: |
sudo apt-get update && sudo apt-get install -y ninja-build
wget https://download.qemu.org/$QEMU_PATH.tar.xz && tar -xJf $QEMU_PATH.tar.xz
cd $QEMU_PATH \
&& ./configure --prefix=$PREFIX --target-list=x86_64-softmmu,riscv64-softmmu,aarch64-softmmu \
&& make -j > /dev/null 2>&1 \
&& make install
- uses: actions/cache/save@v3
if: steps.cache-qemu.outputs.cache-hit != 'true'
with:
path: qemu_build
key: qemu-${{ inputs.qemu-version }}

- name: Install QEMU
shell: bash
run: |
echo "$PWD/qemu_build/bin" >> $GITHUB_PATH
- name: Verify installation
shell: bash
run: |
qemu-system-x86_64 --version
qemu-system-aarch64 --version
qemu-system-riscv64 --version
176 changes: 176 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
name: Build CI

on: [push, pull_request]

env:
rust-toolchain: nightly

jobs:
clippy:
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ env.rust-toolchain }}
components: rust-src, clippy, rustfmt
- name: Clippy for the default target
run: make clippy
- name: Clippy for x86_64
run: make clippy ARCH=x86_64
- name: Clippy for riscv64
run: make clippy ARCH=riscv64
- name: Clippy for aarch64
run: make clippy ARCH=aarch64
- name: Check code format
run: cargo fmt --all -- --check

build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
arch: [x86_64, riscv64, aarch64]
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ env.rust-toolchain }}
components: rust-src
- uses: actions-rs/install@v0.1
with:
crate: cargo-binutils
version: latest
use-tool-cache: true
- name: Build helloworld
run: make ARCH=${{ matrix.arch }} A=apps/helloworld
- name: Build memtest
run: make ARCH=${{ matrix.arch }} A=apps/memtest
- name: Build exception
run: make ARCH=${{ matrix.arch }} A=apps/exception
- name: Build display
run: make ARCH=${{ matrix.arch }} A=apps/display
- name: Build task/yield
run: make ARCH=${{ matrix.arch }} A=apps/task/yield
- name: Build task/parallel
run: make ARCH=${{ matrix.arch }} A=apps/task/parallel
- name: Build task/sleep
run: make ARCH=${{ matrix.arch }} A=apps/task/sleep
- name: Build task/priority
run: make ARCH=${{ matrix.arch }} A=apps/task/priority
- name: Build task/tls
run: make ARCH=${{ matrix.arch }} A=apps/task/tls
- name: Build fs/shell
run: make ARCH=${{ matrix.arch }} A=apps/fs/shell
- name: Build net/echoserver
run: make ARCH=${{ matrix.arch }} A=apps/net/echoserver
- name: Build net/httpclient
run: make ARCH=${{ matrix.arch }} A=apps/net/httpclient
- name: Build net/httpserver
run: make ARCH=${{ matrix.arch }} A=apps/net/httpserver
- name: Build net/udpserver
run: make ARCH=${{ matrix.arch }} A=apps/net/udpserver

- uses: ./.github/workflows/actions/setup-musl
with:
arch: ${{ matrix.arch }}
- name: Build c/helloworld
run: make ARCH=${{ matrix.arch }} A=apps/c/helloworld
- name: Build c/memtest
run: make ARCH=${{ matrix.arch }} A=apps/c/memtest
- name: Build c/sqlite3
run: make ARCH=${{ matrix.arch }} A=apps/c/sqlite3
- name: Build c/httpclient
run: make ARCH=${{ matrix.arch }} A=apps/c/httpclient
- name: Build c/httpserver
run: make ARCH=${{ matrix.arch }} A=apps/c/httpserver
- name: Build c/udpserver
run: make ARCH=${{ matrix.arch }} A=apps/c/udpserver
- name: Build c/iperf
run: make ARCH=${{ matrix.arch }} A=apps/c/iperf
- name: Build c/redis
run: make ARCH=${{ matrix.arch }} A=apps/c/redis SMP=4

build-apps-for-other-platforms:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ env.rust-toolchain }}
components: rust-src
- uses: actions-rs/install@v0.1
with:
crate: cargo-binutils
version: latest
use-tool-cache: true
- uses: ./.github/workflows/actions/setup-musl
with:
arch: x86_64

- name: Build helloworld for x86_64-pc-oslab
run: make PLATFORM=x86_64-pc-oslab A=apps/helloworld
- name: Build net/httpserver for x86_64-pc-oslab
run: make PLATFORM=x86_64-pc-oslab A=apps/net/httpserver FEATURES=driver-ixgbe
- name: Build c/iperf for x86_64-pc-oslab
run: make PLATFORM=x86_64-pc-oslab A=apps/c/iperf FEATURES=driver-ixgbe,driver-ramdisk
- name: Build c/redis for x86_64-pc-oslab
run: make PLATFORM=x86_64-pc-oslab A=apps/c/redis FEATURES=driver-ixgbe,driver-ramdisk SMP=4

- name: Build helloworld for aarch64-raspi4
run: make PLATFORM=aarch64-raspi4 A=apps/helloworld
- name: Build fs/shell for aarch64-raspi4
run: make PLATFORM=aarch64-raspi4 A=apps/fs/shell FEATURES=driver-bcm2835-sdhci

- name: Build helloworld for aarch64-bsta1000b
run: make PLATFORM=aarch64-bsta1000b A=apps/helloworld

build-apps-for-std:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
arch: [x86_64]
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ env.rust-toolchain }}
- name: Build helloworld
run: cargo build -p arceos-helloworld
- name: Build memtest
run: cargo build -p arceos-memtest
- name: Build exception
run: cargo build -p arceos-exception
- name: Build task/yield
run: cargo build -p arceos-yield
- name: Build task/parallel
run: cargo build -p arceos-parallel
- name: Build task/sleep
run: cargo build -p arceos-sleep
- name: Build task/priority
run: cargo build -p arceos-priority
- name: Build task/tls
run: cargo build -p arceos-tls
- name: Build fs/shell
run: cargo build -p arceos-shell
- name: Build net/echoserver
run: cargo build -p arceos-echoserver
- name: Build net/httpclient
run: cargo build -p arceos-httpclient
- name: Build net/httpserver
run: cargo build -p arceos-httpserver
- name: Build net/udpserver
run: cargo build -p arceos-udpserver
32 changes: 32 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Build & Deploy docs

on: [push, pull_request]

env:
rust-toolchain: nightly

jobs:
doc:
runs-on: ubuntu-latest
strategy:
fail-fast: false
permissions:
contents: write
env:
default-branch: ${{ format('refs/heads/{0}', github.event.repository.default_branch) }}
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ env.rust-toolchain }}
- name: Build docs
continue-on-error: ${{ github.ref != env.default-branch && github.event_name != 'pull_request' }}
run: make doc_check_missing
- name: Deploy to Github Pages
if: ${{ github.ref == env.default-branch }}
uses: JamesIves/github-pages-deploy-action@v4
with:
single-commit: true
branch: gh-pages
folder: target/doc
50 changes: 50 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Test CI

on: [push, pull_request]

env:
qemu-version: 7.1.0
rust-toolchain: nightly

jobs:
unit-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ env.rust-toolchain }}
components: rust-src
- name: Run unit tests
run: make unittest_no_fail_fast

app-test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
arch: [x86_64, riscv64, aarch64]
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ env.rust-toolchain }}
components: rust-src
- uses: actions-rs/install@v0.1
with:
crate: cargo-binutils
version: latest
use-tool-cache: true
- uses: ./.github/workflows/actions/setup-qemu
with:
qemu-version: ${{ env.qemu-version }}
- uses: ./.github/workflows/actions/setup-musl
with:
arch: ${{ matrix.arch }}
- name: Run app tests
run: |
make disk_img
make test ARCH=${{ matrix.arch }}
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/target
/.vscode
.DS_Store
*.asm
*.img
actual.out
qemu.log
rusty-tags.vi
Loading

0 comments on commit 6a4b056

Please sign in to comment.