-
Notifications
You must be signed in to change notification settings - Fork 80
246 lines (216 loc) · 9.01 KB
/
cppcmake.yml
File metadata and controls
246 lines (216 loc) · 9.01 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
name: C/C++ CI
on:
push:
branches:
- main
- dev
tags: ['*']
paths:
- '**'
- '!docs/**'
- '!.github/**'
- '.github/workflows/cppcmake.yml'
pull_request:
release:
types: ['created']
workflow_dispatch:
inputs:
cmakeextra:
description: 'Extra CMake options'
required: false
default: ''
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
defaults:
run:
shell: bash
jobs:
build:
name: ${{ matrix.config.name }}
runs-on: ${{ matrix.config.os }}
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
config:
# x86_64 Linux builds
- {name: "ubuntu-22.04-x64", os: "ubuntu-22.04", arch: "x86_64" }
- {name: "ubuntu-24.04-x64", os: "ubuntu-24.04", arch: "x86_64" }
# ARM Linux builds - cross-compiled with QEMU testing (Jetson, Raspberry Pi compatible)
# SHLIBDEPS must be disabled for cross-compiled packages as the host system
# does not have the target architecture libraries installed
- {name: "ubuntu-22.04-arm64", os: "ubuntu-22.04", arch: "aarch64", cross_compile: true, cmake_extra: "-DLSL_DISABLE_PACKAGE_SHLIBDEPS=ON" }
- {name: "ubuntu-22.04-armhf", os: "ubuntu-22.04", arch: "armv7", cross_compile: true, cmake_extra: "-DLSL_DISABLE_PACKAGE_SHLIBDEPS=ON" }
# Native ARM build
# - {name: "ubuntu-24.04-arm64-native", os: "ubuntu-24.04-arm", arch: "aarch64" }
# Windows builds
- {name: "windows-x64", os: "windows-latest", arch: "x86_64", cmake_extra: "-T v142,host=x86"}
- {name: "windows-x86", os: "windows-latest", arch: "x86", cmake_extra: "-T v142,host=x86 -A Win32"}
- {name: "windows-arm64", os: "windows-11-arm", arch: "aarch64", cmake_extra: "-T v143,host=ARM64 -A ARM64"}
# macOS non-framework builds (build-only, no tests or release uploads)
# These verify compatibility with package managers like conda-forge
- {name: "macos-dylib-x64", os: "macos-15-intel", arch: "x86_64", cmake_extra: "-DLSL_FRAMEWORK=OFF", build_only: true}
- {name: "macos-dylib-arm64", os: "macos-latest", arch: "arm64", cmake_extra: "-DLSL_FRAMEWORK=OFF", build_only: true}
steps:
- uses: actions/checkout@v5
# Set up cross-compilation toolchain for ARM on Linux
- name: Install cross-compilation toolchain
if: matrix.config.cross_compile && runner.os == 'Linux'
run: |
sudo apt-get update
if [[ "${{ matrix.config.arch }}" == "aarch64" ]]; then
sudo apt-get install -y --no-install-recommends \
gcc-aarch64-linux-gnu \
g++-aarch64-linux-gnu
echo "CMAKE_TOOLCHAIN=-DCMAKE_TOOLCHAIN_FILE=${GITHUB_WORKSPACE}/cmake/toolchains/aarch64-linux-gnu.cmake" >> $GITHUB_ENV
elif [[ "${{ matrix.config.arch }}" == "armv7" ]]; then
sudo apt-get install -y --no-install-recommends \
gcc-arm-linux-gnueabihf \
g++-arm-linux-gnueabihf
echo "CMAKE_TOOLCHAIN=-DCMAKE_TOOLCHAIN_FILE=${GITHUB_WORKSPACE}/cmake/toolchains/arm-linux-gnueabihf.cmake" >> $GITHUB_ENV
fi
# Cache dependencies for Linux
- name: Cache APT packages
if: runner.os == 'Linux'
uses: actions/cache@v4
with:
path: /var/cache/apt/archives
key: ${{ runner.os }}-apt-${{ matrix.config.name }}-${{ hashFiles('.github/workflows/cppcmake.yml') }}
restore-keys: |
${{ runner.os }}-apt-${{ matrix.config.name }}-
${{ runner.os }}-apt-
# Cache build artifacts with ccache
- name: Cache ccache
if: runner.os == 'Linux' || runner.os == 'macOS'
uses: actions/cache@v4
with:
path: ~/.ccache
key: ${{ runner.os }}-ccache-${{ matrix.config.name }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-ccache-${{ matrix.config.name }}-
${{ runner.os }}-ccache-
- name: Install ccache
if: runner.os == 'Linux' || runner.os == 'macOS'
run: |
if [[ "${{ runner.os }}" == "Linux" ]]; then
sudo apt-get install -y ccache
elif [[ "${{ runner.os }}" == "macOS" ]]; then
brew install ccache
fi
ccache --max-size=500M
ccache --set-config=compression=true
- name: Configure CMake
run: |
# Set up ccache as compiler wrapper (skip for cross-compilation)
if [[ "${{ runner.os }}" == "Linux" || "${{ runner.os }}" == "macOS" ]] && [[ "${{ matrix.config.cross_compile }}" != "true" ]]; then
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
export CC="ccache gcc"
export CXX="ccache g++"
fi
cmake --version
cmake -S . -B build \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=${PWD}/install \
-DLSL_UNITTESTS=ON \
-DLSL_BENCHMARKS=ON \
-DCPACK_PACKAGE_DIRECTORY=${PWD}/package \
-DCPACK_PACKAGE_FILE_NAME="liblsl-${{ matrix.config.arch }}" \
-Dlslgitrevision=${{ github.sha }} \
-Dlslgitbranch=${{ github.ref }} \
${CMAKE_TOOLCHAIN} \
${{ matrix.config.cmake_extra }} \
${{ github.event.inputs.cmakeextra }}
echo "Build directory: ${PWD}"
- name: Build
run: |
cmake --build build --config Release -j
# Show ccache statistics
if command -v ccache &> /dev/null; then
ccache -s
fi
- name: Install
run: cmake --build build --config Release --target install
- name: Test install using examples
run: |
# Test that the in-tree install was successful by building the examples
cmake -S examples -B examples/build \
-DLSL_INSTALL_ROOT=${PWD}/install \
-DCMAKE_INSTALL_PREFIX=examples/build/install \
-DLSL_COMFY_DEFAULTS=ON \
${CMAKE_TOOLCHAIN} \
${{ matrix.config.cmake_extra }} \
${{ github.event.inputs.cmakeextra }}
cmake --build examples/build --target install --config Release -j
# Run example binary (skip for cross-compiled builds - no QEMU)
if [[ "${{ matrix.config.cross_compile }}" != "true" ]]; then
./examples/build/install/bin/HandleMetaData
else
echo "Skipping example execution for cross-compiled build (requires real ARM hardware)"
echo "Build validation successful - binary can be tested on target hardware"
fi
- name: Package
if: matrix.config.build_only != true
run: |
echo "Creating package for ${{ matrix.config.arch }}"
cmake --build build --target package --config Release -j
# On Debian / Ubuntu the dependencies can only be resolved for
# already installed packages (only for native builds, not cross-compiled)
if [[ "${{ matrix.config.os }}" == ubuntu-* ]] && [[ "${{ matrix.config.cross_compile }}" != "true" ]]; then
cmake -DCPACK_DEBIAN_PACKAGE_SHLIBDEPS=ON build
sudo dpkg -i package/*.deb
cmake --build build --target package --config Release -j
dpkg -I package/liblsl*.deb
fi
if [[ "${{ matrix.config.cross_compile }}" == "true" ]]; then
echo "Cross-compiled ${{ matrix.config.arch }} package created"
ls -lh package/
fi
cmake -E remove_directory package/_CPack_Packages
cp testing/lslcfgs/default.cfg . 2>/dev/null || true
- name: upload install dir
if: matrix.config.build_only != true
uses: actions/upload-artifact@master
with:
name: build-${{ matrix.config.name }}
path: install
- name: upload package
if: matrix.config.build_only != true
uses: actions/upload-artifact@master
with:
name: pkg-${{ matrix.config.name }}
path: package
- name: print network config
run: |
which ifconfig && ifconfig
if [ `which ip` ]; then
ip link
ip addr
ip route
ip -6 route
fi
# Run tests (native builds only, skip build_only configs)
- name: Unit tests
if: matrix.config.cross_compile != true && matrix.config.build_only != true
run: |
# Set up core dumps for debugging
if [[ "${{ matrix.config.name }}" == ubuntu-* ]]; then
ulimit -c unlimited
echo "$PWD/dumps/corefile-%e-%p-%t" | sudo tee /proc/sys/kernel/core_pattern
fi
mkdir -p dumps
# Run unit tests
install/bin/lsl_test_internal --order rand --wait-for-keypress never --durations yes
install/bin/lsl_test_exported --order rand --wait-for-keypress never --durations yes
timeout-minutes: 10
- name: upload dump
if: failure()
uses: actions/upload-artifact@master
with:
name: dumps-${{ matrix.config.name }}
path: dumps
- name: Upload to release
if: github.event_name == 'release' && matrix.config.build_only != true
uses: softprops/action-gh-release@v2
with:
files: package/*.*