1name: Build Check
2
3on:
4  push:
5    branches: [ "master" ]
6  pull_request:
7    branches: [ "master" ]
8
9jobs:
10  build:
11
12    runs-on: ubuntu-latest
13
14    steps:
15    - uses: actions/checkout@v3
16
17    - name: Cache DragonOS GCC
18      id: cache-dragonos-gcc
19      uses: actions/cache@v3
20      env:
21          cache-name: cache-dragonos-gcc
22      with:
23        path: |
24          ~/opt
25        key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('tools/build_gcc_toolchain.sh') }}
26
27    - if: ${{ steps.cache-dragonos-gcc.outputs.cache-hit != 'true' }}
28      name: build dragonos-gcc
29      continue-on-error: true
30      run: bash tools/build_gcc_toolchain.sh -f
31
32    - name: Cache build tools
33      id: cache-build-tools
34      uses: actions/cache@v3
35      env:
36          cache-name: cache-build-tools
37      with:
38        path: |
39          ~/.cargo
40          ~/.rustup
41          ~/.bashrc
42        key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('.github/workflows/makefile.yml') }}
43
44    - if: ${{ steps.cache-build-tools.outputs.cache-hit != 'true' }}
45      name: Install toolchain
46      continue-on-error: true
47      run:  sudo apt install -y llvm-dev libclang-dev clang gcc-multilib && 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
48
49    - name: build the DragonOS
50      run: bash -c "source ~/.cargo/env && export DragonOS_GCC=$HOME/opt/dragonos-gcc/gcc-x86_64-unknown-none/bin && make -j $(nproc) "
51