Skip to content

Commit

Permalink
ulib: make axstd API more similar to rust std
Browse files Browse the repository at this point in the history
- now apps can be built with both std and ArceOS without modification
  • Loading branch information
equation314 committed Jul 23, 2023
1 parent 8327bb3 commit 7659ad9
Show file tree
Hide file tree
Showing 75 changed files with 1,104 additions and 722 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,41 @@ jobs:
run: make ARCH=${{ matrix.arch }} A=apps/c/udpserver
- name: Build c/iperf
run: make ARCH=${{ matrix.arch }} A=apps/c/iperf

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 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
5 changes: 3 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion apps/display/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ authors = ["Shiping Yuan <[email protected]>"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
axstd = { path = "../../ulib/axstd", features = ["display"] }
axstd = { path = "../../ulib/axstd", features = ["display"], optional = true }
embedded-graphics = "0.8"
2 changes: 1 addition & 1 deletion apps/display/src/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use embedded_graphics::pixelcolor::Rgb888;
use embedded_graphics::prelude::{RgbColor, Size};
use embedded_graphics::{draw_target::DrawTarget, prelude::OriginDimensions};

pub use axstd::display::{framebuffer_flush, framebuffer_info, DisplayInfo};
pub use axstd::os::arceos::axdisplay::{framebuffer_flush, framebuffer_info, DisplayInfo};

pub struct Display {
size: Size,
Expand Down
11 changes: 6 additions & 5 deletions apps/display/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#![no_std]
#![no_main]
#![cfg_attr(feature = "axstd", no_std)]
#![cfg_attr(feature = "axstd", no_main)]

extern crate axstd;
mod display;
#[cfg(feature = "axstd")]
extern crate axstd as std;

mod display;
use display::*;

use embedded_graphics::{
Expand Down Expand Up @@ -77,7 +78,7 @@ fn test_gpu() -> i32 {
0
}

#[no_mangle]
#[cfg_attr(feature = "axstd", no_mangle)]
fn main() -> ! {
test_gpu();
loop {
Expand Down
2 changes: 1 addition & 1 deletion apps/exception/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ authors = ["Yuekai Jia <[email protected]>"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
axstd = { path = "../../ulib/axstd", features = ["paging"] }
axstd = { path = "../../ulib/axstd", optional = true }
2 changes: 0 additions & 2 deletions apps/exception/expect_debug_aarch64.out
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ Found physcial memory regions:
boot stack (READ | WRITE | RESERVED)
.bss (READ | WRITE | RESERVED)
free memory (READ | WRITE | FREE)
Initialize global memory allocator...
Initialize kernel page table...
Initialize platform devices...
Primary CPU 0 init OK.
Running exception tests...
Expand Down
2 changes: 0 additions & 2 deletions apps/exception/expect_debug_riscv64.out
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ Found physcial memory regions:
boot stack (READ | WRITE | RESERVED)
.bss (READ | WRITE | RESERVED)
free memory (READ | WRITE | FREE)
Initialize global memory allocator...
Initialize kernel page table...
Initialize platform devices...
Primary CPU 0 init OK.
Running exception tests...
Expand Down
3 changes: 1 addition & 2 deletions apps/exception/expect_debug_x86_64.out
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ Found physcial memory regions:
boot stack (READ | WRITE | RESERVED)
.bss (READ | WRITE | RESERVED)
free memory (READ | WRITE | FREE)
Initialize global memory allocator...
Initialize kernel page table...
Initialize platform devices...
Primary CPU 0 init OK.
Running exception tests...
#BP @ 0x[0-9a-f]\{16\}
Expand Down
13 changes: 8 additions & 5 deletions apps/exception/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#![no_std]
#![no_main]
#![cfg_attr(feature = "axstd", no_std)]
#![cfg_attr(feature = "axstd", no_main)]

use axstd::println;
use core::arch::asm;
#[cfg(feature = "axstd")]
extern crate axstd as std;

use std::arch::asm;
use std::println;

fn raise_break_exception() {
unsafe {
Expand All @@ -15,7 +18,7 @@ fn raise_break_exception() {
}
}

#[no_mangle]
#[cfg_attr(feature = "axstd", no_mangle)]
fn main() {
println!("Running exception tests...");
raise_break_exception();
Expand Down
5 changes: 2 additions & 3 deletions apps/fs/shell/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ authors = ["Yuekai Jia <[email protected]>"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[features]
use_ramfs = ["axfs/myfs", "dep:axfs_vfs", "dep:axfs_ramfs", "dep:crate_interface"]
use-ramfs = ["axstd/myfs", "dep:axfs_vfs", "dep:axfs_ramfs", "dep:crate_interface"]
default = []

[dependencies]
axfs = { path = "../../../modules/axfs", optional = true }
axfs_vfs = { path = "../../../crates/axfs_vfs", optional = true }
axfs_ramfs = { path = "../../../crates/axfs_ramfs", optional = true }
crate_interface = { path = "../../../crates/crate_interface", optional = true }
axstd = { path = "../../../ulib/axstd", features = ["fs"] }
axstd = { path = "../../../ulib/axstd", features = ["alloc", "fs"], optional = true }
Loading

0 comments on commit 7659ad9

Please sign in to comment.