From c70cc5832b6bcd70c5917350d5805af8ce03b2e4 Mon Sep 17 00:00:00 2001 From: Jameson Nash Date: Thu, 19 Jan 2023 14:00:15 -0600 Subject: [PATCH] build,win: add mingw-w64 CI configuration (#3885) Co-authored-by: Nicolas Noble --- .github/workflows/CI-win.yml | 58 ++++++++++++++++++++++++++++ cmake-toolchains/cross-mingw32.cmake | 17 ++++++++ 2 files changed, 75 insertions(+) create mode 100644 cmake-toolchains/cross-mingw32.cmake diff --git a/.github/workflows/CI-win.yml b/.github/workflows/CI-win.yml index ca6741df..a8810ead 100644 --- a/.github/workflows/CI-win.yml +++ b/.github/workflows/CI-win.yml @@ -62,3 +62,61 @@ jobs: shell: cmd run: build\\RelWithDebInfo\\uv_run_tests_a.exe + + build-mingw: + runs-on: ubuntu-latest + name: build-mingw-${{ matrix.config.arch }} + strategy: + fail-fast: false + matrix: + config: + - {arch: i686, server: 2022, libgcc: dw2 } + - {arch: x86_64, server: 2022, libgcc: seh } + steps: + - uses: actions/checkout@v3 + - name: Install mingw32 environment + run: | + sudo apt update + sudo apt install mingw-w64 ninja-build -y + - name: Build + run: | + cmake -S . -B build -G Ninja -DHOST_ARCH=${{ matrix.config.arch }} -DBUILD_TESTING=ON -DCMAKE_TOOLCHAIN_FILE=cmake-toolchains/cross-mingw32.cmake + cmake --build build + cmake --install build --prefix "`pwd`/build/usr" + mkdir -p build/usr/test build/usr/bin + cp -av test/fixtures build/usr/test + cp -av build/uv_run_tests_a.exe build/uv_run_tests.exe \ + `${{ matrix.config.arch }}-w64-mingw32-gcc -print-file-name=libgcc_s_${{ matrix.config.libgcc }}-1.dll` \ + `${{ matrix.config.arch }}-w64-mingw32-gcc -print-file-name=libwinpthread-1.dll` \ + `${{ matrix.config.arch }}-w64-mingw32-gcc -print-file-name=libatomic-1.dll` \ + build/usr/bin + - name: Upload build artifacts + uses: actions/upload-artifact@v3 + with: + name: mingw-${{ matrix.config.arch }} + path: build/usr/**/* + retention-days: 2 + + test-mingw: + runs-on: windows-${{ matrix.config.server }} + name: test-mingw-${{ matrix.config.arch }} + needs: build-mingw + strategy: + fail-fast: false + matrix: + config: + - {arch: i686, server: 2022} + - {arch: x86_64, server: 2022} + steps: + - name: Download build artifacts + uses: actions/download-artifact@v2 + with: + name: mingw-${{ matrix.config.arch }} + - name: Test + shell: cmd + run: | + bin\uv_run_tests_a.exe + - name: Test + shell: cmd + run: | + bin\uv_run_tests.exe diff --git a/cmake-toolchains/cross-mingw32.cmake b/cmake-toolchains/cross-mingw32.cmake new file mode 100644 index 00000000..3fe1dd69 --- /dev/null +++ b/cmake-toolchains/cross-mingw32.cmake @@ -0,0 +1,17 @@ +if(NOT HOST_ARCH) + message(SEND_ERROR "-DHOST_ARCH required to be specified") +endif() + +list(APPEND CMAKE_TRY_COMPILE_PLATFORM_VARIABLES + HOST_ARCH + ) + +SET(CMAKE_SYSTEM_NAME Windows) +set(COMPILER_PREFIX "${HOST_ARCH}-w64-mingw32") +find_program(CMAKE_RC_COMPILER NAMES ${COMPILER_PREFIX}-windres) +find_program(CMAKE_C_COMPILER NAMES ${COMPILER_PREFIX}-gcc) +find_program(CMAKE_CXX_COMPILER NAMES ${COMPILER_PREFIX}-g++) + +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)