Quellcode durchsuchen

固定工具链+设置github workflow (#21)

* 1

* 设置github workflow

* 1
LoGin vor 7 Monaten
Ursprung
Commit
236b9b4f4d

+ 6 - 2
.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 = [

+ 40 - 0
.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

+ 54 - 0
.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)

+ 7 - 13
.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",
-    
-}
+    // "rust-analyzer.cargo.target": "x86_64-unknown-dragonos",
+}

+ 1 - 1
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"] }
 

+ 16 - 1
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

+ 0 - 0
build.txt


+ 3 - 0
rust-toolchain.toml

@@ -0,0 +1,3 @@
+[toolchain]
+channel = "nightly-2023-08-15"
+components = ["rust-src"]

+ 1 - 0
target.json → 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,