Skip to content

Commit

Permalink
feat: remove axlibc
Browse files Browse the repository at this point in the history
  • Loading branch information
Azure-stars committed May 2, 2024
1 parent 537d053 commit 360c5ef
Show file tree
Hide file tree
Showing 11 changed files with 50 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

[env]
AX_WORK_DIR = { value = ".", relative = true }
AX_LIBC_DIR = { value = "tools/axlibc", relative = true }
AX_LIBC_DIR = { value = "crates/axlibc", relative = true }
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,4 @@ arceos-fada.bin.gz
arceos-fada.itb
.tmp_its
!tools/rk3588/ramdisk.img
!tools/axlibc
linker_*
crates/
6 changes: 0 additions & 6 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 Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ lto = true
lto = true

[workspace]
members = ["tools/axlibc", "apps/display", "apps/exception", "apps/helloworld", "apps/memtest", "apps/fs/shell", "apps/net/echoserver", "apps/net/httpclient", "apps/net/httpserver", "apps/net/udpserver", "apps/net/bwbench", "apps/task/parallel", "apps/task/sleep", "apps/task/yield", "apps/task/priority", "apps/task/tls", "apps/monolithic_userboot"]
members = ["crates/axlibc", "apps/display", "apps/exception", "apps/helloworld", "apps/memtest", "apps/fs/shell", "apps/net/echoserver", "apps/net/httpclient", "apps/net/httpserver", "apps/net/udpserver", "apps/net/bwbench", "apps/task/parallel", "apps/task/sleep", "apps/task/yield", "apps/task/priority", "apps/task/tls", "apps/monolithic_userboot"]
resolver = "2"
19 changes: 11 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ SMP ?= 1
MODE ?= release
LOG ?= off
V ?=

LIBC_DIR = crates/axlibc
# App options
A ?= apps/monolithic_userboot
APP ?= $(A)
Expand Down Expand Up @@ -161,12 +161,15 @@ else ifeq ($(PLATFORM_NAME), aarch64-rk3588j)
include scripts/make/rk3588.mk
endif

make_bin:
ifeq ($(STRUCT), Monolithic)
$(call make_bin)
endif
pre_c:
ifeq ($(wildcard crates/axlibc/include),)
@rm -rf crates/axlibc
@git clone https://github.com/Starry-OS/axlibc.git crates/axlibc
@cargo update axlibc
@echo Load axlibc successfully
endif

build: make_bin $(OUT_DIR) $(OUT_BIN)
build: $(OUT_DIR) $(OUT_BIN)

disasm:
$(OBJDUMP) $(OUT_ELF) | less
Expand Down Expand Up @@ -202,7 +205,7 @@ fmt:
cargo fmt --all

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

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

clean_c::
rm -rf tools/axlibc/build_*
rm -rf crates/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 make_bin
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,14 @@ $ ./build_img.sh x86_64
$ make A=apps/monolithic_userboot ARCH=x86_64 run
```

## Build C applications

```sh
# Load axlibc
$ make pre_c

# Build the application
# $ make A=apps/<app_name> ARCH=<arch> build
$ make A=apps/c/helloworld ARCH=x86_64 build
```

16 changes: 16 additions & 0 deletions crates/axlibc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[package]
name = "axlibc"
version = "0.1.0"
description = "Empty crates mock for cargo analyzer.When you want to use it, first clone it from the github repository."
repository = "https://github.com/Starry-OS/axlibc"


[dependencies]
axfeat = { git = "https://github.com/Starry-OS/axfeat.git" }
arceos_posix_api = { git = "https://github.com/Starry-OS/arceos_posix_api.git" }
axio = { git = "https://github.com/Starry-OS/axio.git" }
axerrno = { git = "https://github.com/Starry-OS/axerrno.git" }
arch_boot = { git = "https://github.com/Starry-OS/arch_boot.git" }

[build-dependencies]
bindgen ={ version = "0.66" }
5 changes: 5 additions & 0 deletions crates/axlibc/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//! Empty crates mock for cargo analyzer.When you want to use it, first clone it from the github repository.
//!
//! The repository is [here](https://github.com/Starry-OS/axlibc)
#![no_std]
#![no_main]
3 changes: 3 additions & 0 deletions scripts/make/build.mk
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ ifeq ($(APP_TYPE), rust)
$(call cargo_build,--manifest-path $(APP)/Cargo.toml,$(AX_FEAT) $(LIB_FEAT) $(APP_FEAT))
@cp $(rust_elf) $(OUT_ELF)
else ifeq ($(APP_TYPE), c)
ifeq ($(wildcard $(LIBC_DIR)/include),)
$(error "libc" is not built, please build it first by run the command `make pre_c`)
endif
$(call cargo_build,-p axlibc,$(AX_FEAT) $(LIB_FEAT))
endif

Expand Down
2 changes: 1 addition & 1 deletion scripts/make/build_c.mk
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
rust_lib_name := axlibc
rust_lib := target/$(TARGET)/$(MODE)/lib$(rust_lib_name).a

ulib_dir := tools/axlibc
ulib_dir := crates/axlibc
src_dir := $(ulib_dir)/c
obj_dir := $(ulib_dir)/build_$(ARCH)
inc_dir := $(ulib_dir)/include
Expand Down
2 changes: 1 addition & 1 deletion scripts/make/build_lwext4.mk
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ local_lib_feat := fp_simd alloc paging fs fd
export LIBC_BUILD_TARGET_DIR=$(abspath $(local_obj_dir))

### include scripts/make/build_c.mk
local_ulib_dir := tools/axlibc
local_ulib_dir := crates/axlibc
local_src_dir := $(local_ulib_dir)/c
local_inc_dir := $(local_ulib_dir)/include
local_obj_dir := $(local_ulib_dir)/lwext4_libc_$(ARCH)
Expand Down

0 comments on commit 360c5ef

Please sign in to comment.