-
Notifications
You must be signed in to change notification settings - Fork 20
316 lines (264 loc) · 11.3 KB
/
build.yml
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
name: Build
# Run workflow when manually triggered, part of a pull request or on a tag push (release)
on:
workflow_dispatch:
pull_request:
push:
branches:
- 'main'
tags:
- '*'
jobs:
build:
name: ${{ matrix.config.name }}
runs-on: ${{ matrix.config.os }}
env:
CCACHE_WIN_VERSION: 4.2.1
CCACHE_DIR: ${{ github.workspace }}/.ccache
CCACHE_COMPRESS: 'true'
CCACHE_COMPRESSLEVEL: '5'
CCACHE_MAXSIZE: '500M'
CCACHE_BASEDIR: '${{ github.workspace }}'
strategy:
matrix:
config:
- name: "Windows Latest MSVC"
os: windows-latest
package: true
cmake_preset: "windows-packaging-release"
vcpkg_triplet: x64-windows-static
test: true
- name: "Windows Latest MSVC RelWithDebInfo"
os: windows-latest
package: true
cmake_preset: "windows-packaging-relwithdebinfo"
vcpkg_triplet: x64-windows-static
test: true
- name: "macOS Latest Clang x64"
os: macos-latest
package: true
cmake_preset: "macos-packaging-release"
vcpkg_triplet: x64-osx-10_13
test: true
- name: "macOS Latest Clang arm64"
os: macos-latest
package: true
cmake_preset: "macos-arm64-packaging-release"
vcpkg_triplet: arm64-osx-11_0
test: false
- name: "Ubuntu 20.04"
os: ubuntu-20.04
package: true
cmake_preset: "linux-packaging-release"
vcpkg_triplet: x64-linux
test: true
steps:
- name: Set Conditional Environment Variables (Win)
if: matrix.config.os == 'windows-latest'
run: |
echo "VCPKG_DEFAULT_BINARY_CACHE=C:/tmp/vcpkg_cache" >> $env:GITHUB_ENV
- name: Set Conditional Environment Variables (NOT Win)
if: matrix.config.os != 'windows-latest'
run: |
echo "VCPKG_DEFAULT_BINARY_CACHE=${{ github.workspace }}/vcpkg_cache" >> $GITHUB_ENV
- name: 'Windows Disk Space'
if: matrix.config.os == 'windows-latest'
run: Get-PSDrive
- name: 'Checkout repo recursively.'
uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 0
- name: 'Install ninja-build tool.'
uses: seanmiddleditch/gha-setup-ninja@v3
- name: 'Create vcpkg cache dir.'
run: cmake -E make_directory ${{ env.VCPKG_DEFAULT_BINARY_CACHE }}
- name: 'Prepare timestamp.'
id: cache_timestamp
shell: cmake -P {0}
run: |
string(TIMESTAMP current_date "%Y-%m-%d-%H;%M;%S" UTC)
file(APPEND "$ENV{GITHUB_OUTPUT}" "timestamp=${current_date}\n")
- name: 'Restore vcpkg and its artifacts.'
uses: actions/cache@v3
with:
path: ${{ env.VCPKG_DEFAULT_BINARY_CACHE }}
key: ${{ matrix.config.name }}-vcpkg-${{ steps.cache_timestamp.outputs.timestamp }}
restore-keys: |
${{ matrix.config.name }}-vcpkg-
- name: 'Windows: Install ccache.'
if: matrix.config.os == 'windows-latest'
shell: cmake -P {0}
run: |
set(ccache_url "https://github.com/cristianadam/ccache/releases/download/v$ENV{CCACHE_WIN_VERSION}/Windows.tar.xz")
file(DOWNLOAD "${ccache_url}" ./ccache.tar.xz SHOW_PROGRESS)
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xvf ./ccache.tar.xz)
working-directory: ${{ runner.workspace }}
- name: 'Windows: Add ccache location to PATH.'
if: matrix.config.os == 'windows-latest'
run: |
echo "${{ runner.workspace }}" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: 'macOS: Install ccache.'
if: matrix.config.os == 'macos-latest'
run: |
brew install ccache
- name: 'macOS: Install pkg-config.'
if: matrix.config.os == 'macos-latest'
run: |
brew install pkg-config
- name: 'linux: Install dependencies.'
if: startsWith(matrix.config.os, 'ubuntu')
run: |
sudo apt-get install -y ccache libx11-dev libxcursor-dev libxext-dev libxinerama-dev libxrandr-dev libglu1-mesa-dev libfreetype6-dev
- name: 'Cache ccache files.'
uses: actions/cache@v3
with:
path: ${{ env.CCACHE_DIR }}
key: ${{ matrix.config.name }}-ccache-${{ steps.cache_timestamp.outputs.timestamp }}
restore-keys: |
${{ matrix.config.name }}-ccache-
- name: 'Zero ccache stats.'
run: ccache -z
- name: 'Print ccache config.'
run: ccache -p
- name: 'Set install prefix.'
id: cmake_install_prefix
env:
RUNNER_WORKSPACE: ${{ runner.workspace }}
shell: cmake -P {0}
run: |
string(REPLACE " " "_" NAME_NO_SPACES "${{ matrix.config.name }}")
file(TO_CMAKE_PATH "$ENV{RUNNER_WORKSPACE}" RUNNER_WORKSPACE)
set(INSTALL_DIR "${NAME_NO_SPACES}")
file(TO_NATIVE_PATH "${RUNNER_WORKSPACE}/${INSTALL_DIR}" PREFIX)
file(APPEND "$ENV{GITHUB_OUTPUT}" "install_prefix=${PREFIX}\n")
file(APPEND "$ENV{GITHUB_OUTPUT}" "install_dir=${INSTALL_DIR}\n")
- name: 'Windows: set up developer environment'
uses: ilammy/msvc-dev-cmd@v1
if: matrix.config.os == 'windows-latest'
- name: 'Git Status'
run: git status
- name: 'Configure with CMake, vcpkg and ccmake (Win)'
if: matrix.config.os == 'windows-latest'
run: cmake --preset ${{ matrix.config.cmake_preset }} -DCMAKE_INSTALL_PREFIX="${{ steps.cmake_install_prefix.outputs.install_prefix }}" -DEPS_CI=ON -DVCPKG_INSTALL_OPTIONS="--x-buildtrees-root=C:/tmp/vcpkg_buildtrees;--downloads-root=C:/tmp/vcpkg_downloads;--x-packages-root=C:/tmp/vcpkg_packages" -DVCPKG_INSTALLED_DIR="C:/tmp/vcpkg_installed"
env:
CMAKE_C_COMPILER_LAUNCHER: 'ccache'
CMAKE_CXX_COMPILER_LAUNCHER: 'ccache'
- name: 'Configure with CMake, vcpkg and ccmake (NOT Win)'
if: matrix.config.os != 'windows-latest'
run: cmake --preset ${{ matrix.config.cmake_preset }} -DCMAKE_INSTALL_PREFIX="${{ steps.cmake_install_prefix.outputs.install_prefix }}" -DEPS_CI=ON
env:
CMAKE_C_COMPILER_LAUNCHER: 'ccache'
CMAKE_CXX_COMPILER_LAUNCHER: 'ccache'
- name: 'Git Status'
run: git status
- name: 'Prune the vcpkg cache'
run: cmake -P "${{ github.workspace }}/.github/workflows/expire_vcpkg_cache.cmake"
- name: 'Windows Disk Space'
if: matrix.config.os == 'windows-latest'
run: Get-PSDrive
- name: 'Build using CMake and Ninja via CMake preset.'
run: cmake --build --preset ${{ matrix.config.cmake_preset }}
- name: 'Print ccache stats.'
run: ccache -s
- name: 'Windows Disk Space'
if: matrix.config.os == 'windows-latest'
run: Get-PSDrive
- name: 'Run tests.'
if: ${{ matrix.config.test }}
run: ctest --preset '${{ matrix.config.cmake_preset }}'
- name: 'Install to output dir.'
if: ${{ matrix.config.package }}
run: |
cmake -E make_directory "${{ steps.cmake_install_prefix.outputs.install_prefix }}"
cmake --build --preset ${{ matrix.config.cmake_preset }} --target install
- name: 'unix: Tar output dir.'
if: ${{ matrix.config.package && !startsWith(matrix.config.os, 'windows') }}
run: tar -cvf ${{ steps.cmake_install_prefix.outputs.install_dir }}.tar -C ${{ steps.cmake_install_prefix.outputs.install_prefix }} .
- name: 'unix: Upload Tar as build artifact.'
if: ${{ matrix.config.package && !startsWith(matrix.config.os, 'windows') }}
uses: actions/upload-artifact@v2
with:
name: ${{ steps.cmake_install_prefix.outputs.install_dir }}
path: ${{ steps.cmake_install_prefix.outputs.install_dir }}.tar
- name: 'Windows: Upload output dir as build artifact.'
if: ${{ matrix.config.package && matrix.config.os == 'windows-latest' }}
uses: actions/upload-artifact@v2
with:
name: ${{ steps.cmake_install_prefix.outputs.install_dir }}
path: ${{ steps.cmake_install_prefix.outputs.install_prefix }}
- name: 'Windows Disk Space'
if: matrix.config.os == 'windows-latest'
run: Get-PSDrive
# Clean up windows tmp dir
- name: 'Clean up temporary files (Win)'
if: matrix.config.os == 'windows-latest'
run: cmake -E rm -rf "C:/tmp"
mac_universal_bin:
name: mac_universal_bin
runs-on: macos-latest
needs: build
steps:
- uses: actions/download-artifact@v2
with:
name: 'macOS_Latest_Clang_x64'
path: 'macOS_Latest_Clang_x64'
- uses: actions/download-artifact@v2
with:
name: 'macOS_Latest_Clang_arm64'
path: 'macOS_Latest_Clang_arm64'
- name: 'un-tar x64'
run: tar -xf macOS_Latest_Clang_x64.tar && rm macOS_Latest_Clang_x64.tar
working-directory: macOS_Latest_Clang_x64
- name: 'un-tar arm64'
run: tar -xf macOS_Latest_Clang_arm64.tar && rm macOS_Latest_Clang_arm64.tar
working-directory: macOS_Latest_Clang_arm64
- name: 'dir listing'
run: ls -R
- name: 'build ub'
run: |
intel_dir="macOS_Latest_Clang_x64"
arm_dir="macOS_Latest_Clang_arm64"
ub_dir="macOS_Latest_Clang_universal"
cp -r $intel_dir $ub_dir
function make_ub() {
intel_bin="$1"
arm_bin=$(echo "$intel_bin" | sed "s:$intel_dir:$arm_dir:")
ub_bin=$(echo "$intel_bin" | sed "s:$intel_dir:$ub_dir:")
if [ ! -f "$arm_bin" ]; then
echo "$arm_bin not found"
exit 1
fi
lipo "$intel_bin" "$arm_bin" -create -output "$ub_bin"
}
LIBS=`find $intel_dir -name '*.dylib'`
# note: "! -name '*.*'" excludes files with an extension (auxiliary files)
PLUGINS=`find $intel_dir -path '*vst3/Contents/MacOS/*' ! -name '*.*'`
APPS=`find $intel_dir -path '*app/Contents/MacOS/*' ! -name '*.*'`
# don't forget project upgrade command line util
EXES=`find $intel_dir -name 'project_upgrade'`
IFS=$'\n'
for exe in $EXES; do
echo "Making UB Exectuable from: $exe"
make_ub "$exe"
done
for lib in $LIBS; do
echo "Making UB Library from: $lib"
make_ub "$lib"
done
for plugin in $PLUGINS; do
echo "Making UB Plugin from: $plugin"
make_ub "$plugin"
done
for app in $APPS; do
echo "Making UB App from: $app"
make_ub "$app"
done
- name: 'dir listing'
run: ls -R
- name: 'tar ub'
run: tar -cvf macOS_Latest_Clang_universal.tar -C macOS_Latest_Clang_universal .
- uses: actions/upload-artifact@v2
with:
name: 'macOS_Latest_Clang_universal'
path: 'macOS_Latest_Clang_universal.tar'