xref: /freebsd/.github/workflows/cross-bootstrap-tools.yml (revision cfd6422a5217410fbd66f7a7a8a64d9d85e61229)
1name: Cross-build Kernel
2
3on:
4  push:
5    branches: [ main ]
6  pull_request:
7    branches: [ main ]
8
9jobs:
10  build:
11    name: ${{ matrix.os }} (${{ matrix.compiler }})
12    runs-on: ${{ matrix.os }}
13    strategy:
14      fail-fast: false
15      matrix:
16        include:
17          # TODO: both Ubuntu and macOS have bmake packages, we should try them instead of bootstrapping our own copy.
18          - os: ubuntu-20.04
19            compiler: clang-9
20            cross-bindir: /usr/lib/llvm-9/bin
21            pkgs: bmake libarchive-dev
22          - os: ubuntu-20.04
23            compiler: clang-10
24            cross-bindir: /usr/lib/llvm-10/bin
25            pkgs: bmake libarchive-dev
26          - os: macOS-latest
27            compiler: clang-11
28            pkgs: bmake libarchive
29
30    steps:
31      - uses: actions/checkout@v2
32      - name: install packages (Ubuntu)
33        if: runner.os == 'Linux'
34        run: |
35          sudo apt-get update --quiet || true
36          sudo apt-get -yq --no-install-suggests --no-install-recommends install ${{ matrix.pkgs }}
37      - name: install packages (macOS)
38        if: runner.os == 'macOS'
39        run: |
40          brew update --quiet || true
41          brew install ${{ matrix.pkgs }} || true
42      - name: create environment
43        run: |
44          echo "GITHUB_WORKSPACE = $GITHUB_WORKSPACE"
45          if [ -n "${{ matrix.cross-bindir }}" ]; then
46            echo "EXTRA_BUILD_ARGS=--cross-bindir=${{ matrix.cross-bindir }}" >> $GITHUB_ENV
47          fi
48          mkdir -p ../build
49          echo "MAKEOBJDIRPREFIX=${PWD%/*}/build" >> $GITHUB_ENV
50          # heh, works on Linux/BSD/macOS ...
51          echo "NPROC=`getconf _NPROCESSORS_ONLN 2>/dev/null || getconf NPROCESSORS_ONLN 2>/dev/null || echo 1`" >> $GITHUB_ENV
52      - name: bootstrap bmake
53        run: ./tools/build/make.py --debug $EXTRA_BUILD_ARGS TARGET=amd64 TARGET_ARCH=amd64 -n
54      - name: make kernel-toolchain
55        run: ./tools/build/make.py --debug $EXTRA_BUILD_ARGS TARGET=amd64 TARGET_ARCH=amd64 kernel-toolchain -s -j$NPROC
56      - name: make buildkernel
57        run: ./tools/build/make.py --debug $EXTRA_BUILD_ARGS TARGET=amd64 TARGET_ARCH=amd64 KERNCONF=GENERIC NO_MODULES=yes buildkernel -s -j$NPROC $EXTRA_MAKE_ARGS
58