forked from audacity/audacity
-
Notifications
You must be signed in to change notification settings - Fork 3
284 lines (278 loc) · 10.4 KB
/
cmake.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
#
# CMake based build for Audacity
#
name: CMake Build
#
# Only execute on "git push" actions
#
on:
push:
# Remove the "#" from the next 2 lines if you need to disable this action
#branches:
# - disable
pull_request:
# Remove the "#" from the next 2 lines if you need to disable this action
#branches:
# - disable
#
# Global environment variables
#
env:
WXURL: https://github.com/audacity/wxWidgets
WXREF: audacity-fixes-3.1.3
WXWIN: ${{ github.workspace }}/wxwin
# As of 2021/01/01, github is using Xcode 12.2 as the default and
# it has a bug in the install_name_tool. So explicitly use 12.3
# instead.
DEVELOPER_DIR: /Applications/Xcode_12.3.app/Contents/Developer
#
# Define our job(s)
#
jobs:
build:
name: ${{ matrix.config.name }}
runs-on: ${{ matrix.config.os }}
strategy:
fail-fast: false
matrix:
config:
- {
name: "Windows_32bit",
os: windows-latest,
generator: "Visual Studio 16 2019",
platform: "Win32"
}
- {
name: "Windows_64bit",
os: windows-latest,
generator: "Visual Studio 16 2019",
platform: "x64"
}
- {
name: "Ubuntu_18.04",
os: ubuntu-18.04,
generator: "Unix Makefiles"
}
- {
name: "macOS",
os: macos-latest,
generator: "Xcode"
}
steps:
# =========================================================================
# SHARED: Checkout source
# =========================================================================
- name: Checkout
uses: actions/checkout@v2
# with:
# ref: master
# =========================================================================
# SHARED: Retrieve git hashes and set up for cache
# =========================================================================
- name: Setup cache
shell: bash
run: |
set -x
# Get latest wxWidgets commit hash
wxhash=$(git ls-remote "${WXURL}" "${WXREF}" | awk 'NR==1 {print $1}')
# Build the cache key
wxhash="wx_${wxhash}_${RUNNER_OS}_${{matrix.config.platform}}"
# Export the commit hash to further steps
echo "WXHASH=${wxhash}" >> ${GITHUB_ENV}
# Get the short hash
shorthash=$(git show -s --format='%h')
# Export the short hash for the upload step
echo "SHORTHASH=${shorthash}" >> ${GITHUB_ENV}
# Export the destination directory name
echo "DEST=${{matrix.config.name}}_${shorthash}" >> ${GITHUB_ENV}
# =========================================================================
# SHARED: Create and/or retrieve wxWidgets cached build
# =========================================================================
- name: Populate cache
id: cache
uses: actions/cache@v1
with:
# Increment the number at the end to force recreation of the cache
key: ${{ env.WXHASH }}.2
path: ${{ env.WXWIN }}
# =========================================================================
# WINDOWS: Build (for all versions of Windows)
# =========================================================================
- name: Build for Windows
if: startswith( matrix.config.os, 'windows' )
shell: bash
run: |
set -x
# Build wxWidgets if needed
if [ ! -e "${WXWIN}" ]
then
# Clone the wxWidgets repo
git clone --depth 1 --recurse-submodules -b "${WXREF}" "${WXURL}" "wxroot"
# Use cmake since it defines the MSVC environment for us
cmake -S "wxroot" \
-B "wxroot" \
-G "${{matrix.config.generator}}" \
-A "${{matrix.config.platform}}"
# Build
cmake --build "wxroot" --config Release --verbose
# Install to the cached path
cmake --install "wxroot" --config Release --prefix "${WXWIN}"
# On Windows, we need zlib for libid3tag
mkdir -p "${WXWIN}/src"
cp -a "wxroot/lib" "${WXWIN}/"
cp -a "wxroot/src/zlib" "${WXWIN}/src"
fi
# Convert to CMake path
export WXWIN="${WXWIN//\\//}"
# Configure Audacity
#
# The wxWidgets_USE_REL_AND_DBG is needed because,
# on Github, we only build the Release version of
# wxWidgets and the FindwxWidgets CMake module
# defaults to looking for both. If either of them
# isn't found, then it doesn't provided the required
# library information. This is only a concern for
# Windows.
cmake -S . \
-B build \
-G "${{matrix.config.generator}}" \
-A ${{matrix.config.platform}} \
-D wxWidgets_USE_REL_AND_DBG=no \
-D audacity_use_pch=no
# Build Audacity
cmake --build build --config Release --verbose
# "Install" Audacity
mkdir -p "${DEST}"
cp -a build/bin/Release/* "${DEST}"
rm -f "${DEST}"/{*.iobj,*.ipdb}
# Create artifact (zipped as Github actions don't preserve permissions)
cmake -E tar c "${GITHUB_SHA}.zip" --format=zip "${DEST}"
# =========================================================================
# MACOS: Build (for all versions of MacOS)
# =========================================================================
- name: Build for macOS
if: startswith( matrix.config.os, 'macos' )
shell: bash
run: |
set -x
# Setup environment
export PATH="/usr/local/bin:${PATH}"
export DYLD_LIBRARY_PATH="/usr/local/lib"
# Install required packages
brew install gettext
brew link --force gettext
# Build wxWidgets if needed
if [ ! -e "${WXWIN}" ]
then
# Clone the wxWidgets repo
git clone --depth 1 --recurse-submodules -b "${WXREF}" "${WXURL}" "wxroot"
# Make sure our flags are included
export CXX="g++ -std=c++1z -stdlib=libc++"
export LD="g++ -std=c++1z -stdlib=libc++"
# The cmake build produces an incorrect wx-config script, so use
# the plain old configure/make
cd wxroot
./configure --prefix=/usr/local \
--enable-debug=no \
--enable-macosx-arch="x86_64" \
--enable-shared=yes \
--enable-unicode=yes \
--enable-universal_binary=no \
--enable-webkit=no \
--enable-webviewwebkit=no \
--with-expat=builtin \
--with-flavour="release" \
--with-libjpeg=builtin \
--with-libpng=builtin \
--with-libtiff=builtin \
--with-macosx-version-min="10.7" \
--with-regex=builtin \
--with-zlib=builtin \
--without-liblzma
# Build and install to cached path
make -j $(sysctl -n hw.ncpu) install DESTDIR="${WXWIN}"
cd ..
# Clean up
unset CXX LD
fi
# "Install" wxWidgets
sudo cp -a "${WXWIN}"/usr/* /usr
# Configure Audacity
cmake -S . \
-B build \
-G "${{matrix.config.generator}}" \
-D audacity_use_pch=no
# Build Audacity
cmake --build build --config Release
# "Install" Audacity
mkdir -p "${DEST}"
cp -a build/bin/Release/ "${DEST}"
# Create artifact (zipped as Github actions don't preserve permissions)
cmake -E tar c "${GITHUB_SHA}.zip" --format=zip "${DEST}"
# =========================================================================
# UBUNTU: Build (for all versions of Ubuntu)
# =========================================================================
- name: Build for Ubuntu
if: startswith( matrix.config.os, 'ubuntu' )
shell: bash
run: |
set -x
# Setup environment
export PATH="/usr/local/bin:${PATH}"
export LD_LIBRARY_PATH="/usr/local/lib"
# Install required packages
sudo apt-get update -y
sudo apt-get install -y libgtk2.0-dev libasound2-dev gettext
sudo apt-get remove -y ccache
# Build wxWidgets if needed
if [ ! -e "${WXWIN}" ]
then
# Clone the wxWidgets repo
git clone --depth 1 --recurse-submodules -b "${WXREF}" "${WXURL}" "wxroot"
# Install additional required package
sudo apt-get install -y autoconf automake
# The cmake build produces an incorrect wx-config script, so use
# the plain old configure
cd wxroot
./configure --with-gtk
# Build and install to cached path
make -j $(nproc) install DESTDIR="${WXWIN}"
cd ..
fi
# "Install" wxWidgets
sudo cp -a "${WXWIN}"/* /
# Configure Audacity
cmake -S . \
-B build \
-G "${{matrix.config.generator}}" \
-D audacity_use_pch=no
# Build Audacity
cmake --build build --config Release
# "Install" Audacity
cmake --install build --config Release --prefix "${DEST}"
# Create the lib directory
mkdir -p ${DEST}/lib
# Copy over wxWidgets libs
ldd ${DEST}/bin/audacity
for lib in $(ldd ${DEST}/bin/audacity | awk '/libwx/{print $3}')
do
echo ${lib}
ldd ${lib} | awk '/libwx/{print $3}'
done | sort -u | xargs cp -n -H -t ${DEST}/lib
# Create wrapper script
cat >"${DEST}/audacity" <<"EOF"
#!/bin/sh
export LD_LIBRARY_PATH="${0%/*}/lib:${LD_LIBRARY_PATH}"
"${0%/*}/bin/audacity"
EOF
chmod +x "${DEST}/audacity"
# Create artifact (zipped as Github actions don't preserve permissions)
cmake -E tar c "${GITHUB_SHA}.zip" --format=zip "${DEST}"
# =========================================================================
# SHARED: Attach the artifact to the workflow results
# =========================================================================
- name: Upload artifact
uses: actions/upload-artifact@v1
with:
name: ${{ matrix.config.name }}_${{ env.SHORTHASH }}
path: ${{ github.sha }}.zip