From 236b9b4f4d4f527c482cad40d09674195023e5fb Mon Sep 17 00:00:00 2001 From: LoGin Date: Thu, 28 Sep 2023 23:45:43 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=BA=E5=AE=9A=E5=B7=A5=E5=85=B7=E9=93=BE+?= =?UTF-8?q?=E8=AE=BE=E7=BD=AEgithub=20workflow=20(#21)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 1 * 设置github workflow * 1 --- .cargo/config.toml | 8 ++- .github/workflows/cache-toolchain.yml | 40 +++++++++++++++ .github/workflows/standard-check.yml | 54 +++++++++++++++++++++ .vscode/settings.json | 20 +++----- Cargo.toml | 2 +- Makefile | 17 ++++++- build.txt | 0 rust-toolchain.toml | 3 ++ target.json => x86_64-unknown-dragonos.json | 1 + 9 files changed, 128 insertions(+), 17 deletions(-) create mode 100644 .github/workflows/cache-toolchain.yml create mode 100644 .github/workflows/standard-check.yml delete mode 100644 build.txt create mode 100644 rust-toolchain.toml rename target.json => x86_64-unknown-dragonos.json (97%) diff --git a/.cargo/config.toml b/.cargo/config.toml index ec171f1..85f6d0a 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,5 +1,9 @@ -#[build] -#target = "x86_64-unknown-dragonos" +[build] +target = "./x86_64-unknown-dragonos.json" + +[unstable] +build-std = ["core", "compiler_builtins", "alloc"] +build-std-features = ["compiler-builtins-mem"] [target.'cfg(target_os = "dragonos")'] rustflags = [ diff --git a/.github/workflows/cache-toolchain.yml b/.github/workflows/cache-toolchain.yml new file mode 100644 index 0000000..86d9425 --- /dev/null +++ b/.github/workflows/cache-toolchain.yml @@ -0,0 +1,40 @@ +name: Reusable workflow example + +on: workflow_call + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + + - name: Cache build tools + id: cache-build-tools + uses: actions/cache@v3 + env: + cache-name: cache-build-tools + dadk_version: 0.1.2 + with: + path: | + ~/.cargo + ~/.rustup + ~/.bashrc + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ env.dadk_version }}-${{ hashFiles('.github/workflows/cache-toolchain.yml') }} + + - if: ${{ steps.cache-build-tools.outputs.cache-hit != 'true' }} + name: Install toolchain + continue-on-error: true + run: | + sudo sh -c "apt update && apt install -y llvm-dev libclang-dev clang gcc-multilib libssl-dev pkg-config" + cargo install cargo-binutils + rustup toolchain install nightly + rustup default nightly + rustup component add rust-src + rustup component add llvm-tools-preview + rustup target add x86_64-unknown-none + rustup component add rust-src --toolchain nightly-2023-08-15-x86_64-unknown-linux-gnu + rustup component add rustfmt + cargo install dadk --version 0.1.2 \ No newline at end of file diff --git a/.github/workflows/standard-check.yml b/.github/workflows/standard-check.yml new file mode 100644 index 0000000..eda3d5f --- /dev/null +++ b/.github/workflows/standard-check.yml @@ -0,0 +1,54 @@ +name: Standard Check + +on: [push, pull_request] + +jobs: + # ensure the toolchain is cached + ensure-toolchain: + uses: ./.github/workflows/cache-toolchain.yml + + fmt: + name: fmt check + runs-on: ubuntu-latest + needs: [ensure-toolchain] + steps: + - uses: actions/checkout@v3 + - name: Cache build tools + id: cache-build-tools + uses: actions/cache@v3 + env: + cache-name: cache-build-tools + dadk_version: 0.1.2 + with: + path: | + ~/.cargo + ~/.rustup + ~/.bashrc + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ env.dadk_version }}-${{ hashFiles('.github/workflows/cache-toolchain.yml') }} + + - name: Check format + run: | + make fmt-check + + build: + name: build check + runs-on: ubuntu-latest + needs: [ensure-toolchain] + steps: + - uses: actions/checkout@v3 + - name: Cache build tools + id: cache-build-tools + uses: actions/cache@v3 + env: + cache-name: cache-build-tools + dadk_version: 0.1.2 + with: + path: | + ~/.cargo + ~/.rustup + ~/.bashrc + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ env.dadk_version }}-${{ hashFiles('.github/workflows/cache-toolchain.yml') }} + + - name: Build check + run: | + make all -j $(nproc) diff --git a/.vscode/settings.json b/.vscode/settings.json index aeb527b..59b0ed1 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,16 +1,10 @@ { + "rust-analyzer.linkedProjects": [ + "./Cargo.toml", + ], "rust-analyzer.check.overrideCommand": [ - "cargo", - "+nightly", - "-Z", - "build-std=core,alloc,compiler_builtins", - "check", - "--workspace", - "--message-format=json", - "--target", - "target.json", + "make", + "check" ], - - "rust-analyzer.cargo.target": "x86_64-unknown-dragonos", - -} \ No newline at end of file + // "rust-analyzer.cargo.target": "x86_64-unknown-dragonos", +} diff --git a/Cargo.toml b/Cargo.toml index c98d8f0..fd04678 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,7 @@ hashbrown = "0.11" cfg-if = { version = "1.0"} [target.'cfg(target_os = "dragonos")'.dependencies] -drstd = { git = "https://git.mirrors.dragonos.org/DragonOS-Community/drstd.git", rev = "0fe3ff0054" } +drstd = { git = "https://git.mirrors.dragonos.org/DragonOS-Community/drstd.git", rev = "e1fbd22da2" } lazy_static = { version = "1.4.0", default-features = false, features = ["spin_no_std"] } diff --git a/Makefile b/Makefile index e969cd9..e63b53f 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,15 @@ +export RUSTUP_DIST_SERVER=https://mirrors.ustc.edu.cn/rust-static +export RUSTUP_UPDATE_ROOT=https://mirrors.ustc.edu.cn/rust-static/rustup + OUTPUT_DIR = $(DADK_BUILD_CACHE_DIR_DRAGONREACH_0_1_0) REACH_ETC_DIR=$(OUTPUT_DIR)/etc/reach REACH_BIN_DIR=$(OUTPUT_DIR)/bin/ TMP_INSTALL_DIR=$(OUTPUT_DIR)/tmp_install +all: build + build: - cargo -Z build-std=core,alloc,compiler_builtins build --target ./target.json --release + cargo -Z build-std=core,alloc,compiler_builtins build --target ./x86_64-unknown-dragonos.json --release install: mkdir -p $(TMP_INSTALL_DIR) @@ -23,3 +28,13 @@ build-linux: clean: cargo clean + + +fmt: + cargo fmt + +fmt-check: + cargo fmt --check + +check: + cargo -Z build-std=core,alloc,compiler_builtins check --workspace --message-format=json --target ./x86_64-unknown-dragonos.json diff --git a/build.txt b/build.txt deleted file mode 100644 index e69de29..0000000 diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000..5eaf8e3 --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,3 @@ +[toolchain] +channel = "nightly-2023-08-15" +components = ["rust-src"] \ No newline at end of file diff --git a/target.json b/x86_64-unknown-dragonos.json similarity index 97% rename from target.json rename to x86_64-unknown-dragonos.json index ffef3ec..ca99221 100644 --- a/target.json +++ b/x86_64-unknown-dragonos.json @@ -8,6 +8,7 @@ "target-family": [ "unix" ], + "env": "musl", "target-c-int-width": "32", "data-layout": "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128", "disable-redzone": true,