forked from tildearrow/furnace
-
Notifications
You must be signed in to change notification settings - Fork 0
339 lines (288 loc) · 11.5 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
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
name: Build furnace
on:
push:
branches: [master, ymf278b]
pull_request:
branches: ymf287b
defaults:
run:
shell: bash
env:
BUILD_TYPE: RelWithDebInfo
jobs:
build:
strategy:
matrix:
config:
- { name: 'Windows MSVC x86', os: windows-latest, compiler: msvc, arch: x86 }
- { name: 'Windows MSVC x86_64', os: windows-latest, compiler: msvc, arch: x86_64 }
#- { name: 'Windows MinGW x86', os: ubuntu-20.04, compiler: mingw, arch: x86 }
#- { name: 'Windows MinGW x86_64', os: ubuntu-20.04, compiler: mingw, arch: x86_64 }
#- { name: 'macOS x86_64', os: macos-12, arch: x86_64 }
#- { name: 'macOS ARM', os: macos-latest, arch: arm64 }
#- { name: 'Linux x86_64', os: ubuntu-20.04, arch: x86_64 }
#- { name: 'Linux ARM', os: ubuntu-18.04, arch: armhf }
fail-fast: true
name: ${{ matrix.config.name }}
runs-on: ${{ matrix.config.os }}
steps:
- name: Checkout
uses: actions/checkout@v4.1.1
with:
submodules: recursive
- name: Set Windows arch identifiers
id: windows-identify
if: ${{ matrix.config.compiler == 'msvc' || matrix.config.compiler == 'mingw' }}
run: |
vswhere_target="${{ matrix.config.arch }}"
msvc_target="${{ matrix.config.arch }}"
mingw_target="${{ matrix.config.arch }}"
if [ '${{ matrix.config.arch }}' == 'x86' ]; then
msvc_target="Win32"
elif [ '${{ matrix.config.arch }}' == 'x86_64' ]; then
vswhere_target="amd64"
msvc_target="x64"
fi
if [ '${{ matrix.config.compiler }}' == 'msvc' ]; then
echo "vswhere target: ${vswhere_target}"
echo "MSVC target: ${msvc_target}"
else
echo "MinGW cross target: ${mingw_target}"
fi
echo "vswhere-target=${vswhere_target}" >> $GITHUB_OUTPUT
echo "msvc-target=${msvc_target}" >> $GITHUB_OUTPUT
echo "mingw-target=${mingw_target}" >> $GITHUB_OUTPUT
- name: Set package identifier
id: package-identify
run: |
package_name="furnace-${GITHUB_SHA}"
package_ext=""
if [ '${{ runner.os }}' == 'Windows' ] || [ '${{ matrix.config.compiler }}' == 'mingw' ]; then
package_name="${package_name}-Windows"
if [ '${{ matrix.config.compiler }}' == 'mingw' ]; then
package_name="${package_name}-MinGW"
else
package_name="${package_name}-MSVC"
fi
package_name="${package_name}-${{ matrix.config.arch }}"
package_ext="" # Directory, uploading will automatically zip it
elif [ '${{ runner.os }}' == 'macOS' ]; then
package_name="${package_name}-macOS-${{ matrix.config.arch }}"
package_ext=".dmg"
else
package_name="${package_name}-Linux-${{ matrix.config.arch }}"
package_ext=".tar.gz"
fi
echo "Package identifier: ${package_name}"
echo "Package file: ${package_name}${package_ext}"
echo "id=${package_name}" >> $GITHUB_OUTPUT
echo "filename=${package_name}${package_ext}" >> $GITHUB_OUTPUT
- name: Set build cores amount
id: build-cores
run: |
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
amount=2
if [ '${{ runner.os }}' == 'macOS' ]; then
amount=3
fi
echo "Amount of cores we can build with: ${amount}"
echo "amount=${amount}" >> $GITHUB_OUTPUT
- name: Setup Toolchain [Windows MSVC]
if: ${{ matrix.config.compiler == 'msvc' }}
uses: lunathir/gha-setup-vsdevenv@avoid-deprecation-warnings
with:
arch: ${{ steps.windows-identify.outputs.vswhere-target }}
- name: Setup Toolchain [Windows MinGW]
if: ${{ matrix.config.compiler == 'mingw' }}
run: |
sudo apt update
sudo apt install \
mingw-w64 \
mingw-w64-tools
- name: Install Dependencies [Linux x86_64]
if: ${{ runner.os == 'Linux' && matrix.config.compiler != 'mingw' && matrix.config.arch == 'x86_64' }}
run: |
sudo apt update
sudo apt install \
libsdl2-dev \
libfmt-dev \
librtmidi-dev \
libsndfile1-dev \
zlib1g-dev \
libjack-jackd2-dev \
gettext
- name: Install Dependencies [Linux armhf]
if: ${{ runner.os == 'Linux' && matrix.config.compiler != 'mingw' && matrix.config.arch == 'armhf' }}
run: |
sudo sed -ri "s/^deb /deb [arch=amd64] /" /etc/apt/sources.list
echo "deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports/ bionic main universe" | sudo tee -a /etc/apt/sources.list
echo "deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports/ bionic-updates main universe" | sudo tee -a /etc/apt/sources.list
sudo dpkg --add-architecture armhf
sudo apt update
sudo apt install \
crossbuild-essential-armhf \
appstream \
gettext
sudo apt install \
libsdl2-dev:armhf \
libfmt-dev:armhf \
librtmidi-dev:armhf \
libsndfile1-dev:armhf \
zlib1g-dev:armhf \
libjack-jackd2-dev:armhf
ls /usr/arm-linux-gnueabihf/lib
- name: Build Language Files
if: ${{ runner.os == 'Linux' && matrix.config.compiler != 'mingw' }}
run: |
./scripts/build-po.sh
- name: Configure
run: |
export USE_WAE=ON
export CMAKE_EXTRA_ARGS=()
if [ '${{ matrix.config.compiler }}' == 'msvc' ]; then
CMAKE_EXTRA_ARGS+=('-DCMAKE_GENERATOR_PLATFORM=${{ steps.windows-identify.outputs.msvc-target }}')
# Force static linking
# 1. Make MSVC runtime configurable
CMAKE_EXTRA_ARGS+=('-DCMAKE_POLICY_DEFAULT_CMP0091=NEW')
# 2. Use static (debug) runtime
if [ '${{ env.BUILD_TYPE }}' == 'Debug' ]; then
CMAKE_EXTRA_ARGS+=('-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDebug')
else
CMAKE_EXTRA_ARGS+=('-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded')
fi
elif [ '${{ matrix.config.compiler }}' == 'mingw' ]; then
CMAKE_EXTRA_ARGS+=('-DCMAKE_TOOLCHAIN_FILE=scripts/Cross-MinGW-${{ steps.windows-identify.outputs.mingw-target }}.cmake')
if [ '${{ matrix.config.arch }}' == 'x86' ]; then
CMAKE_EXTRA_ARGS+=('-DSUPPORT_XP=ON')
fi
elif [ '${{ runner.os }}' == 'macOS' ]; then
if [ '${{ matrix.config.arch }}' == 'arm64' ]; then
CMAKE_EXTRA_ARGS+=('-DCMAKE_OSX_DEPLOYMENT_TARGET="11.0"' '-DCMAKE_OSX_ARCHITECTURES=arm64' '-DMAKE_BUNDLE=ON')
else
CMAKE_EXTRA_ARGS+=('-DCMAKE_OSX_DEPLOYMENT_TARGET="10.9"' '-DCMAKE_OSX_ARCHITECTURES=x86_64' '-DMAKE_BUNDLE=ON' '-DCMAKE_C_FLAGS=-march=core2' '-DCMAKE_CXX_FLAGS=-march=core2')
fi
elif [ '${{ runner.os }}' == 'Linux' ] && [ '${{ matrix.config.arch }}' == 'armhf' ]; then
CMAKE_EXTRA_ARGS+=('-DCMAKE_TOOLCHAIN_FILE=scripts/Cross-Linux-armhf.cmake')
fi
cmake \
-B ${PWD}/build \
-DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \
-DWARNINGS_ARE_ERRORS=${USE_WAE} \
-DWITH_DEMOS=OFF -DWITH_INSTRUMENTS=OFF -DWITH_WAVETABLES=OFF \
"${CMAKE_EXTRA_ARGS[@]}"
- name: Build
run: |
cmake \
--build ${PWD}/build \
--config ${{ env.BUILD_TYPE }} \
--parallel ${{ steps.build-cores.outputs.amount }}
- name: Package [Windows]
if: ${{ runner.os == 'Windows' || matrix.config.compiler == 'mingw' }}
run: |
binPath=build
if [ '${{ matrix.config.compiler }}' == 'msvc' ]; then
binPath="${binPath}/${{ env.BUILD_TYPE }}"
fi
# always strip on MinGW as it generate massive artifacts
#if [ '${{ matrix.config.compiler }}' == 'mingw' ]; then
# # arch-specific strip prefix
# # TODO maybe extract from cross toolchain files?
# toolPrefix="-w64-mingw32-"
# if [ '${{ matrix.config.arch }}' == 'x86_64' ]; then
# toolPrefix="x86_64${toolPrefix}"
# else
# toolPrefix="i686${toolPrefix}"
# fi
# ${toolPrefix}strip -s "${binPath}/furnace.exe"
#fi
mkdir ${{ steps.package-identify.outputs.filename }}
pushd ${{ steps.package-identify.outputs.filename }}
cp -v ../LICENSE LICENSE.txt
cp -v ../res/releaseReadme/unstable-win.txt README.txt
cp -vr ../po/locale locale
cp -vr ../papers ../${binPath}/furnace.exe ./
if [ '${{ matrix.config.compiler }}' == 'msvc' ]; then
cp -v ../${binPath}/furnace.pdb ./
fi
sha256sum ../${binPath}/furnace.exe > checksum.txt
popd
- name: Package [macOS]
if: ${{ runner.os == 'macOS' }}
run: |
pushd build
echo "preparing bundle"
mkdir -p Furnace.app/Contents/Resources
cp -v -r ../po/locale Furnace.app/Contents/Resources/locale
cp -v ../res/icon.icns Furnace.app/Contents/Resources/Furnace.icns
codesign --deep -f -s - Furnace.app
echo "making dirs"
mkdir new
echo "copying"
cp -v -r Furnace.app new/Furnace.app
ln -s /Applications new/Applications
echo "synchronizing"
sync
echo "copying extra stuff"
cp -v ../LICENSE new/LICENSE.txt
cp -v ../res/releaseReadme/stable-mac.txt new/README
cp -v -r ../demos new/demos
cp -v -r ../instruments new/instruments
cp -v -r ../wavetables new/wavetables
cd new
wget https://tildearrow.org/furnace/doc/latest/manual.pdf
cd ..
echo "creating new image"
retries=0
while ! hdiutil create -srcfolder new -volname Furnace -format UDZO -fs HFS+ furnace.dmg; do
echo "TRYING AGAIN..."
retries=$((retries+1))
if [ $retries -gt 5 ]; then
echo "OH NO, WE'VE FAILED..."
exit 1
break
fi
sleep 5
done
mv furnace.dmg ../${{ steps.package-identify.outputs.filename }}
popd
- name: Package [Linux]
if: ${{ runner.os == 'Linux' && matrix.config.compiler != 'mingw' }}
run: |
#if [ '${{ env.BUILD_TYPE }}' == 'Release' ]; then
# strip -s build/furnace
#fi
mkdir -p target/furnace
make -C ${PWD}/build DESTDIR=${PWD}/target/furnace install
pushd target/furnace
cp -v ../../res/logo.png .DirIcon
cd usr
mv bin/furnace ..
rmdir bin
rm -r share/applications
rm -r share/doc
rm -r share/icons
rm -r share/licenses
rm -r share/metainfo
rm -r share/mime
mv share/locale ..
rmdir share
cd ..
cp ../../LICENSE .
cp ../../res/releaseReadme/unstable-other.txt .
cp -r ../../papers papers
rmdir usr
popd
cd target
tar -zcv -f ../${{ steps.package-identify.outputs.filename }} furnace
- name: Upload artifact
uses: actions/upload-artifact@v4.3.0
with:
name: ${{ steps.package-identify.outputs.id }}
path: ${{ steps.package-identify.outputs.filename }}
- name: Upload Metal artifact
if: ${{ github.repository == 'tildearrow/furnace' && github.ref_name == 'metal' }}
uses: actions/upload-artifact@v4.3.0
with:
name: ${{ steps.package-identify.outputs.id }}
path: ${{ steps.package-identify.outputs.filename }}