mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-09 19:36:47 +00:00
parent
7a29d4fcbc
commit
43ef2a0d2b
34
.github/actions/import-toolchain/action.yml
vendored
Normal file
34
.github/actions/import-toolchain/action.yml
vendored
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
name: import-toolchain
|
||||||
|
|
||||||
|
runs:
|
||||||
|
using: composite
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
submodules: 'recursive'
|
||||||
|
|
||||||
|
- name: Cache DragonOS GCC
|
||||||
|
id: cache-dragonos-gcc
|
||||||
|
uses: actions/cache@v3
|
||||||
|
env:
|
||||||
|
cache-name: cache-dragonos-gcc
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
~/opt
|
||||||
|
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('tools/build_gcc_toolchain.sh') }}-${{ hashFiles('tools/install_musl_gcc.sh') }}
|
||||||
|
|
||||||
|
- name: Cache build tools
|
||||||
|
id: cache-build-tools
|
||||||
|
uses: actions/cache@v3
|
||||||
|
env:
|
||||||
|
cache-name: cache-build-tools
|
||||||
|
dadk_version: 0.1.6
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
~/.cargo
|
||||||
|
~/.rustup
|
||||||
|
~/.bashrc
|
||||||
|
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ env.dadk_version }}-${{ hashFiles('.github/workflows/cache-toolchain.yml') }}
|
||||||
|
|
||||||
|
- uses: ./.github/actions/install-apt-packages
|
||||||
|
|
16
.github/actions/install-apt-packages/action.yml
vendored
Normal file
16
.github/actions/install-apt-packages/action.yml
vendored
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
name: install-apt-packages
|
||||||
|
|
||||||
|
runs:
|
||||||
|
using: composite
|
||||||
|
steps:
|
||||||
|
|
||||||
|
- uses: awalsh128/cache-apt-pkgs-action@latest
|
||||||
|
with:
|
||||||
|
packages: llvm-dev libclang-dev clang gcc-multilib libssl-dev pkg-config
|
||||||
|
version: ${{ hashFiles('.github/actions/install-apt-packages/action.yml') }}
|
||||||
|
|
||||||
|
- uses: awalsh128/cache-apt-pkgs-action@latest
|
||||||
|
with:
|
||||||
|
packages: gcc-riscv64-unknown-elf gcc-riscv64-linux-gnu gdb-multiarch
|
||||||
|
version: ${{ hashFiles('.github/actions/install-apt-packages/action.yml') }}
|
||||||
|
|
43
.github/workflows/cache-toolchain.yml
vendored
43
.github/workflows/cache-toolchain.yml
vendored
@ -1,4 +1,4 @@
|
|||||||
name: Reusable workflow example
|
name: Cache toolchain
|
||||||
|
|
||||||
on: workflow_call
|
on: workflow_call
|
||||||
|
|
||||||
@ -18,19 +18,23 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
path: |
|
path: |
|
||||||
~/opt
|
~/opt
|
||||||
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('tools/build_gcc_toolchain.sh') }}
|
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('tools/build_gcc_toolchain.sh') }}-${{ hashFiles('tools/install_musl_gcc.sh') }}
|
||||||
|
|
||||||
- if: ${{ steps.cache-dragonos-gcc.outputs.cache-hit != 'true' }}
|
- if: ${{ steps.cache-dragonos-gcc.outputs.cache-hit != 'true' }}
|
||||||
name: build dragonos-gcc
|
name: build dragonos-gcc
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
run: bash tools/build_gcc_toolchain.sh -f
|
run: |
|
||||||
|
bash tools/build_gcc_toolchain.sh -f
|
||||||
|
bash tools/install_musl_gcc.sh
|
||||||
|
|
||||||
|
- uses: ./.github/actions/install-apt-packages
|
||||||
|
|
||||||
- name: Cache build tools
|
- name: Cache build tools
|
||||||
id: cache-build-tools
|
id: cache-build-tools
|
||||||
uses: actions/cache@v3
|
uses: actions/cache@v3
|
||||||
env:
|
env:
|
||||||
cache-name: cache-build-tools
|
cache-name: cache-build-tools
|
||||||
dadk_version: 0.1.2
|
dadk_version: 0.1.6
|
||||||
with:
|
with:
|
||||||
path: |
|
path: |
|
||||||
~/.cargo
|
~/.cargo
|
||||||
@ -40,23 +44,38 @@ jobs:
|
|||||||
|
|
||||||
- if: ${{ steps.cache-build-tools.outputs.cache-hit != 'true' }}
|
- if: ${{ steps.cache-build-tools.outputs.cache-hit != 'true' }}
|
||||||
name: Install toolchain
|
name: Install toolchain
|
||||||
continue-on-error: true
|
continue-on-error: false
|
||||||
run: |
|
run: |
|
||||||
sudo sh -c "apt update && apt install -y llvm-dev libclang-dev clang gcc-multilib libssl-dev pkg-config"
|
|
||||||
cargo install cargo-binutils
|
cargo install cargo-binutils
|
||||||
rustup toolchain install nightly
|
rustup toolchain install nightly-x86_64-unknown-linux-gnu
|
||||||
rustup toolchain install nightly-2023-01-21-x86_64-unknown-linux-gnu
|
rustup toolchain install nightly-2023-01-21-x86_64-unknown-linux-gnu
|
||||||
rustup toolchain install nightly-2023-08-15-x86_64-unknown-linux-gnu
|
rustup toolchain install nightly-2023-08-15-x86_64-unknown-linux-gnu
|
||||||
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-x86_64-unknown-linux-gnu
|
|
||||||
rustup component add rust-src --toolchain nightly-2023-01-21-x86_64-unknown-linux-gnu
|
rustup component add rust-src --toolchain nightly-2023-01-21-x86_64-unknown-linux-gnu
|
||||||
rustup component add rust-src --toolchain nightly-2023-08-15-x86_64-unknown-linux-gnu
|
rustup component add rust-src --toolchain nightly-2023-08-15-x86_64-unknown-linux-gnu
|
||||||
|
rustup target add x86_64-unknown-none --toolchain nightly-2023-01-21-x86_64-unknown-linux-gnu
|
||||||
|
rustup target add x86_64-unknown-none --toolchain nightly-2023-08-15-x86_64-unknown-linux-gnu
|
||||||
|
|
||||||
|
rustup toolchain install nightly-2023-01-21-riscv64gc-unknown-linux-gnu --force-non-host
|
||||||
|
rustup toolchain install nightly-2023-08-15-riscv64gc-unknown-linux-gnu --force-non-host
|
||||||
|
rustup target add riscv64gc-unknown-none-elf --toolchain nightly-2023-01-21-riscv64gc-unknown-linux-gnu
|
||||||
|
rustup target add riscv64imac-unknown-none-elf --toolchain nightly-2023-01-21-riscv64gc-unknown-linux-gnu
|
||||||
|
rustup target add riscv64gc-unknown-none-elf --toolchain nightly-2023-08-15-riscv64gc-unknown-linux-gnu
|
||||||
|
rustup target add riscv64imac-unknown-none-elf --toolchain nightly-2023-08-15-riscv64gc-unknown-linux-gnu
|
||||||
|
|
||||||
|
rustup component add rust-src --toolchain nightly-x86_64-unknown-linux-gnu
|
||||||
|
rustup component add rust-src
|
||||||
|
rustup component add llvm-tools-preview
|
||||||
|
|
||||||
rustup component add rustfmt
|
rustup component add rustfmt
|
||||||
|
rustup component add rustfmt --toolchain nightly-x86_64-unknown-linux-gnu
|
||||||
rustup component add rustfmt --toolchain nightly-2023-01-21-x86_64-unknown-linux-gnu
|
rustup component add rustfmt --toolchain nightly-2023-01-21-x86_64-unknown-linux-gnu
|
||||||
rustup component add rustfmt --toolchain nightly-2023-08-15-x86_64-unknown-linux-gnu
|
rustup component add rustfmt --toolchain nightly-2023-08-15-x86_64-unknown-linux-gnu
|
||||||
|
rustup component add rustfmt --toolchain nightly-2023-01-21-riscv64gc-unknown-linux-gnu
|
||||||
|
rustup component add rustfmt --toolchain nightly-2023-08-15-riscv64gc-unknown-linux-gnu
|
||||||
|
|
||||||
|
rustup default nightly
|
||||||
|
|
||||||
cargo install dadk --version 0.1.6
|
cargo install dadk --version 0.1.6
|
||||||
|
|
||||||
|
|
||||||
|
102
.github/workflows/makefile.yml
vendored
102
.github/workflows/makefile.yml
vendored
@ -2,7 +2,7 @@ name: Build Check
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ "master" ]
|
branches: [ "master", "patch-add-riscv64-github-workflow" ]
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [ "master" ]
|
branches: [ "master" ]
|
||||||
|
|
||||||
@ -11,7 +11,50 @@ jobs:
|
|||||||
ensure-toolchain:
|
ensure-toolchain:
|
||||||
uses: ./.github/workflows/cache-toolchain.yml
|
uses: ./.github/workflows/cache-toolchain.yml
|
||||||
|
|
||||||
build:
|
format-check:
|
||||||
|
name: Format check ${{ matrix.arch }}
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: [ensure-toolchain]
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
arch: [x86_64, riscv64]
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- uses: ./.github/actions/import-toolchain
|
||||||
|
|
||||||
|
- name: Format check
|
||||||
|
env:
|
||||||
|
ARCH: ${{ matrix.arch }}
|
||||||
|
run: |
|
||||||
|
printf "\n" >> kernel/src/include/bindings/bindings.rs
|
||||||
|
printf "\n" >> user/libs/libc/src/include/internal/bindings/bindings.rs
|
||||||
|
FMT_CHECK=1 make fmt
|
||||||
|
|
||||||
|
kernel-static-test:
|
||||||
|
name: Kernel static test ${{ matrix.arch }}
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: [ensure-toolchain]
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
arch: [x86_64, riscv64]
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- uses: ./.github/actions/import-toolchain
|
||||||
|
|
||||||
|
- name: Run kernel static test
|
||||||
|
env:
|
||||||
|
ARCH: ${{ matrix.arch }}
|
||||||
|
run: bash -c "source ~/.cargo/env && cd kernel && make test"
|
||||||
|
|
||||||
|
build-x86_64:
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [ensure-toolchain]
|
needs: [ensure-toolchain]
|
||||||
@ -19,37 +62,30 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Cache DragonOS GCC
|
- uses: ./.github/actions/import-toolchain
|
||||||
id: cache-dragonos-gcc
|
|
||||||
uses: actions/cache@v3
|
|
||||||
env:
|
|
||||||
cache-name: cache-dragonos-gcc
|
|
||||||
with:
|
|
||||||
path: |
|
|
||||||
~/opt
|
|
||||||
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('tools/build_gcc_toolchain.sh') }}
|
|
||||||
|
|
||||||
- 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: Format check
|
|
||||||
run: |
|
|
||||||
printf "\n" >> kernel/src/include/bindings/bindings.rs
|
|
||||||
printf "\n" >> user/libs/libc/src/include/internal/bindings/bindings.rs
|
|
||||||
FMT_CHECK=1 make fmt
|
|
||||||
|
|
||||||
- name: build the DragonOS
|
- name: build the DragonOS
|
||||||
|
env:
|
||||||
|
ARCH: x86_64
|
||||||
run: bash -c "source ~/.cargo/env && export DragonOS_GCC=$HOME/opt/dragonos-gcc/gcc-x86_64-unknown-none/bin && make -j $(nproc) "
|
run: bash -c "source ~/.cargo/env && export DragonOS_GCC=$HOME/opt/dragonos-gcc/gcc-x86_64-unknown-none/bin && make -j $(nproc) "
|
||||||
|
|
||||||
- name: Run kernel static test
|
|
||||||
run: bash -c "source ~/.cargo/env && cd kernel && make test"
|
build-riscv64:
|
||||||
|
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: [ensure-toolchain]
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
submodules: 'recursive'
|
||||||
|
|
||||||
|
- uses: ./.github/actions/import-toolchain
|
||||||
|
|
||||||
|
- name: build the DragonOS
|
||||||
|
env:
|
||||||
|
ARCH: riscv64
|
||||||
|
|
||||||
|
run: bash -c "source ~/.cargo/env && make kernel -j $(nproc)"
|
||||||
|
|
||||||
|
4
Makefile
4
Makefile
@ -42,13 +42,11 @@ all: kernel user
|
|||||||
.PHONY: kernel
|
.PHONY: kernel
|
||||||
kernel:
|
kernel:
|
||||||
mkdir -p bin/kernel/
|
mkdir -p bin/kernel/
|
||||||
@if [ -z $$DragonOS_GCC ]; then echo "\033[31m [错误]尚未安装DragonOS交叉编译器, 请使用tools文件夹下的build_gcc_toolchain.sh脚本安装 \033[0m"; exit 1; fi
|
|
||||||
$(MAKE) -C ./kernel all ARCH=$(ARCH) || (sh -c "echo 内核编译失败" && exit 1)
|
$(MAKE) -C ./kernel all ARCH=$(ARCH) || (sh -c "echo 内核编译失败" && exit 1)
|
||||||
|
|
||||||
.PHONY: user
|
.PHONY: user
|
||||||
user:
|
user:
|
||||||
|
|
||||||
@if [ -z $$DragonOS_GCC ]; then echo "\033[31m [错误]尚未安装DragonOS交叉编译器, 请使用tools文件夹下的build_gcc_toolchain.sh脚本安装 \033[0m"; exit 1; fi
|
|
||||||
$(MAKE) -C ./user all ARCH=$(ARCH) || (sh -c "echo 用户程序编译失败" && exit 1)
|
$(MAKE) -C ./user all ARCH=$(ARCH) || (sh -c "echo 用户程序编译失败" && exit 1)
|
||||||
|
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
|
3
env.mk
3
env.mk
@ -12,6 +12,9 @@ endif
|
|||||||
# 设置编译器
|
# 设置编译器
|
||||||
ifeq ($(ARCH), x86_64)
|
ifeq ($(ARCH), x86_64)
|
||||||
|
|
||||||
|
# 如果 x86_64时,DragonOS_GCC 为空,那么设置为默认值
|
||||||
|
export DragonOS_GCC?=$(HOME)/opt/dragonos-gcc/gcc-x86_64-unknown-none/bin
|
||||||
|
|
||||||
export CC=$(DragonOS_GCC)/x86_64-elf-gcc
|
export CC=$(DragonOS_GCC)/x86_64-elf-gcc
|
||||||
export LD=ld
|
export LD=ld
|
||||||
export AS=$(DragonOS_GCC)/x86_64-elf-as
|
export AS=$(DragonOS_GCC)/x86_64-elf-as
|
||||||
|
@ -16,7 +16,6 @@ ECHO:
|
|||||||
@echo "$@"
|
@echo "$@"
|
||||||
|
|
||||||
all:
|
all:
|
||||||
@if [ -z $$DragonOS_GCC ]; then echo "\033[31m [错误]尚未安装DragonOS交叉编译器, 请使用tools文件夹下的build_gcc_toolchain.sh脚本安装 \033[0m"; exit 1; fi
|
|
||||||
$(MAKE) -C src all ARCH=$(ARCH) || (sh -c "echo 内核编译失败" && exit 1)
|
$(MAKE) -C src all ARCH=$(ARCH) || (sh -c "echo 内核编译失败" && exit 1)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user