Browse Source

添加github workflow的build check和fmt check (#28)

TTaq 1 year ago
parent
commit
dcc611d712
4 changed files with 43 additions and 38 deletions
  1. 30 0
      .github/workflows/rust.yml
  2. 11 2
      Makefile
  3. 2 1
      rust-toolchain.toml
  4. 0 35
      x86_64-unknown-dragonos.json

+ 30 - 0
.github/workflows/rust.yml

@@ -0,0 +1,30 @@
+name: Rust
+
+on:
+  workflow_dispatch:
+  push:
+    branches: [ "main" ]
+  pull_request:
+    branches: [ "main" ]
+
+env:
+  CARGO_TERM_COLOR: always
+
+jobs:
+  build-check:
+
+    runs-on: ubuntu-latest
+
+    steps:
+    - uses: actions/checkout@v3
+    - name: build check
+      run: make check
+
+  fmt-check:
+
+    runs-on: ubuntu-latest
+
+    steps:
+    - uses: actions/checkout@v3
+    - name: Build
+      run: make fmt-check

+ 11 - 2
Makefile

@@ -1,7 +1,7 @@
 # The toolchain we use.
 # You can get it by running DragonOS' `tools/bootstrap.sh`
-TOOLCHAIN="+nightly-2023-08-15-x86_64-unknown-linux_dragonos-gnu"
-RUSTFLAGS+="-C target-feature=+crt-static -C link-arg=-no-pie"
+# TOOLCHAIN="+nightly-2023-08-15-x86_64-unknown-linux_dragonos-gnu"
+# RUSTFLAGS+="-C target-feature=+crt-static -C link-arg=-no-pie"
 
 # 如果是在dadk中编译,那么安装到dadk的安装目录中
 INSTALL_DIR?=$(DADK_CURRENT_BUILD_DIR)
@@ -15,6 +15,9 @@ run:
 build:
 	RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) build
 
+check:
+	RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) check --all-features
+
 clean:
 	RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) clean
 
@@ -24,6 +27,12 @@ test:
 doc:
 	RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) doc
 
+fmt:
+	RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) fmt
+
+fmt-check:
+	RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) fmt --check
+
 run-release:
 	RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) run --release
 

+ 2 - 1
rust-toolchain.toml

@@ -1,3 +1,4 @@
 [toolchain]
 channel = "nightly-2023-08-15"
-components = ["rust-src"]
+components = ["rust-src", "rustfmt"]
+targets = [ "x86_64-unknown-linux-musl" ]

+ 0 - 35
x86_64-unknown-dragonos.json

@@ -1,35 +0,0 @@
-{
-    "arch": "x86_64",
-    "code-model": "kernel",
-    "cpu": "x86-64",
-    "os": "dragonos",
-    "target-endian": "little",
-    "target-pointer-width": "64",
-    "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,
-    "features": "-3dnow,-3dnowa,-avx,-avx2",
-    "linker": "rust-lld",
-    "linker-flavor": "ld.lld",
-    "llvm-target": "x86_64-unknown-none",
-    "max-atomic-width": 64,
-    "panic-strategy": "abort",
-    "position-independent-executables": true,
-    "relro-level": "full",
-    "stack-probes": {
-        "kind": "inline-or-call",
-        "min-llvm-version-for-inline": [
-            16,
-            0,
-            0
-        ]
-    },
-    "static-position-independent-executables": true,
-    "supported-sanitizers": [
-        "kcfi"
-    ]
-}