Skip to content

Commit 9a13787

Browse files
committed
Initial commit
0 parents  commit 9a13787

File tree

9 files changed

+151
-0
lines changed

9 files changed

+151
-0
lines changed

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

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 .arceos || 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"

src/main.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#![cfg_attr(feature = "axstd", no_std)]
2+
#![cfg_attr(feature = "axstd", no_main)]
3+
4+
#[cfg(feature = "axstd")]
5+
use axstd::println;
6+
7+
#[cfg_attr(feature = "axstd", no_mangle)]
8+
fn main() {
9+
println!("Hello, world!");
10+
}

0 commit comments

Comments
 (0)