Skip to content

Commit c70cc58

Browse files
vtjnashnicolasnoble
andauthoredJan 19, 2023
build,win: add mingw-w64 CI configuration (libuv#3885)
Co-authored-by: Nicolas Noble <[email protected]>
1 parent a4ba1bd commit c70cc58

File tree

2 files changed

+75
-0
lines changed

2 files changed

+75
-0
lines changed
 

‎.github/workflows/CI-win.yml

+58
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,61 @@ jobs:
6262
shell: cmd
6363
run:
6464
build\\RelWithDebInfo\\uv_run_tests_a.exe
65+
66+
build-mingw:
67+
runs-on: ubuntu-latest
68+
name: build-mingw-${{ matrix.config.arch }}
69+
strategy:
70+
fail-fast: false
71+
matrix:
72+
config:
73+
- {arch: i686, server: 2022, libgcc: dw2 }
74+
- {arch: x86_64, server: 2022, libgcc: seh }
75+
steps:
76+
- uses: actions/checkout@v3
77+
- name: Install mingw32 environment
78+
run: |
79+
sudo apt update
80+
sudo apt install mingw-w64 ninja-build -y
81+
- name: Build
82+
run: |
83+
cmake -S . -B build -G Ninja -DHOST_ARCH=${{ matrix.config.arch }} -DBUILD_TESTING=ON -DCMAKE_TOOLCHAIN_FILE=cmake-toolchains/cross-mingw32.cmake
84+
cmake --build build
85+
cmake --install build --prefix "`pwd`/build/usr"
86+
mkdir -p build/usr/test build/usr/bin
87+
cp -av test/fixtures build/usr/test
88+
cp -av build/uv_run_tests_a.exe build/uv_run_tests.exe \
89+
`${{ matrix.config.arch }}-w64-mingw32-gcc -print-file-name=libgcc_s_${{ matrix.config.libgcc }}-1.dll` \
90+
`${{ matrix.config.arch }}-w64-mingw32-gcc -print-file-name=libwinpthread-1.dll` \
91+
`${{ matrix.config.arch }}-w64-mingw32-gcc -print-file-name=libatomic-1.dll` \
92+
build/usr/bin
93+
- name: Upload build artifacts
94+
uses: actions/upload-artifact@v3
95+
with:
96+
name: mingw-${{ matrix.config.arch }}
97+
path: build/usr/**/*
98+
retention-days: 2
99+
100+
test-mingw:
101+
runs-on: windows-${{ matrix.config.server }}
102+
name: test-mingw-${{ matrix.config.arch }}
103+
needs: build-mingw
104+
strategy:
105+
fail-fast: false
106+
matrix:
107+
config:
108+
- {arch: i686, server: 2022}
109+
- {arch: x86_64, server: 2022}
110+
steps:
111+
- name: Download build artifacts
112+
uses: actions/download-artifact@v2
113+
with:
114+
name: mingw-${{ matrix.config.arch }}
115+
- name: Test
116+
shell: cmd
117+
run: |
118+
bin\uv_run_tests_a.exe
119+
- name: Test
120+
shell: cmd
121+
run: |
122+
bin\uv_run_tests.exe

‎cmake-toolchains/cross-mingw32.cmake

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
if(NOT HOST_ARCH)
2+
message(SEND_ERROR "-DHOST_ARCH required to be specified")
3+
endif()
4+
5+
list(APPEND CMAKE_TRY_COMPILE_PLATFORM_VARIABLES
6+
HOST_ARCH
7+
)
8+
9+
SET(CMAKE_SYSTEM_NAME Windows)
10+
set(COMPILER_PREFIX "${HOST_ARCH}-w64-mingw32")
11+
find_program(CMAKE_RC_COMPILER NAMES ${COMPILER_PREFIX}-windres)
12+
find_program(CMAKE_C_COMPILER NAMES ${COMPILER_PREFIX}-gcc)
13+
find_program(CMAKE_CXX_COMPILER NAMES ${COMPILER_PREFIX}-g++)
14+
15+
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
16+
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
17+
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

0 commit comments

Comments
 (0)
Please sign in to comment.