1name: Reusable workflow example 2 3on: workflow_call 4 5jobs: 6 build: 7 8 runs-on: ubuntu-latest 9 10 steps: 11 - uses: actions/checkout@v3 12 13 - name: Cache DragonOS GCC 14 id: cache-dragonos-gcc 15 uses: actions/cache@v3 16 env: 17 cache-name: cache-dragonos-gcc 18 with: 19 path: | 20 ~/opt 21 key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('tools/build_gcc_toolchain.sh') }} 22 23 - if: ${{ steps.cache-dragonos-gcc.outputs.cache-hit != 'true' }} 24 name: build dragonos-gcc 25 continue-on-error: true 26 run: bash tools/build_gcc_toolchain.sh -f 27 28 - name: Cache build tools 29 id: cache-build-tools 30 uses: actions/cache@v3 31 env: 32 cache-name: cache-build-tools 33 dadk_version: 0.1.2 34 with: 35 path: | 36 ~/.cargo 37 ~/.rustup 38 ~/.bashrc 39 key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ env.dadk_version }}-${{ hashFiles('.github/workflows/cache-toolchain.yml') }} 40 41 - if: ${{ steps.cache-build-tools.outputs.cache-hit != 'true' }} 42 name: Install toolchain 43 continue-on-error: true 44 run: | 45 sudo sh -c "apt update && apt install -y llvm-dev libclang-dev clang gcc-multilib libssl-dev pkg-config" 46 cargo install cargo-binutils 47 rustup toolchain install nightly 48 rustup toolchain install nightly-2023-01-21-x86_64-unknown-linux-gnu 49 rustup toolchain install nightly-2023-08-15-x86_64-unknown-linux-gnu 50 rustup default nightly 51 rustup component add rust-src 52 rustup component add llvm-tools-preview 53 rustup target add x86_64-unknown-none 54 rustup component add rust-src --toolchain nightly-x86_64-unknown-linux-gnu 55 rustup component add rust-src --toolchain nightly-2023-01-21-x86_64-unknown-linux-gnu 56 rustup component add rust-src --toolchain nightly-2023-08-15-x86_64-unknown-linux-gnu 57 rustup component add rustfmt 58 rustup component add rustfmt --toolchain nightly-2023-01-21-x86_64-unknown-linux-gnu 59 rustup component add rustfmt --toolchain nightly-2023-08-15-x86_64-unknown-linux-gnu 60 cargo install dadk --version 0.1.6 61 62 63 fork_toolchain_from="nightly-2023-08-15-x86_64-unknown-linux-gnu" 64 custom_toolchain="nightly-2023-08-15-x86_64-unknown-linux_dragonos-gnu" 65 custom_toolchain_dir="$(dirname $(rustc --print sysroot))/${custom_toolchain}" 66 echo "Custom toolchain does not exist, creating..." 67 rustup toolchain install ${fork_toolchain_from} 68 rustup component add --toolchain ${fork_toolchain_from} rust-src 69 rustup target add --toolchain ${fork_toolchain_from} x86_64-unknown-linux-musl 70 cp -r $(dirname $(rustc --print sysroot))/${fork_toolchain_from} ${custom_toolchain_dir} 71 self_contained_dir=${custom_toolchain_dir}/lib/rustlib/x86_64-unknown-linux-musl/lib/self-contained 72 cp -f ${self_contained_dir}/crt1.o ${self_contained_dir}/rcrt1.o 73 74 75