-
Notifications
You must be signed in to change notification settings - Fork 29
711 lines (619 loc) · 28.4 KB
/
Copy pathwindows-build.yml
File metadata and controls
711 lines (619 loc) · 28.4 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
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
name: Windows Build
# This workflow builds the project on Windows with multiple compilers:
# - build-vs2022: Uses Visual Studio 2022 (stable)
# - build-vs2026: Uses Visual Studio 2026 (when available on GitHub runners, skips gracefully if not)
# - build-mingw: Uses MinGW-w64 (latest version)
# All jobs test Debug/Release builds with static/shared library configurations.
on:
push:
branches: [ main, ci_test ]
pull_request:
branches: [ main, ci_test ]
workflow_dispatch:
permissions:
contents: read
jobs:
build-vs2022:
name: Windows Build VS2022 (${{ matrix.config }}-${{ matrix.library_type }})
# Pin to the windows-2022 image: windows-latest now resolves to an image that
# ships Visual Studio 2026 (v18) only, where the "Visual Studio 17 2022"
# generator cannot find a VS instance. VS 2026 is covered by the build-vs2026 job.
runs-on: windows-2022
strategy:
matrix:
config: [Debug, Release]
library_type: [static, shared]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Visual Studio environment
uses: microsoft/setup-msbuild@v1.1
# Cache CMake build directory for Windows
- name: Setup CMake build cache
uses: actions/cache@v4
with:
path: |
build/${{ matrix.config }}-${{ matrix.library_type }}/CMakeFiles
build/${{ matrix.config }}-${{ matrix.library_type }}/CMakeCache.txt
build/${{ matrix.config }}-${{ matrix.library_type }}/**/*.obj
key: ${{ runner.os }}-msvc-${{ matrix.config }}-${{ matrix.library_type }}-${{ hashFiles('CMakeLists.txt', 'src/**', 'include/**') }}
restore-keys: |
${{ runner.os }}-msvc-${{ matrix.config }}-${{ matrix.library_type }}-
${{ runner.os }}-msvc-${{ matrix.config }}-
- name: Configure CMake
run: |
$SHARED_FLAG = ""
if ("${{ matrix.library_type }}" -eq "shared") {
$SHARED_FLAG = "-DCCAP_BUILD_SHARED=ON"
Write-Host "Configuring Windows build ${{ matrix.config }} - SHARED LIBRARY (DLL)"
} else {
Write-Host "Configuring Windows build ${{ matrix.config }} - STATIC LIBRARY"
}
New-Item -ItemType Directory -Force -Path "build/${{ matrix.config }}-${{ matrix.library_type }}"
cd "build/${{ matrix.config }}-${{ matrix.library_type }}"
cmake ../.. -G "Visual Studio 17 2022" -A x64 -DCCAP_BUILD_TESTS=ON -DCCAP_BUILD_CLI=ON $SHARED_FLAG
- name: Build
run: |
cd "build/${{ matrix.config }}-${{ matrix.library_type }}"
cmake --build . --config ${{ matrix.config }} --parallel
- name: Verify library type
shell: bash
working-directory: build/${{ matrix.config }}-${{ matrix.library_type }}/${{ matrix.config }}
run: |
echo "Checking built libraries:"
ls -la | grep -E "ccap" || echo "No ccap libraries found"
# Verify library type
# Debug versions have 'd' suffix, Release versions don't
if [ "${{ matrix.config }}" = "Debug" ]; then
LIB_BASENAME="ccapd"
DLL_NAME="ccapd.dll"
else
LIB_BASENAME="ccap"
DLL_NAME="ccap.dll"
fi
if [ "${{ matrix.library_type }}" = "shared" ]; then
if [ -f "$DLL_NAME" ]; then
echo "✓ Windows shared library $DLL_NAME successfully built"
# Check if import library exists
if [ -f "${LIB_BASENAME}.lib" ]; then
echo "✓ Windows import library ${LIB_BASENAME}.lib also created"
fi
else
echo "✗ Windows shared library $DLL_NAME not found"
exit 1
fi
else
if [ -f "${LIB_BASENAME}.lib" ]; then
echo "✓ Windows static library ${LIB_BASENAME}.lib successfully built"
else
echo "✗ Windows static library ${LIB_BASENAME}.lib not found"
exit 1
fi
fi
- name: Test shared library linking (Windows)
if: matrix.library_type == 'shared'
shell: bash
working-directory: build/${{ matrix.config }}-${{ matrix.library_type }}/${{ matrix.config }}
run: |
echo "Testing Windows shared library linking..."
# Create a simple test program
cat > test_shared.cpp << 'EOF'
#include "ccap_c.h"
#include <stdio.h>
int main() {
const char* version = ccap_get_version();
printf("Library version: %s\n", version ? version : "unknown");
CcapProvider* provider = ccap_provider_create();
if (provider) {
printf("Provider created successfully\n");
ccap_provider_destroy(provider);
return 0;
}
return 1;
}
EOF
# Find Visual Studio compiler
VCVARS_PATH=$(find "/c/Program Files/Microsoft Visual Studio" -name "vcvars64.bat" 2>/dev/null | head -n1)
if [ -z "$VCVARS_PATH" ]; then
VCVARS_PATH=$(find "/c/Program Files (x86)/Microsoft Visual Studio" -name "vcvars64.bat" 2>/dev/null | head -n1)
fi
if [ -n "$VCVARS_PATH" ]; then
echo "Using Visual Studio environment from: $VCVARS_PATH"
# Convert path for cmd
VCVARS_WIN_PATH=$(echo "$VCVARS_PATH" | sed 's|/c/|C:/|g' | sed 's|/|\\|g')
# Determine library names based on config
if [ "${{ matrix.config }}" = "Debug" ]; then
LIB_NAME="ccapd.lib"
DLL_NAME="ccapd.dll"
else
LIB_NAME="ccap.lib"
DLL_NAME="ccap.dll"
fi
# Create a temporary batch file to avoid quote escaping issues
cat > compile_test.bat << EOF
@echo off
call "$VCVARS_WIN_PATH"
set "INCLUDE_DIR=%GITHUB_WORKSPACE%\\include"
if not exist "%INCLUDE_DIR%" (
echo Include directory not found: %INCLUDE_DIR%
exit /b 1
)
cl /I"%INCLUDE_DIR%" test_shared.cpp $LIB_NAME /Fe:test_shared.exe
EOF
# Execute the batch file
cmd //c compile_test.bat
# Ensure DLL is available beside the test executable
if [ ! -f "./$DLL_NAME" ]; then
DLL_PATH=$(find .. -name "$DLL_NAME" -print -quit)
if [ -z "$DLL_PATH" ]; then
echo "✗ Windows shared library $DLL_NAME not found for runtime"
exit 1
fi
cp "$DLL_PATH" .
fi
./test_shared.exe
echo "✓ Windows shared library linking test passed"
else
echo "⚠ Visual Studio compiler not found, skipping link test"
fi
- name: Run Unit Tests
shell: bash
run: |
# Create symbolic links to make test script work with new build directory structure
mkdir -p build/tests
# Create symbolic link for the config directory
if [ ! -L "build/${{ matrix.config }}" ]; then
ln -sf "${{ matrix.config }}-${{ matrix.library_type }}" "build/${{ matrix.config }}"
fi
# Create symbolic link for the tests directory to match expected path structure
if [ ! -L "build/tests/${{ matrix.config }}" ]; then
ln -sf "../${{ matrix.config }}-${{ matrix.library_type }}/tests/${{ matrix.config }}" "build/tests/${{ matrix.config }}"
fi
cd scripts
if [ "${{ matrix.config }}" == "Debug" ]; then
# Set library path for shared library tests
if [ "${{ matrix.library_type }}" = "shared" ]; then
export PATH="$PWD/../build/${{ matrix.config }}-${{ matrix.library_type }}/${{ matrix.config }}:$PATH"
fi
./run_tests.sh --functional --skip-build
else
# Set library path for shared library tests
if [ "${{ matrix.library_type }}" = "shared" ]; then
export PATH="$PWD/../build/${{ matrix.config }}-${{ matrix.library_type }}/${{ matrix.config }}:$PATH"
fi
./run_tests.sh --performance --skip-build
# Run video file playback tests (Release only)
./run_tests.sh --video --skip-build
# Run video writer tests (Release only, macOS/Windows)
./run_tests.sh --writer --skip-build
fi
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: ccap-windows-vs2022-${{ matrix.config }}-${{ matrix.library_type }}
path: |
build/${{ matrix.config }}-${{ matrix.library_type }}/${{ matrix.config }}/ccap*.*
build/${{ matrix.config }}-${{ matrix.library_type }}/${{ matrix.config }}/0-print_camera.exe
build/${{ matrix.config }}-${{ matrix.library_type }}/${{ matrix.config }}/1-minimal_example.exe
build/${{ matrix.config }}-${{ matrix.library_type }}/${{ matrix.config }}/2-capture_grab.exe
build/${{ matrix.config }}-${{ matrix.library_type }}/${{ matrix.config }}/3-capture_callback.exe
build/${{ matrix.config }}-${{ matrix.library_type }}/*_results.xml
if-no-files-found: error
build-vs2026:
name: Windows Build VS2026 (${{ matrix.config }}-${{ matrix.library_type }})
runs-on: windows-latest
strategy:
matrix:
config: [Debug, Release]
library_type: [static, shared]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Check for Visual Studio 2026
id: check-vs2026
shell: pwsh
run: |
Write-Host "Checking for Visual Studio 2026 on this runner..."
# Use vswhere to check for VS2026 installation
$vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
# Check for VS2026 installation (version 18.x)
$vs2026 = & $vswhere -version "[18.0,19.0)" -property installationPath 2>$null
# Also check if v144 toolset exists in any VS installation
$vsInstalls = & $vswhere -all -property installationPath 2>$null
$v144Found = $false
foreach ($install in $vsInstalls) {
$v144Path = Join-Path $install "MSBuild\Microsoft\VC\v144"
if (Test-Path $v144Path) {
$v144Found = $true
Write-Host "✓ v144 toolset (VS2026) found at: $v144Path"
break
}
}
if ($vs2026) {
echo "VS_2026_AVAILABLE=true" >> $env:GITHUB_OUTPUT
Write-Host "✓ Visual Studio 2026 is installed at: $vs2026"
} elseif ($v144Found) {
echo "VS_2026_AVAILABLE=true" >> $env:GITHUB_OUTPUT
Write-Host "✓ Visual Studio 2026 v144 toolset is available"
} else {
echo "VS_2026_AVAILABLE=false" >> $env:GITHUB_OUTPUT
Write-Host "ℹ Visual Studio 2026 (v144 toolset) is not available on this GitHub runner yet."
Write-Host ""
Write-Host "=== Available Visual Studio Installations (via vswhere) ==="
& $vswhere -all -format text
Write-Host ""
Write-Host "⏭ Skipping VS2026 build - this job will complete successfully without running the build."
Write-Host "Once GitHub adds VS2026 to their runners, this job will automatically start building."
}
- name: Setup latest CMake
if: steps.check-vs2026.outputs.VS_2026_AVAILABLE == 'true'
# Use @latest to ensure CMake 3.31+ is available, which is required for VS 2026 support
uses: lukka/get-cmake@latest
# Cache CMake build directory for VS2026
- name: Setup CMake build cache
if: steps.check-vs2026.outputs.VS_2026_AVAILABLE == 'true'
uses: actions/cache@v4
with:
path: |
build/${{ matrix.config }}-${{ matrix.library_type }}/CMakeFiles
build/${{ matrix.config }}-${{ matrix.library_type }}/CMakeCache.txt
build/${{ matrix.config }}-${{ matrix.library_type }}/**/*.obj
key: ${{ runner.os }}-vs2026-${{ matrix.config }}-${{ matrix.library_type }}-${{ hashFiles('CMakeLists.txt', 'src/**', 'include/**') }}
restore-keys: |
${{ runner.os }}-vs2026-${{ matrix.config }}-${{ matrix.library_type }}-
${{ runner.os }}-vs2026-${{ matrix.config }}-
- name: Configure CMake with VS2026
if: steps.check-vs2026.outputs.VS_2026_AVAILABLE == 'true'
run: |
$SHARED_FLAG = ""
if ("${{ matrix.library_type }}" -eq "shared") {
$SHARED_FLAG = "-DCCAP_BUILD_SHARED=ON"
Write-Host "Configuring Windows build ${{ matrix.config }} with VS2026 - SHARED LIBRARY (DLL)"
} else {
Write-Host "Configuring Windows build ${{ matrix.config }} with VS2026 - STATIC LIBRARY"
}
# Check CMake version
cmake --version
mkdir -p "build/${{ matrix.config }}-${{ matrix.library_type }}"
cd "build/${{ matrix.config }}-${{ matrix.library_type }}"
# Use the Visual Studio 18 2026 generator with its default toolset.
# Forcing -T v144 makes MSBuild fail to resolve VCTargetsPath on the
# windows-2025-vs2026 image, so let CMake pick the toolset that ships with VS 2026.
Write-Host "Attempting to use Visual Studio 18 2026 generator..."
cmake ../.. -G "Visual Studio 18 2026" -A x64 -DCCAP_BUILD_TESTS=ON $SHARED_FLAG
if ($LASTEXITCODE -ne 0) {
Write-Host "Visual Studio 18 2026 generator not available, trying the default generator..."
cmake ../.. -A x64 -DCCAP_BUILD_TESTS=ON $SHARED_FLAG
}
- name: Build
if: steps.check-vs2026.outputs.VS_2026_AVAILABLE == 'true'
run: |
cd "build/${{ matrix.config }}-${{ matrix.library_type }}"
cmake --build . --config ${{ matrix.config }} --parallel
- name: Verify library type
if: steps.check-vs2026.outputs.VS_2026_AVAILABLE == 'true'
shell: bash
working-directory: build/${{ matrix.config }}-${{ matrix.library_type }}/${{ matrix.config }}
run: |
echo "Checking built libraries:"
ls -la | grep -E "ccap" || echo "No ccap libraries found"
# Verify library type
# Debug versions have 'd' suffix, Release versions don't
if [ "${{ matrix.config }}" = "Debug" ]; then
LIB_BASENAME="ccapd"
DLL_NAME="ccapd.dll"
else
LIB_BASENAME="ccap"
DLL_NAME="ccap.dll"
fi
if [ "${{ matrix.library_type }}" = "shared" ]; then
if [ -f "$DLL_NAME" ]; then
echo "✓ Windows shared library $DLL_NAME successfully built with VS2026"
# Check if import library exists
if [ -f "${LIB_BASENAME}.lib" ]; then
echo "✓ Windows import library ${LIB_BASENAME}.lib also created"
fi
else
echo "✗ Windows shared library $DLL_NAME not found"
exit 1
fi
else
if [ -f "${LIB_BASENAME}.lib" ]; then
echo "✓ Windows static library ${LIB_BASENAME}.lib successfully built with VS2026"
else
echo "✗ Windows static library ${LIB_BASENAME}.lib not found"
exit 1
fi
fi
- name: Test shared library linking (Windows VS2026)
if: steps.check-vs2026.outputs.VS_2026_AVAILABLE == 'true' && matrix.library_type == 'shared'
shell: bash
working-directory: build/${{ matrix.config }}-${{ matrix.library_type }}/${{ matrix.config }}
run: |
echo "Testing Windows shared library linking with VS2026..."
# Create a simple test program
cat > test_shared.cpp << 'EOF'
#include "ccap_c.h"
#include <stdio.h>
int main() {
const char* version = ccap_get_version();
printf("Library version: %s\n", version ? version : "unknown");
CcapProvider* provider = ccap_provider_create();
if (provider) {
printf("Provider created successfully\n");
ccap_provider_destroy(provider);
return 0;
}
return 1;
}
EOF
# Find Visual Studio 2026 compiler
VCVARS_PATH=$(find "/c/Program Files/Microsoft Visual Studio/2026" -name "vcvars64.bat" 2>/dev/null | head -n1)
if [ -n "$VCVARS_PATH" ]; then
echo "Using Visual Studio 2026 environment from: $VCVARS_PATH"
# Convert path for cmd
VCVARS_WIN_PATH=$(echo "$VCVARS_PATH" | sed 's|/c/|C:/|g' | sed 's|/|\\|g')
# Determine library names based on config
if [ "${{ matrix.config }}" = "Debug" ]; then
LIB_NAME="ccapd.lib"
DLL_NAME="ccapd.dll"
else
LIB_NAME="ccap.lib"
DLL_NAME="ccap.dll"
fi
# Create a temporary batch file to avoid quote escaping issues
cat > compile_test.bat << EOF
@echo off
call "$VCVARS_WIN_PATH"
set "INCLUDE_DIR=%GITHUB_WORKSPACE%\\include"
if not exist "%INCLUDE_DIR%" (
echo Include directory not found: %INCLUDE_DIR%
exit /b 1
)
cl /I"%INCLUDE_DIR%" test_shared.cpp $LIB_NAME /Fe:test_shared.exe
EOF
# Execute the batch file
cmd //c compile_test.bat
# Ensure DLL is available beside the test executable
if [ ! -f "./$DLL_NAME" ]; then
DLL_PATH=$(find .. -name "$DLL_NAME" -print -quit)
if [ -z "$DLL_PATH" ]; then
echo "✗ Windows shared library $DLL_NAME not found for runtime"
exit 1
fi
cp "$DLL_PATH" .
fi
./test_shared.exe
echo "✓ Windows shared library linking test with VS2026 passed"
else
echo "⚠ Visual Studio 2026 compiler not found, skipping link test"
fi
- name: Run Unit Tests
if: steps.check-vs2026.outputs.VS_2026_AVAILABLE == 'true'
shell: bash
run: |
# Create symbolic links to make test script work with new build directory structure
mkdir -p build/tests
# Create symbolic link for the config directory
if [ ! -L "build/${{ matrix.config }}" ]; then
ln -sf "${{ matrix.config }}-${{ matrix.library_type }}" "build/${{ matrix.config }}"
fi
# Create symbolic link for the tests directory to match expected path structure
if [ ! -L "build/tests/${{ matrix.config }}" ]; then
ln -sf "../${{ matrix.config }}-${{ matrix.library_type }}/tests/${{ matrix.config }}" "build/tests/${{ matrix.config }}"
fi
cd scripts
if [ "${{ matrix.config }}" = "Debug" ]; then
# Set library path for shared library tests
if [ "${{ matrix.library_type }}" = "shared" ]; then
export PATH="$PWD/../build/${{ matrix.config }}-${{ matrix.library_type }}/${{ matrix.config }}:$PATH"
fi
./run_tests.sh --functional --skip-build
else
# Set library path for shared library tests
if [ "${{ matrix.library_type }}" = "shared" ]; then
export PATH="$PWD/../build/${{ matrix.config }}-${{ matrix.library_type }}/${{ matrix.config }}:$PATH"
fi
./run_tests.sh --performance --skip-build
# Run video file playback tests (Release only)
./run_tests.sh --video --skip-build
# Run video writer tests (Release only, macOS/Windows)
./run_tests.sh --writer --skip-build
fi
- name: Upload artifacts
if: steps.check-vs2026.outputs.VS_2026_AVAILABLE == 'true'
uses: actions/upload-artifact@v4
with:
name: ccap-windows-vs2026-${{ matrix.config }}-${{ matrix.library_type }}
path: |
build/${{ matrix.config }}-${{ matrix.library_type }}/${{ matrix.config }}/ccap*.*
build/${{ matrix.config }}-${{ matrix.library_type }}/${{ matrix.config }}/0-print_camera.exe
build/${{ matrix.config }}-${{ matrix.library_type }}/${{ matrix.config }}/1-minimal_example.exe
build/${{ matrix.config }}-${{ matrix.library_type }}/${{ matrix.config }}/2-capture_grab.exe
build/${{ matrix.config }}-${{ matrix.library_type }}/${{ matrix.config }}/3-capture_callback.exe
build/${{ matrix.config }}-${{ matrix.library_type }}/*_results.xml
# Use 'warn' instead of 'error' since VS 2026 build is optional (may not be available on all runners)
if-no-files-found: warn
build-mingw:
name: Windows Build MinGW (${{ matrix.config }}-${{ matrix.library_type }})
runs-on: windows-latest
strategy:
matrix:
config: [Debug, Release]
library_type: [static, shared]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup MinGW-w64
uses: msys2/setup-msys2@v2
with:
msystem: MINGW64
update: true
install: >-
mingw-w64-x86_64-toolchain
mingw-w64-x86_64-cmake
mingw-w64-x86_64-ninja
make
# Cache CMake build directory for MinGW
- name: Setup CMake build cache
uses: actions/cache@v4
with:
path: |
build/${{ matrix.config }}-${{ matrix.library_type }}/CMakeFiles
build/${{ matrix.config }}-${{ matrix.library_type }}/CMakeCache.txt
build/${{ matrix.config }}-${{ matrix.library_type }}/**/*.o
key: ${{ runner.os }}-mingw-${{ matrix.config }}-${{ matrix.library_type }}-${{ hashFiles('CMakeLists.txt', 'src/**', 'include/**') }}
restore-keys: |
${{ runner.os }}-mingw-${{ matrix.config }}-${{ matrix.library_type }}-
${{ runner.os }}-mingw-${{ matrix.config }}-
- name: Configure CMake with MinGW
shell: msys2 {0}
run: |
SHARED_FLAG=""
if [ "${{ matrix.library_type }}" = "shared" ]; then
SHARED_FLAG="-DCCAP_BUILD_SHARED=ON"
echo "Configuring Windows build ${{ matrix.config }} with MinGW - SHARED LIBRARY (DLL)"
else
echo "Configuring Windows build ${{ matrix.config }} with MinGW - STATIC LIBRARY"
fi
# Check compiler version
gcc --version
cmake --version
mkdir -p "build/${{ matrix.config }}-${{ matrix.library_type }}"
cd "build/${{ matrix.config }}-${{ matrix.library_type }}"
cmake ../.. -G "Ninja" -DCMAKE_BUILD_TYPE=${{ matrix.config }} -DCCAP_BUILD_TESTS=ON $SHARED_FLAG
- name: Build
shell: msys2 {0}
run: |
cd "build/${{ matrix.config }}-${{ matrix.library_type }}"
cmake --build . --parallel
- name: Verify library type
shell: msys2 {0}
working-directory: build/${{ matrix.config }}-${{ matrix.library_type }}
run: |
echo "Checking built libraries:"
ls -la | grep -E "ccap" || echo "No ccap libraries found"
if [ "${{ matrix.library_type }}" = "shared" ]; then
# MinGW shared libraries use .dll extension
if [ -f "libccap.dll" ]; then
echo "✓ Windows shared library libccap.dll successfully built with MinGW"
else
echo "✗ Windows shared library libccap.dll not found"
exit 1
fi
else
# MinGW static libraries use .a extension
if [ -f "libccap.a" ]; then
echo "✓ Windows static library libccap.a successfully built with MinGW"
else
echo "✗ Windows static library libccap.a not found"
exit 1
fi
fi
- name: Test shared library linking (Windows MinGW)
if: matrix.library_type == 'shared'
shell: msys2 {0}
working-directory: build/${{ matrix.config }}-${{ matrix.library_type }}
run: |
echo "Testing Windows shared library linking with MinGW..."
# Create a simple test program
cat > test_shared.cpp << 'EOF'
#include "ccap_c.h"
#include <stdio.h>
int main() {
const char* version = ccap_get_version();
printf("Library version: %s\n", version ? version : "unknown");
CcapProvider* provider = ccap_provider_create();
if (provider) {
printf("Provider created successfully\n");
ccap_provider_destroy(provider);
return 0;
}
return 1;
}
EOF
# Compile and run with shared library
g++ -I../../include test_shared.cpp -L. -lccap -o test_shared.exe
./test_shared.exe
echo "✓ Windows shared library linking test with MinGW passed"
- name: Run Unit Tests
shell: msys2 {0}
run: |
# Create symbolic links to make test script work with new build directory structure
mkdir -p build/tests
# Create symbolic link for the config directory
if [ ! -L "build/${{ matrix.config }}" ]; then
ln -sf "${{ matrix.config }}-${{ matrix.library_type }}" "build/${{ matrix.config }}"
fi
# Create symbolic link for the tests directory to match expected path structure
if [ ! -L "build/tests/${{ matrix.config }}" ]; then
ln -sf "../${{ matrix.config }}-${{ matrix.library_type }}/tests" "build/tests/${{ matrix.config }}"
fi
cd scripts
# Set library path for shared library tests
if [ "${{ matrix.library_type }}" = "shared" ]; then
export PATH="$PWD/../build/${{ matrix.config }}-${{ matrix.library_type }}:$PATH"
fi
# Run appropriate tests based on config
if [ "${{ matrix.config }}" = "Debug" ]; then
./run_tests.sh --functional --skip-build
else
./run_tests.sh --performance --skip-build
# Run video file playback tests (Release only)
./run_tests.sh --video --skip-build
# Run video writer tests (Release only, macOS/Windows)
./run_tests.sh --writer --skip-build
fi
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: ccap-windows-mingw-${{ matrix.config }}-${{ matrix.library_type }}
path: |
build/${{ matrix.config }}-${{ matrix.library_type }}/libccap.*
build/${{ matrix.config }}-${{ matrix.library_type }}/0-print_camera.exe
build/${{ matrix.config }}-${{ matrix.library_type }}/1-minimal_example.exe
build/${{ matrix.config }}-${{ matrix.library_type }}/2-capture_grab.exe
build/${{ matrix.config }}-${{ matrix.library_type }}/3-capture_callback.exe
build/${{ matrix.config }}-${{ matrix.library_type }}/*_results.xml
if-no-files-found: warn
# Test building with file playback disabled (VS2022 Release only)
build-vs2022-no-file-playback:
name: Windows VS2022 Release - No File Playback
# See build-vs2022: pin to windows-2022 for the Visual Studio 2022 toolchain.
runs-on: windows-2022
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Visual Studio environment
uses: microsoft/setup-msbuild@v1.1
- name: Configure CMake (File Playback Disabled)
run: |
Write-Host "Configuring Windows Release build with CCAP_ENABLE_FILE_PLAYBACK=OFF"
New-Item -ItemType Directory -Force -Path "build/Release-no-file-playback"
cd "build/Release-no-file-playback"
cmake ../.. -G "Visual Studio 17 2022" -A x64 -DCCAP_BUILD_TESTS=ON -DCCAP_ENABLE_FILE_PLAYBACK=OFF
- name: Build
run: |
cd "build/Release-no-file-playback"
cmake --build . --config Release --parallel
- name: Verify build
shell: bash
working-directory: build/Release-no-file-playback/Release
run: |
echo "Verifying build with file playback disabled:"
ls -la | grep -E "ccap" || echo "No ccap libraries found"
# Verify library exists
if [ -f "ccap.lib" ]; then
echo "✓ Static library ccap.lib successfully built"
else
echo "✗ Static library ccap.lib not found"
exit 1
fi
# Verify example programs are built
if [ -f "0-print_camera.exe" ]; then
echo "✓ Example programs built successfully"
else
echo "✗ Example programs not found"
exit 1
fi
echo "✓ Build verification passed - file playback disabled build works correctly"