1+ name : CMake CI
2+
3+ on :
4+ push :
5+ paths :
6+ - " **.c"
7+ - " **.h"
8+ - " **.cpp"
9+ - " **.hpp"
10+ - " **.py"
11+ - " **.build"
12+ - " **.options"
13+ pull_request :
14+ paths :
15+ - " **.c"
16+ - " **.h"
17+ - " **.cpp"
18+ - " **.hpp"
19+ - " **.py"
20+ - " **.build"
21+ - " **.options"
22+
23+ jobs :
24+ build_msvc :
25+ name : Building on MSVC ${{ matrix.msvc_version }}
26+ runs-on : windows-latest
27+ strategy :
28+ matrix :
29+ msvc_version : [2015, 2017, 2019, 2022]
30+ steps :
31+ - name : Checkout code
32+ uses : actions/checkout@v4
33+ with :
34+ fetch-depth : 0
35+
36+ - name : Set up Python
37+ uses : actions/setup-python@v5
38+ with :
39+ python-version : ' 3.12'
40+
41+ - name : Install CMake and Ninja
42+ shell : pwsh
43+ run : |
44+ python -m pip install --upgrade pip
45+ python -m pip install cmake ninja
46+ if ($env:msvc_version -eq "2015") {
47+ choco install visualstudio2015buildtools --package-parameters "--add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 --includeRecommended --includeOptional --passive"
48+ } elseif ($env:msvc_version -eq "2017") {
49+ choco install visualstudio2017buildtools --package-parameters "--add Microsoft.VisualStudio.Workload.VCTools --includeRecommended --includeOptional --passive"
50+ } elseif ($env:msvc_version -eq "2019") {
51+ choco install visualstudio2019buildtools --package-parameters "--add Microsoft.VisualStudio.Workload.VCTools --includeRecommended --includeOptional --passive"
52+ } elseif ($env:msvc_version -eq "2022") {
53+ choco install visualstudio2022buildtools --package-parameters "--add Microsoft.VisualStudio.Workload.VCTools --includeRecommended --includeOptional --passive"
54+ }
55+ $env:CC="cl.exe"
56+ $env:CXX="cl.exe"
57+
58+ - name : Configure CMake
59+ run : cmake -S . -B build_msvc_${{ matrix.msvc_version }} -G "Ninja" -DWITH_TEST=ON
60+
61+ - name : Build
62+ run : cmake --build build_msvc_${{ matrix.msvc_version }} --config Release
63+
64+ - name : Upload Build Log
65+ if : failure()
66+ uses : actions/upload-artifact@v4
67+ with :
68+ name : windows_msvc_${{ matrix.msvc_version }}_cmake_buildlog
69+ path : build_msvc_${{ matrix.msvc_version }}/build.ninja
70+
71+ build_macosx :
72+ name : Building on macOS with Xcode ${{ matrix.xcode_version }}
73+ runs-on : macos-latest
74+ strategy :
75+ matrix :
76+ xcode_version : ["15.2", "15.3"]
77+ steps :
78+ - name : Checkout code
79+ uses : actions/checkout@v4
80+ with :
81+ fetch-depth : 0
82+
83+ - name : Set up Python
84+ uses : actions/setup-python@v5
85+ with :
86+ python-version : ' 3.12'
87+
88+ - name : Install Xcode
89+ run : sudo xcode-select --switch /Applications/Xcode_${{ matrix.xcode_version }}.app
90+
91+ - name : Install CMake and Ninja
92+ run : |
93+ python -m pip install cmake ninja
94+
95+ - name : Configure CMake
96+ run : cmake -S . -B builddir -G "Ninja" -DWITH_TEST=ON
97+
98+ - name : Build
99+ run : cmake --build builddir --config Release
100+
101+ - name : Upload Build Log
102+ if : failure()
103+ uses : actions/upload-artifact@v4
104+ with :
105+ name : macos_xcode_${{ matrix.xcode_version }}_cmake_buildlog
106+ path : builddir/build.ninja
107+
108+ build_msys :
109+ name : Building on MSYS ${{ matrix.architecture }}
110+ runs-on : windows-latest
111+ strategy :
112+ matrix :
113+ architecture : [x86, x64]
114+ steps :
115+ - name : Checkout code
116+ uses : actions/checkout@v4
117+ with :
118+ fetch-depth : 0
119+
120+ - name : Set up MSYS2
121+ uses : msys2/setup-msys2@v2
122+ with :
123+ update : true
124+
125+ - name : Set environment variables
126+ run : |
127+ echo "CC=/mingw${{ matrix.architecture }}/bin/gcc.exe" >> $GITHUB_ENV
128+ echo "CXX=/mingw${{ matrix.architecture }}/bin/g++.exe" >> $GITHUB_ENV
129+
130+ - name : Set up Python
131+ uses : actions/setup-python@v5
132+ with :
133+ python-version : ' 3.12'
134+
135+ - name : Install CMake and Ninja
136+ run : |
137+ python -m pip install cmake ninja
138+
139+ - name : Configure CMake
140+ run : cmake -S . -B builddir -G "Ninja" -DWITH_TEST=ON
141+
142+ - name : Build
143+ run : cmake --build builddir --config Release
144+
145+ - name : Upload Build Log
146+ if : failure()
147+ uses : actions/upload-artifact@v4
148+ with :
149+ name : msys_${{ matrix.architecture }}_cmake_buildlog
150+ path : builddir/build.ninja
151+
152+ build_posix :
153+ name : Build on Linux ${{ matrix.distro }}
154+ runs-on : ubuntu-latest
155+
156+ strategy :
157+ matrix :
158+ distro : [ubuntu, fedora, archlinux, debian]
159+
160+ steps :
161+ - name : Checkout code
162+ uses : actions/checkout@v4
163+ with :
164+ fetch-depth : 0
165+
166+ - name : Set up Docker Buildx
167+ uses : docker/setup-buildx-action@v3
168+
169+ - name : Cache Docker layers
170+ uses : actions/cache@v4
171+ with :
172+ path : /tmp/.buildx-cache
173+ key : ${{ runner.os }}-buildx-${{ matrix.distro }}
174+ restore-keys : |
175+ ${{ runner.os }}-buildx
176+
177+ - name : Build Docker Image
178+ run : |
179+ docker build \
180+ --file .github/ciimage/Dockerfile.${{ matrix.distro }} \
181+ --tag ${GITHUB_REPOSITORY}:${{ matrix.distro }} .
182+
183+ - name : Run CMake Build in Docker Container
184+ run : |
185+ docker run --rm \
186+ -v ${{ github.workspace }}:/workspace \
187+ -w /workspace \
188+ ${GITHUB_REPOSITORY}:${{ matrix.distro }} \
189+ /bin/bash -c "
190+ apt-get update
191+ cmake -S . -B builddir -G Ninja -DWITH_TEST=ON
192+ cmake --build builddir --config Release"
193+
194+ build_cross :
195+ name : Building on Bedrock ${{ matrix.architecture }}
196+ runs-on : ubuntu-latest # Using Ubuntu as the base system for cross-compilation
197+
198+ strategy :
199+ matrix :
200+ architecture : [arm, arm64, mips, mipsel, riscv64, ppc, ppc64le, sparc64, s390x]
201+
202+ steps :
203+ - name : Checkout code
204+ uses : actions/checkout@v4
205+ with :
206+ fetch-depth : 0
207+
208+ - name : Set up Python
209+ uses : actions/setup-python@v5
210+ with :
211+ python-version : ' 3.12'
212+
213+ - name : Install Cross-Compilation Toolchain
214+ run : |
215+ sudo apt-get update
216+ if [ "${{ matrix.architecture }}" == "arm" ]; then
217+ sudo apt-get install -y gcc-arm-linux-gnueabi g++-arm-linux-gnueabi
218+ elif [ "${{ matrix.architecture }}" == "arm64" ]; then
219+ sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
220+ elif [ "${{ matrix.architecture }}" == "mips" ]; then
221+ sudo apt-get install -y gcc-mips-linux-gnu g++-mips-linux-gnu
222+ elif [ "${{ matrix.architecture }}" == "mipsel" ]; then
223+ sudo apt-get install -y gcc-mipsel-linux-gnu g++-mipsel-linux-gnu
224+ elif [ "${{ matrix.architecture }}" == "riscv64" ]; then
225+ sudo apt-get install -y gcc-riscv64-linux-gnu g++-riscv64-linux-gnu
226+ elif [ "${{ matrix.architecture }}" == "ppc" ]; then
227+ sudo apt-get install -y gcc-powerpc-linux-gnu g++-powerpc-linux-gnu
228+ elif [ "${{ matrix.architecture }}" == "ppc64le" ]; then
229+ sudo apt-get install -y gcc-powerpc64le-linux-gnu g++-powerpc64le-linux-gnu
230+ elif [ "${{ matrix.architecture }}" == "sparc64" ]; then
231+ sudo apt-get install -y gcc-sparc64-linux-gnu g++-sparc64-linux-gnu
232+ elif [ "${{ matrix.architecture }}" == "s390x" ]; then
233+ sudo apt-get install -y gcc-s390x-linux-gnu g++-s390x-linux-gnu
234+ fi
235+
236+ - name : Set Cross-Compilation Environment Variables
237+ run : |
238+ if [ "${{ matrix.architecture }}" == "arm" ]; then
239+ echo "CC=arm-linux-gnueabi-gcc" >> $GITHUB_ENV
240+ echo "CXX=arm-linux-gnueabi-g++" >> $GITHUB_ENV
241+ elif [ "${{ matrix.architecture }}" == "arm64" ]; then
242+ echo "CC=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
243+ echo "CXX=aarch64-linux-gnu-g++" >> $GITHUB_ENV
244+ elif [ "${{ matrix.architecture }}" == "mips" ]; then
245+ echo "CC=mips-linux-gnu-gcc" >> $GITHUB_ENV
246+ echo "CXX=mips-linux-gnu-g++" >> $GITHUB_ENV
247+ elif [ "${{ matrix.architecture }}" == "mipsel" ]; then
248+ echo "CC=mipsel-linux-gnu-gcc" >> $GITHUB_ENV
249+ echo "CXX=mipsel-linux-gnu-g++" >> $GITHUB_ENV
250+ elif [ "${{ matrix.architecture }}" == "riscv64" ]; then
251+ echo "CC=riscv64-linux-gnu-gcc" >> $GITHUB_ENV
252+ echo "CXX=riscv64-linux-gnu-g++" >> $GITHUB_ENV
253+ elif [ "${{ matrix.architecture }}" == "ppc" ]; then
254+ echo "CC=powerpc-linux-gnu-gcc" >> $GITHUB_ENV
255+ echo "CXX=powerpc-linux-gnu-g++" >> $GITHUB_ENV
256+ elif [ "${{ matrix.architecture }}" == "ppc64le" ]; then
257+ echo "CC=powerpc64le-linux-gnu-gcc" >> $GITHUB_ENV
258+ echo "CXX=powerpc64le-linux-gnu-g++" >> $GITHUB_ENV
259+ elif [ "${{ matrix.architecture }}" == "sparc64" ]; then
260+ echo "CC=sparc64-linux-gnu-gcc" >> $GITHUB_ENV
261+ echo "CXX=sparc64-linux-gnu-g++" >> $GITHUB_ENV
262+ elif [ "${{ matrix.architecture }}" == "s390x" ]; then
263+ echo "CC=s390x-linux-gnu-gcc" >> $GITHUB_ENV
264+ echo "CXX=s390x-linux-gnu-g++" >> $GITHUB_ENV
265+ fi
266+
267+ - name : Install CMake and Ninja
268+ run : |
269+ python -m pip install cmake ninja
270+
271+ - name : Configure CMake
272+ run : cmake -S . -B builddir -G "Ninja" -DWITH_TEST=ON
273+
274+ - name : Build
275+ run : cmake --build builddir --config Release
276+
277+ - name : Upload Build Log
278+ if : failure()
279+ uses : actions/upload-artifact@v4
280+ with :
281+ name : cross_${{ matrix.architecture }}_cmake_buildlog
282+ path : builddir/build.ninja
0 commit comments