Skip to content

Commit 8eb605e

Browse files
committed
Initial commit
0 parents  commit 8eb605e

File tree

11 files changed

+153
-0
lines changed

11 files changed

+153
-0
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
scripts/* linguist-vendored

.github/workflows/ci.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: CI
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
clippy:
7+
runs-on: ubuntu-latest
8+
strategy:
9+
fail-fast: false
10+
matrix:
11+
rust-toolchain: [nightly]
12+
steps:
13+
- uses: actions/checkout@v4
14+
- uses: dtolnay/rust-toolchain@nightly
15+
with:
16+
toolchain: ${{ matrix.rust-toolchain }}
17+
components: rust-src, clippy, rustfmt
18+
- name: Setup ArceOS
19+
run: ./scripts/get_deps.sh
20+
- name: Check rust version
21+
run: rustc --version --verbose
22+
- name: Check code format
23+
run: cargo fmt -- --check
24+
- name: Clippy
25+
run: cargo clippy
26+
- name: Build for rust-std
27+
run: cargo build
28+
29+
build:
30+
runs-on: ${{ matrix.os }}
31+
strategy:
32+
fail-fast: false
33+
matrix:
34+
os: [ubuntu-latest]
35+
arch: [x86_64, riscv64, aarch64]
36+
rust-toolchain: [nightly]
37+
steps:
38+
- uses: actions/checkout@v4
39+
- uses: dtolnay/rust-toolchain@stable
40+
with:
41+
toolchain: ${{ matrix.rust-toolchain }}
42+
components: rust-src, llvm-tools
43+
targets: x86_64-unknown-none, riscv64gc-unknown-none-elf, aarch64-unknown-none, aarch64-unknown-none-softfloat
44+
- uses: Swatinem/rust-cache@v2
45+
- run: cargo install cargo-binutils
46+
- run: ./scripts/get_deps.sh
47+
- name: Build for ${{ matrix.arch }}
48+
run: make ARCH=${{ matrix.arch }}

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/target
2+
/.vscode
3+
/.arceos
4+
/.cargo
5+
.DS_Store
6+
Cargo.lock
7+
*.elf
8+
*.bin

Cargo.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[package]
2+
name = "arceos-helloworld"
3+
version = "0.1.0"
4+
edition = "2021"
5+
authors = ["Yuekai Jia <equation618@gmail.com>"]
6+
homepage = "https://github.com/arceos-org/arceos"
7+
repository = "https://github.com/arceos-org/app-helloworld"
8+
9+
[dependencies]
10+
axstd = { git = "https://github.com/arceos-org/arceos.git", optional = true }

Makefile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
AX_ROOT ?= $(PWD)/.arceos
2+
3+
all: build
4+
5+
ax_root:
6+
@./scripts/set_ax_root.sh $(AX_ROOT)
7+
8+
build run justrun debug fmt disasm clean: ax_root
9+
@make -C $(AX_ROOT) A=$(PWD) $@
10+
11+
.PHONY: all ax_root build run justrun debug fmt disasm clean

README.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# app-helloworld
2+
3+
[![CI](https://github.com/arceos-org/app-helloworld/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/arceos-org/app-helloworld/actions/workflows/ci.yml)
4+
5+
A "Hello, world!" application on [ArceOS](https://github.com/arceos-org/arceos).
6+
7+
## Quick Start
8+
9+
### 1. Install Build Dependencies
10+
11+
Install [cargo-binutils](https://github.com/rust-embedded/cargo-binutils) to use `rust-objcopy` and `rust-objdump` tools:
12+
13+
```bash
14+
cargo install cargo-binutils
15+
```
16+
17+
Download ArceOS source code:
18+
19+
```bash
20+
./scripts/get_deps.sh
21+
```
22+
23+
The ArceOS repository will be cloned into `.arceos`.
24+
You can also skip this step by specifying the `AX_ROOT` parameter when running the `make` command.
25+
26+
### 2. Build & Run
27+
28+
```bash
29+
make ARCH=<arch> LOG=<log> run
30+
```
31+
32+
Where `<arch>` should be one of `riscv64`, `aarch64``x86_64`.
33+
34+
`<log>` should be one of `off`, `error`, `warn`, `info`, `debug`, `trace`.
35+
36+
Other arguments are the same as ArceOS's [Makefile](https://github.com/arceos-org/arceos/blob/main/Makefile).
37+
38+
For example, to run on `qemu-system-aarch64` with 4 cores and log level `info`:
39+
40+
```bash
41+
make ARCH=aarch64 LOG=info SMP=4 run
42+
```
43+
44+
[![Run app-helloworld on ArceOS](img/demo.gif)](https://asciinema.org/a/669147?autoplay=1)

img/demo.gif

540 KB
Loading

scripts/config.toml.temp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[patch.'https://github.com/arceos-org/arceos.git']
2+
axstd = { path = "%AX_ROOT%/ulib/axstd" }

scripts/get_deps.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
3+
AX_ROOT=.arceos
4+
5+
test ! -d "$AX_ROOT" && echo "Cloning repositories ..." || true
6+
test ! -d "$AX_ROOT" && git clone https://github.com/arceos-org/arceos $AX_ROOT || true

scripts/set_ax_root.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#/bin/bash
2+
3+
if [ "$#" -ne 1 ]; then
4+
echo "Usage: $0 <AX_ROOT>"
5+
exit 1
6+
fi
7+
8+
AX_ROOT=$1
9+
10+
mkdir -p .cargo
11+
sed -e "s|%AX_ROOT%|$AX_ROOT|g" scripts/config.toml.temp > .cargo/config.toml
12+
13+
echo "Set AX_ROOT (ArceOS directory) to $AX_ROOT"

0 commit comments

Comments
 (0)