-
Notifications
You must be signed in to change notification settings - Fork 29
129 lines (117 loc) · 5.04 KB
/
Copy pathmacos-build.yml
File metadata and controls
129 lines (117 loc) · 5.04 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
name: macOS Build
on:
push:
branches: [ main, ci_test ]
pull_request:
branches: [ main, ci_test ]
workflow_dispatch:
jobs:
build-mac:
name: macOS Build (${{ matrix.config }}-${{ matrix.library_type }})
runs-on: macos-latest
strategy:
matrix:
config: [Debug, Release]
library_type: [static, shared]
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Configure CMake
run: |
if [ "${{ matrix.library_type }}" = "shared" ]; then
SHARED_FLAG="-DCCAP_BUILD_SHARED=ON"
echo "Configuring macOS build ${{ matrix.config }} - SHARED LIBRARY"
else
SHARED_FLAG=""
echo "Configuring macOS build ${{ matrix.config }} - STATIC LIBRARY"
fi
mkdir -p build/${{ matrix.config }}-${{ matrix.library_type }}
cd build/${{ matrix.config }}-${{ matrix.library_type }}
cmake ../.. -DCMAKE_BUILD_TYPE=${{ matrix.config }} -DCCAP_BUILD_TESTS=ON $SHARED_FLAG
- name: Build
run: |
cd build/${{ matrix.config }}-${{ matrix.library_type }}
cmake --build . --config ${{ matrix.config }} --parallel
- name: Verify library type
working-directory: build/${{ matrix.config }}-${{ matrix.library_type }}
run: |
echo "Checking built libraries:"
ls -la | grep -E "ccap" || echo "No ccap libraries found"
# Verify library type
if [ "${{ matrix.library_type }}" = "shared" ]; then
if [ -f "libccap.dylib" ]; then
echo "✓ macOS shared library libccap.dylib successfully built"
echo "Exported symbols check:"
nm -gU libccap.dylib | grep "ccap_provider_create" && echo "✓ C symbols exported" || echo "✗ C symbols not found"
nm -gU libccap.dylib | grep "_ZN4ccap" | head -2 && echo "✓ C++ symbols exported" || echo "✗ C++ symbols not found"
else
echo "✗ macOS shared library not found"
exit 1
fi
else
if [ -f "libccap.a" ]; then
echo "✓ macOS static library libccap.a successfully built"
else
echo "✗ macOS static library not found"
exit 1
fi
fi
- name: Test shared library linking (macOS)
if: matrix.library_type == 'shared'
working-directory: build/${{ matrix.config }}-${{ matrix.library_type }}
run: |
echo "Testing macOS 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
# Compile and run with shared library
clang++ -I../../include test_shared.cpp -L. -lccap -o test_shared
DYLD_LIBRARY_PATH=. ./test_shared
echo "✓ macOS shared library linking test passed"
- name: Run Unit Tests
run: |
# Create symbolic links to make test script work with new build directory structure
mkdir -p build
if [ ! -L "build/${{ matrix.config }}" ]; then
ln -sf "${{ matrix.config }}-${{ matrix.library_type }}" "build/${{ matrix.config }}"
fi
cd scripts
if [ "${{ matrix.config }}" == "Debug" ]; then
# Set library path for shared library tests
if [ "${{ matrix.library_type }}" = "shared" ]; then
export DYLD_LIBRARY_PATH="$PWD/../build/${{ matrix.config }}-${{ matrix.library_type }}:$DYLD_LIBRARY_PATH"
fi
# Run tests with AddressSanitizer enabled by default (improves memory error detection)
./run_tests.sh --functional --skip-build
else
# Set library path for shared library tests
if [ "${{ matrix.library_type }}" = "shared" ]; then
export DYLD_LIBRARY_PATH="$PWD/../build/${{ matrix.config }}-${{ matrix.library_type }}:$DYLD_LIBRARY_PATH"
fi
./run_tests.sh --performance --skip-build
fi
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: ccap-macOS-${{ matrix.config }}-${{ matrix.library_type }}
path: |
build/${{ matrix.config }}-${{ matrix.library_type }}/libccap.*
build/${{ matrix.config }}-${{ matrix.library_type }}/0-print_camera
build/${{ matrix.config }}-${{ matrix.library_type }}/1-minimal_example
build/${{ matrix.config }}-${{ matrix.library_type }}/2-capture_grab
build/${{ matrix.config }}-${{ matrix.library_type }}/3-capture_callback
build/${{ matrix.config }}-${{ matrix.library_type }}/*_results.xml
if-no-files-found: error