Skip to content

Commit 7fa585c

Browse files
committed
feat: workflow build in windows msys2
1 parent 2c0d3c0 commit 7fa585c

File tree

3 files changed

+134
-2
lines changed

3 files changed

+134
-2
lines changed
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
name: Windows MSYS2 Build
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- windows_msys2
8+
pull_request:
9+
branches:
10+
- master
11+
- windows_msys2
12+
13+
env:
14+
BUILD_TYPE: Release
15+
16+
jobs:
17+
build:
18+
name: Windows MSYS2
19+
runs-on: windows-latest
20+
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v4
24+
with:
25+
submodules: recursive
26+
27+
- name: Setup MSYS2
28+
uses: msys2/setup-msys2@v2
29+
with:
30+
msystem: ucrt64
31+
update: true
32+
install: >-
33+
wget
34+
zip
35+
36+
- name: Update MSYS2 and Install Dependencies
37+
shell: msys2 {0}
38+
run: |
39+
dependencies=(
40+
"mingw-w64-ucrt-x86_64-cmake"
41+
"mingw-w64-ucrt-x86_64-extra-cmake-modules"
42+
"mingw-w64-ucrt-x86_64-ninja"
43+
"mingw-w64-ucrt-x86_64-toolchain"
44+
"mingw-w64-ucrt-x86_64-gcc"
45+
"mingw-w64-ucrt-x86_64-openssl"
46+
"mingw-w64-ucrt-x86_64-gtest"
47+
"make"
48+
"cmake"
49+
)
50+
pacman -Syu --noconfirm "${dependencies[@]}"
51+
52+
- name: Build Workflow
53+
shell: msys2 {0}
54+
run: |
55+
mkdir -p build
56+
cmake \
57+
-B build \
58+
-G Ninja \
59+
-S . \
60+
-DCMAKE_BUILD_TYPE=Release
61+
ninja -C build
62+
63+
- name: Build Tutorial
64+
shell: msys2 {0}
65+
run: |
66+
cd tutorial
67+
mkdir -p build
68+
cmake \
69+
-B build \
70+
-G Ninja \
71+
-S . \
72+
-DCMAKE_BUILD_TYPE=Release
73+
ninja -C build
74+
75+
- name: Build and Run Tests (Optional)
76+
shell: msys2 {0}
77+
continue-on-error: true
78+
run: |
79+
cd test
80+
mkdir -p build
81+
cmake \
82+
-B build \
83+
-G Ninja \
84+
-S . \
85+
-DCMAKE_BUILD_TYPE=Release
86+
ninja -C build check
87+
cd build
88+
ctest --output-on-failure
89+
90+
- name: Get Version
91+
id: version
92+
shell: bash
93+
run: |
94+
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
95+
VERSION=${GITHUB_REF#refs/tags/}
96+
else
97+
VERSION=$(date +%Y%m%d-%H%M%S)
98+
fi
99+
echo "version=$VERSION" >> $GITHUB_OUTPUT
100+
echo "Version: $VERSION"
101+
102+
- name: Package Workflow
103+
shell: msys2 {0}
104+
run: |
105+
mkdir -p artifacts
106+
VERSION="${{ steps.version.outputs.version }}"
107+
if [ -d "_lib" ] && [ -d "_include" ]; then
108+
mkdir -p workflow_windows_msys2_${VERSION}
109+
cp -r _lib _include workflow_windows_msys2_${VERSION}/
110+
zip -r artifacts/workflow_windows_msys2_${VERSION}.zip workflow_windows_msys2_${VERSION}
111+
rm -rf workflow_windows_msys2_${VERSION}
112+
fi
113+
114+
- name: Generate Checksums
115+
shell: pwsh
116+
run: |
117+
cd artifacts
118+
Get-ChildItem -File | ForEach-Object {
119+
$hash = (Get-FileHash $_.FullName -Algorithm SHA256).Hash
120+
"$hash $($_.Name)" | Out-File -Append -Encoding utf8 SHA256SUMS.txt
121+
}
122+
123+
- name: Upload Artifacts
124+
uses: actions/upload-artifact@v4
125+
with:
126+
name: workflow-windows-msys2
127+
path: |
128+
artifacts/workflow_windows_msys2_*.zip
129+
artifacts/SHA256SUMS.txt
130+
if-no-files-found: error
131+

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,5 @@
3535
_include
3636
_lib
3737
.vscode
38-
build.cmake
38+
build.cmake
39+
build

test/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ endif ()
4747

4848
if (MINGW)
4949
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -fPIC -pipe -std=gnu90")
50-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fPIC -pipe -std=c++14 -fexceptions")
50+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fPIC -pipe -std=c++17 -fexceptions")
5151
elseif (WIN32)
5252
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP /wd4200")
5353
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP /wd4200 /Zc:__cplusplus /std:c++14")

0 commit comments

Comments
 (0)