-
Notifications
You must be signed in to change notification settings - Fork 29
297 lines (254 loc) · 10.5 KB
/
Copy pathlinux-build.yml
File metadata and controls
297 lines (254 loc) · 10.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
name: Linux Build
on:
push:
branches: [ main, develop, support_linux ]
pull_request:
branches: [ main, develop ]
jobs:
build-ubuntu:
name: "Build (${{ matrix.build_type }}-gcc)"
runs-on: ubuntu-latest
strategy:
matrix:
build_type: [Debug, Release]
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Install base dependencies
run: |
sudo apt-get update
sudo apt-get install -y cmake build-essential gcc
- name: Install GLFW (for Release builds only)
if: matrix.build_type == 'Release'
run: |
sudo apt-get install -y libglfw3-dev
echo "GLFW_INSTALLED=true" >> $GITHUB_ENV
- name: Setup compiler
run: |
echo "CC=gcc" >> $GITHUB_ENV
echo "CXX=g++" >> $GITHUB_ENV
- name: Configure CMake
run: |
echo "Configuring build ${{ matrix.build_type }} with gcc"
cmake -B build/${{ matrix.build_type }} \
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-DCCAP_BUILD_EXAMPLES=ON \
-DCCAP_BUILD_TESTS=ON
- name: Build
run: cmake --build build/${{ matrix.build_type }} --config ${{ matrix.build_type }} --parallel $(nproc)
- name: Verify GLFW examples build status
working-directory: build/${{ matrix.build_type }}
run: |
echo "Checking built examples:"
ls -la | grep -E "(glfw|example)" || echo "No GLFW examples found"
if [ "${{ matrix.build_type }}" = "Release" ]; then
echo "Release build - checking if GLFW examples were built with system GLFW:"
if [ -f "4-example_with_glfw" ]; then
echo "✓ GLFW example successfully built with system GLFW"
else
echo "✗ GLFW example not found - this might indicate a build issue"
exit 1
fi
else
echo "Debug build - checking if bundled GLFW was used:"
if [ -f "4-example_with_glfw" ]; then
echo "✓ GLFW example successfully built with bundled GLFW"
else
echo "ℹ GLFW example not built - using bundled GLFW or GLFW disabled"
fi
fi
- name: Run Unit Tests
if: matrix.build_type == 'Release'
run: |
cd scripts
./run_tests.sh --functional --exit-when-failed
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: ccap-linux-gcc-${{ matrix.build_type }}
path: |
build/${{ matrix.build_type }}/libccap.a
build/${{ matrix.build_type }}/0-print_camera
build/${{ matrix.build_type }}/1-minimal_example
build/${{ matrix.build_type }}/2-capture_grab
build/${{ matrix.build_type }}/3-capture_callback
build/${{ matrix.build_type }}/4-example_with_glfw
build/${{ matrix.build_type }}/*_results.xml
if-no-files-found: warn
build-ubuntu-clang:
name: "Build (${{ matrix.build_type }}-clang)"
runs-on: ubuntu-latest
# Run clang builds on push to main and on pull requests
if: github.event_name == 'pull_request' || (github.event_name == 'push' && github.ref == 'refs/heads/main')
strategy:
matrix:
build_type: [Debug, Release]
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y cmake build-essential clang libglfw3-dev
- name: Setup compiler
run: |
echo "CC=clang" >> $GITHUB_ENV
echo "CXX=clang++" >> $GITHUB_ENV
- name: Configure CMake
run: |
echo "Configuring build ${{ matrix.build_type }} with clang (with system GLFW)"
cmake -B build/${{ matrix.build_type }} \
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-DCCAP_BUILD_EXAMPLES=ON \
-DCCAP_BUILD_TESTS=ON
- name: Build
run: cmake --build build/${{ matrix.build_type }} --config ${{ matrix.build_type }} --parallel $(nproc)
- name: Verify build outputs
working-directory: build/${{ matrix.build_type }}
run: |
echo "Checking built examples:"
ls -la | grep -E "(glfw|example)" || echo "No examples found"
echo "✓ Build completed successfully"
- name: Run Unit Tests
if: matrix.build_type == 'Release'
run: |
cd scripts
./run_tests.sh --functional --exit-when-failed
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: ccap-linux-clang-${{ matrix.build_type }}
path: |
build/${{ matrix.build_type }}/libccap.a
build/${{ matrix.build_type }}/0-print_camera
build/${{ matrix.build_type }}/1-minimal_example
build/${{ matrix.build_type }}/2-capture_grab
build/${{ matrix.build_type }}/3-capture_callback
build/${{ matrix.build_type }}/4-example_with_glfw
build/${{ matrix.build_type }}/*_results.xml
if-no-files-found: warn
build-ubuntu-arm64:
name: "Build ARM64 (${{ matrix.build_type }}-gcc)"
runs-on: ubuntu-latest
strategy:
matrix:
build_type: [Debug, Release]
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Install cross-compilation toolchain
run: |
sudo apt-get update
sudo apt-get install -y cmake build-essential gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
echo "Cross-compilation toolchain installed"
- name: Configure CMake for ARM64
run: |
echo "Configuring build ${{ matrix.build_type }} for ARM64 (cross-compilation)"
cmake -B build/arm64/${{ matrix.build_type }} \
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc \
-DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++ \
-DCMAKE_SYSTEM_NAME=Linux \
-DCMAKE_SYSTEM_PROCESSOR=aarch64 \
-DCMAKE_CROSSCOMPILING=ON \
-DCCAP_BUILD_EXAMPLES=ON \
-DCCAP_BUILD_TESTS=ON
- name: Build ARM64
run: cmake --build build/arm64/${{ matrix.build_type }} --config ${{ matrix.build_type }} --parallel $(nproc)
- name: Build ARM64 test target (Release only)
if: matrix.build_type == 'Release'
run: |
cmake --build build/arm64/${{ matrix.build_type }} --config ${{ matrix.build_type }} --target ccap_convert_test --parallel $(nproc)
- name: Install QEMU for ARM64 test emulation (PRs and main push, Release only)
if: (github.event_name == 'pull_request' || (github.event_name == 'push' && github.ref == 'refs/heads/main')) && matrix.build_type == 'Release'
run: |
sudo apt-get update
sudo apt-get install -y qemu-user qemu-user-static
qemu-aarch64 --version
- name: Run ARM64 Unit Tests (PRs and main push, Release only)
if: (github.event_name == 'pull_request' || (github.event_name == 'push' && github.ref == 'refs/heads/main')) && matrix.build_type == 'Release'
run: |
TEST_BIN="build/arm64/${{ matrix.build_type }}/tests/ccap_convert_test"
if [ ! -x "$TEST_BIN" ]; then
echo "Test binary not found: $TEST_BIN" >&2
ls -la "build/arm64/${{ matrix.build_type }}" || true
exit 1
fi
echo "Verifying test binary architecture:"
file "$TEST_BIN" || true
echo "Running ARM64 unit tests via QEMU..."
# Use the ARM64 sysroot provided by the cross toolchain for dynamic libs
qemu-aarch64 -L /usr/aarch64-linux-gnu "$TEST_BIN" \
--gtest_fail_fast \
--gtest_output=xml:build/arm64/${{ matrix.build_type }}/arm64_results.xml
echo "✓ ARM64 unit tests finished"
- name: Verify build outputs
working-directory: build/arm64/${{ matrix.build_type }}
run: |
echo "Checking built ARM64 binaries:"
ls -la | grep -E "(ccap|example)" || echo "No examples found"
echo "Verifying ARM64 architecture:"
file libccap.a | grep -q "aarch64" && echo "✓ Library is ARM64" || echo "⚠ Library architecture verification failed"
if [ -f "0-print_camera" ]; then
file 0-print_camera | grep -q "aarch64" && echo "✓ Binary is ARM64" || echo "⚠ Binary architecture verification failed"
fi
echo "✓ ARM64 cross-compilation completed successfully"
- name: Upload ARM64 artifacts
uses: actions/upload-artifact@v4
with:
name: ccap-linux-arm64-gcc-${{ matrix.build_type }}
path: |
build/arm64/${{ matrix.build_type }}/libccap.a
build/arm64/${{ matrix.build_type }}/0-print_camera
build/arm64/${{ matrix.build_type }}/1-minimal_example
build/arm64/${{ matrix.build_type }}/2-capture_grab
build/arm64/${{ matrix.build_type }}/3-capture_callback
build/arm64/${{ matrix.build_type }}/4-example_with_glfw
build/arm64/${{ matrix.build_type }}/*_results.xml
if-no-files-found: warn
build-fedora:
name: "Build Fedora (${{ matrix.build_type }})"
runs-on: ubuntu-latest
container: fedora:latest
strategy:
matrix:
build_type: [Debug, Release]
steps:
- name: Install Git first
run: |
dnf update -y
dnf install -y git
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Install dependencies
run: |
dnf install -y cmake gcc-c++ make
- name: Configure CMake
run: |
cmake -B build/${{ matrix.build_type }} \
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-DCCAP_BUILD_EXAMPLES=ON \
-DCCAP_BUILD_TESTS=ON
- name: Build
run: cmake --build build/${{ matrix.build_type }} --config ${{ matrix.build_type }} --parallel $(nproc)
- name: Run Unit Tests
if: matrix.build_type == 'Release'
run: |
cd scripts
./run_tests.sh --functional --exit-when-failed
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: ccap-fedora-${{ matrix.build_type }}
path: |
build/${{ matrix.build_type }}/libccap.a
build/${{ matrix.build_type }}/0-print_camera
build/${{ matrix.build_type }}/1-minimal_example
build/${{ matrix.build_type }}/2-capture_grab
build/${{ matrix.build_type }}/3-capture_callback
build/${{ matrix.build_type }}/*_results.xml
if-no-files-found: warn