Skip to content

Commit

Permalink
Merge pull request #105 from rcore-os/refactor-ulib
Browse files Browse the repository at this point in the history
Refactor ulib
  • Loading branch information
chyyuu authored Jul 25, 2023
2 parents 1cb5662 + 8972d93 commit f55a5af
Show file tree
Hide file tree
Showing 193 changed files with 1,353 additions and 876 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
115 changes: 66 additions & 49 deletions Cargo.lock

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

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ members = [
"modules/axsync",
"modules/axtask",

"ulib/libax",
"ulib/axstd",
"ulib/axlibc",
]

[profile.release]
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ fmt:
cargo fmt --all

fmt_c:
@clang-format --style=file -i $(shell find ulib/c_libax -iname '*.c' -o -iname '*.h')
@clang-format --style=file -i $(shell find ulib/axlibc -iname '*.c' -o -iname '*.h')

test:
$(call app_test)
Expand All @@ -192,7 +192,7 @@ clean: clean_c
cargo clean

clean_c:
rm -rf ulib/c_libax/build_*
rm -rf ulib/axlibc/build_*
rm -rf $(app-objs)

.PHONY: all build disasm run justrun debug clippy fmt fmt_c test test_no_fail_fast clean clean_c doc disk_image
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,14 @@ make A=apps/net/httpserver ARCH=aarch64 LOG=info NET=y SMP=4 run
#### Rust

1. Create a new rust package with `no_std` and `no_main` environment.
2. Add `libax` dependency and features to enable to `Cargo.toml`:
2. Add `axstd` dependency and features to enable to `Cargo.toml`:

```toml
[dependencies]
libax = { path = "/path/to/arceos/ulib/libax", features = ["..."] }
axstd = { path = "/path/to/arceos/ulib/axstd", features = ["..."] }
```

3. Call library functions from `libax` in your code, like the [helloworld](apps/helloworld/) example.
3. Call library functions from `axstd` in your code, just like the Rust [std](https://doc.rust-lang.org/std/) library.
4. Build your application with ArceOS, by running the `make` command in the application directory:

```bash
Expand Down
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]
libax = { path = "../../ulib/libax", 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 libax::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 libax;
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]
libax = { path = "../../ulib/libax", features = ["paging"] }
axstd = { path = "../../ulib/axstd", optional = true }
Loading

0 comments on commit f55a5af

Please sign in to comment.