Skip to content

Commit

Permalink
固定工具链+设置github workflow (#21)
Browse files Browse the repository at this point in the history
* 1

* 设置github workflow

* 1
  • Loading branch information
fslongjin authored Sep 28, 2023
1 parent ea33032 commit 236b9b4
Show file tree
Hide file tree
Showing 9 changed files with 128 additions and 17 deletions.
8 changes: 6 additions & 2 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -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 = [
Expand Down
40 changes: 40 additions & 0 deletions .github/workflows/cache-toolchain.yml
Original file line number Diff line number Diff line change
@@ -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 changes: 54 additions & 0 deletions .github/workflows/standard-check.yml
Original file line number Diff line number Diff line change
@@ -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)
20 changes: 7 additions & 13 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -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",
}
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }

Expand Down
17 changes: 16 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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
Empty file removed build.txt
Empty file.
3 changes: 3 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[toolchain]
channel = "nightly-2023-08-15"
components = ["rust-src"]
1 change: 1 addition & 0 deletions target.json → x86_64-unknown-dragonos.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 236b9b4

Please sign in to comment.