|
| 1 | +name: LK CI (Rust) |
| 2 | + |
| 3 | +# Build targets that support `USE_RUST=1` |
| 4 | + |
| 5 | +on: |
| 6 | + pull_request: |
| 7 | + push: |
| 8 | + branches-ignore: |
| 9 | + - 'wip/**' |
| 10 | + - 'docs/**' # Skip builds for documentation branches |
| 11 | + paths-ignore: |
| 12 | + - '**.md' # Skip builds when only markdown files change |
| 13 | + - 'docs/**' # Skip builds for docs directory changes |
| 14 | + |
| 15 | +jobs: |
| 16 | + build: |
| 17 | + runs-on: ubuntu-24.04 |
| 18 | + strategy: |
| 19 | + fail-fast: false |
| 20 | + matrix: |
| 21 | + toolchain-ver: [19] |
| 22 | + debug: [2, 0] |
| 23 | + project: |
| 24 | + # Currently, this is hard-coded here, but should probably be gathered |
| 25 | + # from the source. |
| 26 | + - qemu-virt-arm64-test |
| 27 | + env: |
| 28 | + PROJECT: ${{ matrix.project }} |
| 29 | + TOOLCHAIN_VER: ${{ matrix.toolchain-ver }} |
| 30 | + DEBUG: ${{ matrix.debug }} |
| 31 | + UBSAN: 0 # UBSan runtimes for baremetal are not part of the toolchain |
| 32 | + steps: |
| 33 | + - name: banner |
| 34 | + shell: bash |
| 35 | + run: | |
| 36 | + printf "Building with %d processors\n" "$(nproc)" |
| 37 | + grep -oP '(?<=model name\t: ).*' /proc/cpuinfo|head -n1 |
| 38 | + echo PROJECT = $PROJECT |
| 39 | + echo TOOLCHAIN_VER = $TOOLCHAIN_VER |
| 40 | + echo DEBUG = $DEBUG |
| 41 | + echo UBSAN = $UBSAN |
| 42 | +
|
| 43 | + - name: checkout |
| 44 | + uses: actions/checkout@v4 |
| 45 | + |
| 46 | + # Install LLVM and set up the required environment variables |
| 47 | + - name: compute toolchain |
| 48 | + shell: bash |
| 49 | + run: | |
| 50 | + sudo apt-get install -y clang-${{ matrix.toolchain-ver }} lld-${{ matrix.toolchain-ver }} |
| 51 | + GCC_TOOLCHAIN_PREFIX=$(make list-toolchain | grep TOOLCHAIN_PREFIX | tail -1 | cut -d ' ' -f 3) |
| 52 | + # Map the GCC toolchain prefix to a clang --target argument: |
| 53 | + CLANG_TRIPLE=$(echo "${GCC_TOOLCHAIN_PREFIX}" | sed 's/-elf-/-unknown-elf/g') |
| 54 | + LLVM_BINDIR=/usr/lib/llvm-${{ matrix.toolchain-ver }}/bin |
| 55 | + echo "CC=${LLVM_BINDIR}/clang --target=${CLANG_TRIPLE}" >> $GITHUB_ENV |
| 56 | + echo "LD=${LLVM_BINDIR}/ld.lld" >> $GITHUB_ENV |
| 57 | + echo "OBJDUMP=${LLVM_BINDIR}/llvm-objdump" >> $GITHUB_ENV |
| 58 | + echo "OBJCOPY=${LLVM_BINDIR}/llvm-objcopy" >> $GITHUB_ENV |
| 59 | + echo "CPPFILT=${LLVM_BINDIR}/llvm-cxxfilt" >> $GITHUB_ENV |
| 60 | + echo "SIZE=${LLVM_BINDIR}/llvm-size" >> $GITHUB_ENV |
| 61 | + echo "NM=${LLVM_BINDIR}/llvm-nm" >> $GITHUB_ENV |
| 62 | + echo "STRIP=${LLVM_BINDIR}/llvm-strip" >> $GITHUB_ENV |
| 63 | + echo "TOOLCHAIN_PREFIX=/invalid/prefix/should/not/be/used" >> $GITHUB_ENV |
| 64 | + echo "LIBGCC=" >> $GITHUB_ENV |
| 65 | + cat "$GITHUB_ENV" |
| 66 | +
|
| 67 | + # Install Rust |
| 68 | + # Note that rustup is already included in the image, and we just need to add our target. |
| 69 | + - name: install rust |
| 70 | + shell: bash |
| 71 | + run: | |
| 72 | + rustup install nightly |
| 73 | + rustup component add rust-src --toolchain nightly |
| 74 | + rustup target add aarch64-unknown-linux-gnu |
| 75 | + rustup target add aarch64-unknown-none |
| 76 | +
|
| 77 | + # build it |
| 78 | + - name: build |
| 79 | + shell: bash |
| 80 | + run: | |
| 81 | + make -j $(nproc) USE_RUST=1 |
| 82 | + # When LK is compiled with DEBUG=0, there's no console and no way for us |
| 83 | + # to read test output |
| 84 | + - name: qemu |
| 85 | + if: ${{ matrix.project == 'qemu-virt-arm64-test' }} |
| 86 | + shell: bash |
| 87 | + run: | |
| 88 | + env -i DEBIAN_FRONTEND=noninteractive sudo apt-get update |
| 89 | + env -i DEBIAN_FRONTEND=noninteractive sudo apt-get install -y qemu-system-arm |
| 90 | + - name: unittest |
| 91 | + if: ${{ matrix.project == 'qemu-virt-arm64-test' }} |
| 92 | + shell: bash |
| 93 | + run: | |
| 94 | + python3 scripts/unittest.py |
| 95 | +
|
| 96 | +# vim: ts=2 sw=2 expandtab |
0 commit comments