From f03020296bb12d2b368384113f8c6be474bdeb25 Mon Sep 17 00:00:00 2001 From: Martin Ling Date: Sun, 5 Oct 2025 06:48:39 +0100 Subject: [PATCH] CI: Add host builds using MSYS. --- .github/workflows/build.yml | 147 +++++++++++++++++++----------------- 1 file changed, 77 insertions(+), 70 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f84cb5b5..34b511bf 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -9,8 +9,6 @@ on: - cron: 1 12 * * 1 env: - WIN_PKG_CONFIG: -DPKG_CONFIG_EXECUTABLE=C:/vcpkg/installed/x64-windows/tools/pkgconf/pkgconf.exe - WIN_CMAKE_TOOLCHAIN: -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake # Override OSX architecture detection. Required for CMake versions < 3.19.2. CMAKE_OSX_ARCHITECTURES: arm64 @@ -19,18 +17,44 @@ jobs: host: strategy: matrix: - os: ['macos', 'ubuntu', 'windows'] + sys: + - {os: 'macos', shell: 'bash'} + - {os: 'ubuntu', shell: 'bash'} + - {os: 'windows', shell: 'pwsh'} + - {os: 'windows', shell: 'msys2'} cmake: ['3.10.0', '3.16.0', '3.21.0', '4.0.0', 'latest'] exclude: # GitHub runners use Visual Studio 2022. Support added in CMake 3.21. - - os: 'windows' + - sys: {os: 'windows', shell: 'pwsh'} cmake: '3.10.0' - - os: 'windows' + - sys: {os: 'windows', shell: 'pwsh'} cmake: '3.16.0' + # MSYS2 always supplies the latest cmake. + - sys: {os: 'windows', shell: 'msys2'} + cmake: '3.10.0' + - sys: {os: 'windows', shell: 'msys2'} + cmake: '3.16.0' + - sys: {os: 'windows', shell: 'msys2'} + cmake: '3.21.0' + - sys: {os: 'windows', shell: 'msys2'} + cmake: '4.0.0' + include: + - sys: {os: 'windows', shell: 'pwsh'} + cmake_args: >- + -DPKG_CONFIG_EXECUTABLE=C:/vcpkg/installed/x64-windows/tools/pkgconf/pkgconf.exe + -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake + --install-prefix=$env:GITHUB_WORKSPACE/install + - sys: {os: 'windows', shell: 'msys2'} + cmake_args: >- + --install-prefix=/usr/local # Don't cancel all builds when one fails fail-fast: false - runs-on: ${{ matrix.os }}-latest + runs-on: ${{ matrix.sys.os }}-latest + + defaults: + run: + shell: '${{ matrix.sys.shell }} {0}' steps: - uses: actions/checkout@v4 @@ -39,109 +63,92 @@ jobs: uses: jwlawson/actions-setup-cmake@v2 with: cmake-version: ${{ matrix.cmake }} + if: matrix.sys.shell != 'msys2' - name: Install dependencies (macOS) run: brew install fftw - if: matrix.os == 'macos' + if: matrix.sys.os == 'macos' - name: Install dependencies (Ubuntu) run: | sudo apt update sudo apt install libfftw3-dev libusb-1.0-0-dev - if: matrix.os == 'ubuntu' + if: matrix.sys.os == 'ubuntu' - name: Install dependencies (Windows) run: vcpkg install --triplet=x64-windows libusb fftw3 pthreads pkgconf - if: matrix.os == 'windows' + if: matrix.sys.os == 'windows' && matrix.sys.shell != 'msys2' + + - name: Setup MSYS (Windows) + if: matrix.sys.os == 'windows' && matrix.sys.shell == 'msys2' + uses: msys2/setup-msys2@v2 + with: + msystem: UCRT64 + install: >- + git + make + mingw-w64-ucrt-x86_64-cmake + mingw-w64-ucrt-x86_64-toolchain + mingw-w64-ucrt-x86_64-libusb + mingw-w64-ucrt-x86_64-fftw # Build libhackrf and hackrf-tools together - name: Create Build Environment - run: cmake -E make_directory ${{github.workspace}}/host/build + run: cmake -E make_directory host/build - - name: Configure CMake - working-directory: ${{github.workspace}}/host/build - run: cmake $GITHUB_WORKSPACE/host/ -DCMAKE_BUILD_TYPE=Release - if: matrix.os != 'windows' - - - name: Configure CMake (Windows) - working-directory: ${{github.workspace}}/host/build - run: cmake $env:GITHUB_WORKSPACE/host/ $env:WIN_PKG_CONFIG $env:WIN_CMAKE_TOOLCHAIN - if: matrix.os == 'windows' - - - name: Build - working-directory: ${{github.workspace}}/host/build - run: cmake --build . --config Release + - name: Configure & Build + run: | + cd host/build + cmake .. -DCMAKE_BUILD_TYPE=Release ${{matrix.cmake_args}} + cmake --build . --config Release # Build libhackrf ONLY - name: Create Build Environment (libhackrf) - run: cmake -E make_directory ${{github.workspace}}/host/libhackrf/build + run: cmake -E make_directory host/libhackrf/build - - name: Configure CMake (libhackrf) - working-directory: ${{github.workspace}}/host/libhackrf/build - run: cmake $GITHUB_WORKSPACE/host/libhackrf/ -DCMAKE_BUILD_TYPE=Release - if: matrix.os != 'windows' - - - name: Configure CMake (libhackrf, Windows) - working-directory: ${{github.workspace}}/host/libhackrf/build - run: cmake $env:GITHUB_WORKSPACE/host/libhackrf/ $env:WIN_PKG_CONFIG $env:WIN_CMAKE_TOOLCHAIN - if: matrix.os == 'windows' - - - name: Build (libhackrf) - working-directory: ${{github.workspace}}/host/libhackrf/build - run: cmake --build . --config Release + - name: Configure & Build (libhackrf) + run: | + cd host/libhackrf/build + cmake .. -DCMAKE_BUILD_TYPE=Release ${{ matrix.cmake_args }} + cmake --build . --config Release - name: Install (libhackrf) - working-directory: ${{github.workspace}}/host/libhackrf/build run: | - sudo cmake --install . --config Release - if: matrix.os != 'windows' && matrix.cmake != '3.10.0' + sudo cmake --install host/libhackrf/build --config Release + if: matrix.sys.os != 'windows' && matrix.cmake != '3.10.0' - name: Install (libhackrf, CMake 3.10) - working-directory: ${{github.workspace}}/host/libhackrf/build run: | - sudo cmake --build . --target install --config Release - if: matrix.os != 'windows' && matrix.cmake == '3.10.0' + sudo cmake --build host/libhackrf/build --target install --config Release + if: matrix.sys.os != 'windows' && matrix.cmake == '3.10.0' - name: Install (libhackrf, Windows) - working-directory: ${{github.workspace}}/host/libhackrf/build - run: cmake --install . --config Release --prefix=$env:GITHUB_WORKSPACE/install - if: matrix.os == 'windows' + run: cmake --install host/libhackrf/build --config Release + if: matrix.sys.os == 'windows' # Build hackrf-tools ONLY - name: Create Build Environment (hackrf-tools) - run: cmake -E make_directory ${{github.workspace}}/host/hackrf-tools/build + run: cmake -E make_directory host/hackrf-tools/build - - name: Configure CMake (hackrf-tools) - working-directory: ${{github.workspace}}/host/hackrf-tools/build - run: cmake $GITHUB_WORKSPACE/host/hackrf-tools/ -DCMAKE_BUILD_TYPE=Release - if: matrix.os != 'windows' - - - name: Configure CMake (hackrf-tools, Windows) - working-directory: ${{github.workspace}}/host/hackrf-tools/build + - name: Configure & Build (hackrf-tools) run: | - cmake $env:GITHUB_WORKSPACE/host/hackrf-tools/ -DLIBHACKRF_INCLUDE_DIR="$env:GITHUB_WORKSPACE/install/include/libhackrf" -DLIBHACKRF_LIBRARIES="$env:GITHUB_WORKSPACE/install/bin/hackrf.lib" $env:WIN_PKG_CONFIG $env:WIN_CMAKE_TOOLCHAIN - if: matrix.os == 'windows' - - - name: Build (hackrf-tools) - working-directory: ${{github.workspace}}/host/hackrf-tools/build - run: cmake --build . --config Release + cd host/hackrf-tools/build + cmake .. -DCMAKE_BUILD_TYPE=Release ${{ matrix.cmake_args }} + cmake --build . --config Release - name: Install (hackrf-tools) - working-directory: ${{github.workspace}}/host/hackrf-tools/build run: | - sudo cmake --install . --config Release - if: matrix.os != 'windows' && matrix.cmake != '3.10.0' + sudo cmake --install host/hackrf-tools/build --config Release + if: matrix.sys.os != 'windows' && matrix.cmake != '3.10.0' - name: Install (hackrf-tools, CMake 3.10) - working-directory: ${{github.workspace}}/host/hackrf-tools/build run: | - sudo cmake --build . --target install --config Release - if: matrix.os != 'windows' && matrix.cmake == '3.10.0' + sudo cmake --build host/hackrf-tools/build --target install --config Release + if: matrix.sys.os != 'windows' && matrix.cmake == '3.10.0' - name: Install (hackrf-tools, Windows) - working-directory: ${{github.workspace}}/host/hackrf-tools/build - run: cmake --install . --config Release --prefix=$env:GITHUB_WORKSPACE/install - if: matrix.os == 'windows' + run: cmake --install host/hackrf-tools/build --config Release + if: matrix.sys.os == 'windows' # Publish the contents of install/bin (which should be the combination libhackrf and host-tools) for Windows - name: Publish Artifacts (Windows) @@ -149,7 +156,7 @@ jobs: with: name: hackrf-tools-windows path: ${{github.workspace}}/install/bin - if: matrix.os == 'windows' && matrix.cmake == 'latest' + if: matrix.sys.os == 'windows' && matrix.cmake == 'latest' && matrix.sys.shell == 'pwsh' firmware: strategy: