From b237bd52feec8023b238f91273b23d4556e2e315 Mon Sep 17 00:00:00 2001 From: Yuekai Jia Date: Mon, 22 Jul 2024 02:02:28 +0800 Subject: [PATCH] Add script to set AX_ROOT --- .cargo/config.toml | 3 --- .github/workflows/build.yml | 10 +++++----- .github/workflows/test.yml | 2 +- .gitignore | 1 + Makefile | 12 ++++++++---- scripts/config.toml.temp | 3 +++ scripts/{setup.sh => get_deps.sh} | 4 +++- scripts/set_ax_root.sh | 13 +++++++++++++ 8 files changed, 34 insertions(+), 14 deletions(-) delete mode 100644 .cargo/config.toml create mode 100644 scripts/config.toml.temp rename scripts/{setup.sh => get_deps.sh} (67%) create mode 100755 scripts/set_ax_root.sh diff --git a/.cargo/config.toml b/.cargo/config.toml deleted file mode 100644 index 7e381b0..0000000 --- a/.cargo/config.toml +++ /dev/null @@ -1,3 +0,0 @@ -[patch.'https://github.com/arceos-org/arceos.git'] -axstd = { path = ".arceos/ulib/axstd" } -axnet = { path = ".arceos/modules/axnet" } diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 32cab02..63a1907 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,7 +16,7 @@ jobs: toolchain: ${{ matrix.rust-toolchain }} components: rust-src, clippy, rustfmt - name: Setup ArceOS - run: ./scripts/setup.sh + run: ./scripts/get_deps.sh - name: Check rust version run: rustc --version --verbose - name: Check code format @@ -41,7 +41,7 @@ jobs: targets: x86_64-unknown-none, riscv64gc-unknown-none-elf, aarch64-unknown-none, aarch64-unknown-none-softfloat - uses: Swatinem/rust-cache@v2 - run: cargo install cargo-binutils - - run: ./scripts/setup.sh + - run: ./scripts/get_deps.sh - name: Build rust/helloworld run: make ARCH=${{ matrix.arch }} A=rust/helloworld @@ -92,7 +92,7 @@ jobs: arch: ${{ matrix.arch }} - uses: Swatinem/rust-cache@v2 - run: cargo install cargo-binutils - - run: ./scripts/setup.sh + - run: ./scripts/get_deps.sh - name: Build c/helloworld run: make ARCH=${{ matrix.arch }} A=c/helloworld @@ -130,7 +130,7 @@ jobs: arch: x86_64 - uses: Swatinem/rust-cache@v2 - run: cargo install cargo-binutils - - run: ./scripts/setup.sh + - run: ./scripts/get_deps.sh - name: Build rust/helloworld for x86_64-pc-oslab run: make PLATFORM=x86_64-pc-oslab A=rust/helloworld @@ -162,5 +162,5 @@ jobs: toolchain: ${{ matrix.rust-toolchain }} - name: Build apps for std run: | - ./scripts/setup.sh + ./scripts/get_deps.sh cargo build --all --exclude arceos-display diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fcb6e6b..419598a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -29,6 +29,6 @@ jobs: arch: ${{ matrix.arch }} - name: Run app tests run: | - ./scripts/setup.sh + ./scripts/get_deps.sh make disk_img make test ARCH=${{ matrix.arch }} diff --git a/.gitignore b/.gitignore index eec982e..8d0b86a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ /target /.vscode /.arceos +/.cargo .DS_Store Cargo.lock *.o diff --git a/Makefile b/Makefile index dd011c6..8b26b12 100644 --- a/Makefile +++ b/Makefile @@ -8,11 +8,13 @@ ifeq ($(filter /%,$(A)),) endif endif -all: - @make -C $(AX_ROOT) A=$(APP) +all: build -$(MAKECMDGOALS): - @make -C $(AX_ROOT) A=$(APP) $(MAKECMDGOALS) +ax_root: + @./scripts/set_ax_root.sh $(AX_ROOT) + +build run justrun debug disasm fmt clean clean_c: ax_root + @make -C $(AX_ROOT) A=$(APP) $@ test: ifneq ($(filter command line,$(origin A)),) @@ -20,3 +22,5 @@ ifneq ($(filter command line,$(origin A)),) else ./scripts/app_test.sh endif + +.PHONY: all ax_root build run justrun debug disasm fmt clean clean_c test diff --git a/scripts/config.toml.temp b/scripts/config.toml.temp new file mode 100644 index 0000000..ca97b2d --- /dev/null +++ b/scripts/config.toml.temp @@ -0,0 +1,3 @@ +[patch.'https://github.com/arceos-org/arceos.git'] +axstd = { path = "%AX_ROOT%/ulib/axstd" } +axnet = { path = "%AX_ROOT%/modules/axnet" } diff --git a/scripts/setup.sh b/scripts/get_deps.sh similarity index 67% rename from scripts/setup.sh rename to scripts/get_deps.sh index 4c5a8bd..e59e76f 100755 --- a/scripts/setup.sh +++ b/scripts/get_deps.sh @@ -3,4 +3,6 @@ AX_ROOT=.arceos test ! -d "$AX_ROOT" && echo "Cloning repositories ..." || true -test ! -d "$AX_ROOT" && git clone https://github.com/arceos-org/arceos .arceos || true +test ! -d "$AX_ROOT" && git clone https://github.com/arceos-org/arceos -b separate-apps .arceos || true + +./scripts/set_ax_root.sh $AX_ROOT diff --git a/scripts/set_ax_root.sh b/scripts/set_ax_root.sh new file mode 100755 index 0000000..a9f65db --- /dev/null +++ b/scripts/set_ax_root.sh @@ -0,0 +1,13 @@ +#/bin/bash + +if [ "$#" -ne 1 ]; then + echo "Usage: $0 " + exit 1 +fi + +AX_ROOT=$1 + +mkdir -p .cargo +sed -e "s|%AX_ROOT%|$AX_ROOT|g" scripts/config.toml.temp > .cargo/config.toml + +echo "Set AX_ROOT (ArceOS directory) to $AX_ROOT"