-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathbuild-cmd.sh
More file actions
317 lines (265 loc) · 14 KB
/
Copy pathbuild-cmd.sh
File metadata and controls
317 lines (265 loc) · 14 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
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
#!/usr/bin/env bash
cd "$(dirname "$0")"
# turn on verbose debugging output for parabuild logs.
# exec 4>&1; export BASH_XTRACEFD=4; set -x
# make errors fatal
set -e
# bleat on references to undefined shell variables
set -u
# Check autobuild is around or fail
if [ -z "$AUTOBUILD" ] ; then
exit 1
fi
if [ "$OSTYPE" = "cygwin" ] ; then
export AUTOBUILD="$(cygpath -u $AUTOBUILD)"
fi
top="$(pwd)"
stage="${top}/stage"
# this name must match the one in the autobuild.xml manifest since that is
# what 'autobuild package' looks for when it create a package
cef_stage_dir="${stage}/cef"
# The CEF branch number you want to build
# The relationship to Chrome and the versions of Chromium/CEF is complex and
# can make it difficult to find the branch number to use. This page can help:
# https://bitbucket.org/chromiumembedded/cef/wiki/BranchesAndBuilding
# E.G. Branch 7258 represents Chromium/CEF 139.x
cef_branch_number=7258
# Turn on the proprietary codec support (the main reason for building from source vs using
# the Spotify open source builds here https://cef-builds.spotifycdn.com/index.html)
# Turning this on for builds will allow the resulting browser to render media URLs for
# MPEG4 and H264 directly along with providing transport controls. Examples of this are
# Twitch and YouTube live streams.
use_proprietary_codecs=1
# Load autobuild provided shell functions and variables
source_environment_tempfile="$stage/source_environment.sh"
"$AUTOBUILD" source_environment > "$source_environment_tempfile"
. "$source_environment_tempfile"
# used in VERSION.txt but common to all bit-widths and platforms
build=${AUTOBUILD_BUILD_ID:=0}
case "$AUTOBUILD_PLATFORM" in
windows*)
load_vsvars
# This is a windows path to the directory where Chromium/CEF will be built. The
# official build process has some rules about this name - the most important of which
# is that it cannot have spaces and must be "less than 35 chars" - using a sub-directory
# of the $stage directory like we usually do with autobuild does not work - a typical
# TeamCity path that would be used is D:\work\ac945f566d69d0ee\latest\stage\cef3809_64\
# and parts of the Chromium build scripts fail with "Filename too long". Moreover, we place
# the builds in a single cef folder in the root since the branch number will change overtime and the
# TeamCity task to clean up that folder after a build does not know the branch number. This
# way the TeamCity cleanup task can delete the whole \cef folder.
cef_build_dir="\\cef\\$cef_branch_number"_"$AUTOBUILD_ADDRSIZE"
# The location of the distributable files is based on the version but that makes it
# difficult to find so we set the sub-dir directly and pass to automate-git.py
# in the batch file
cef_distrib_subdir="cef_binary_windows$AUTOBUILD_ADDRSIZE"
# mysteriously, builds in TeamCity started failing to execute the main batch file
# in the following line because "Permission denied" - investigating why and am
# going to try explicitly setting the execute permissions using Cygwin chmod
chmod a+x "$top/tools/build.bat"
# This invokes the batch file that builds Chromium/CEF. Replacing batch file commands
# with bash equivalents and moving the code into this file did not work - the Chromium
# build scripts are much too complex to debug or change - plus the batch file is
# useful by itself to make builds without using autobuild
$top/tools/build.bat \
$cef_build_dir \
$AUTOBUILD_ADDRSIZE \
$use_proprietary_codecs \
$cef_branch_number \
$cef_distrib_subdir
# copy over the bits of the build we need to package
mkdir -p "$cef_stage_dir/"
cp -R "$cef_build_dir/chromium_git/chromium/src/cef/binary_distrib/$cef_distrib_subdir/." "$cef_stage_dir/"
# return to the directory above where we built CEF
cd "${cef_stage_dir}"
# Remove files from the raw CEF build that we do not use
rm -rf "tests"
rm -f "Release/cef_sandbox.lib"
# licence file
mkdir -p "${stage}/LICENSES"
cp "${cef_stage_dir}/LICENSE.txt" "$stage/LICENSES/cef.txt"
# populate version_file (after header files are extracted
# to a well specified place that version.cpp can access)
# /EHsc is for 'warning C4530: C++ exception handler used,
# but unwind semantics are not enabled. Specify /EHsc'
cl \
/EHsc \
/Fo"$(cygpath -w "$stage/version.obj")" \
/Fe"$(cygpath -w "$stage/version.exe")" \
/I "$(cygpath -w "$cef_stage_dir/include/")" \
/I "$(cygpath -w "$cef_stage_dir/")" \
"$(cygpath -w "$top/version.cpp")"
"$stage/version.exe" > "$stage/VERSION.txt"
rm "$stage"/version.{obj,exe}
;;
darwin64)
# setup SDKROOT environment variable per CEF automated build instructions for mac
export SDKROOT=$(xcrun -show-sdk-path -sdk macosx)
# the directory where CEF is built. The documentation suggests that on
# Windows at least, this shouldn't be in a subdirectory since the
# complex build process generates enormous path names. This means we
# have a different location per build platform type
cef_build_dir="${stage}/cef_build"
# base directory structure
mkdir -p "$cef_build_dir/code"
mkdir -p "$cef_build_dir/code/automate"
mkdir -p "$cef_build_dir/code/chromium_git"
# Clone the Git repo with the Chromium/CEF build tools
cd "$cef_build_dir/code"
rm -rf depot_tools
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
# Grab the main build script (-k or --insecure to bypass curl failing on team city host)
# Note: using curl here to grab the file directly fails in TeamCity so we must use git
tmp_cef=tmp_cef_git
git clone --depth 1 https://bitbucket.org/chromiumembedded/cef "$tmp_cef"
cp "$tmp_cef/tools/automate/automate-git.py" "$cef_build_dir/code/automate/automate-git.py"
rm -rf "$tmp_cef"
# PATH needs to include the depot tools folder we cloned
export PATH=$cef_build_dir/code/depot_tools:$PATH
# Generally want media codecs enabled but switch them off above if that's not the case
# Note: we use quotation marks around the GN_DEFINES variable otherwise the build scripts
# ignore anything after the first space - maybe a bash limitation?
if [ $use_proprietary_codecs = "1" ]; then
export GN_DEFINES="is_official_build=true proprietary_codecs=true ffmpeg_branding=Chrome"
else
export GN_DEFINES="is_official_build=true"
fi
# create .tar.bz2 format package archives
export CEF_ARCHIVE_FORMAT=tar.bz2
# the location of the distributable files is based on the long, complex CEF/Chromium
# version numbers and that makes it difficult to deduce and find so we invoke the
# automate-git.py option to set the sub-dir ourselves
cef_distrib_subdir_x64="cef_binary_macosx_x64"
# The main build script that does everything and based on command line parameter
# (--client-distrib) also generates the distributable packages just like we used
# to take from Spotify. Note too that unlike the Windows version, we always invoke
# the 64bit command line parameter
cd "$cef_build_dir/code/chromium_git"
# (CEF author mgreenblat asserts this allows for intel build on arm macs)
export CEF_ENABLE_AMD64=1
python3 ../automate/automate-git.py \
--download-dir="$cef_build_dir/code/chromium_git" \
--depot-tools-dir="$cef_build_dir/code/depot_tools" \
--branch="$cef_branch_number" \
--client-distrib \
--force-clean \
--x64-build \
--no-debug-build \
--no-debug-tests \
--no-release-tests \
--with-pgo-profiles \
--no-chromium-history \
--distrib-subdir="$cef_distrib_subdir_x64"
# copy over the bits of the build we need to package
mkdir -p "$cef_stage_dir/x86_64/"
cp -R "$cef_build_dir/code/chromium_git/chromium/src/cef/binary_distrib/$cef_distrib_subdir_x64/"* "$cef_stage_dir/x86_64/"
# (CEF author mgreenblat asserts this allows for arm builds on intel macs)
export CEF_ENABLE_ARM64=1
cef_distrib_subdir_arm64="cef_binary_macosx_arm64"
python3 ../automate/automate-git.py \
--download-dir="$cef_build_dir/code/chromium_git" \
--depot-tools-dir="$cef_build_dir/code/depot_tools" \
--branch="$cef_branch_number" \
--client-distrib \
--force-clean \
--arm64-build \
--no-debug-build \
--no-debug-tests \
--no-release-tests \
--with-pgo-profiles \
--no-chromium-history \
--distrib-subdir="$cef_distrib_subdir_arm64"
# copy over the bits of the build we need to package
mkdir -p "$cef_stage_dir/arm64/"
cp -R "$cef_build_dir/code/chromium_git/chromium/src/cef/binary_distrib/$cef_distrib_subdir_arm64/"* "$cef_stage_dir/arm64/"
# return to the directory above where we built CEF
cd "${cef_stage_dir}"
# Remove files from the raw CEF build that we do not use
rm -rf "x86_64/tests"
rm -f "x86_64/Release/cef_sandbox.a"
rm -rf "arm64/tests"
rm -f "arm64/Release/cef_sandbox.a"
# licence file
mkdir -p "${stage}/LICENSES"
cp "${cef_stage_dir}/x86_64/LICENSE.txt" "$stage/LICENSES/cef.txt"
# write version using original CEF package includes
clang++ \
-I "$cef_stage_dir/x86_64/include/" \
-I "$cef_stage_dir/include" \
-I "$cef_stage_dir/" \
-o "$stage/version" \
"$top/version.cpp"
"$stage/version" > "$stage/VERSION.txt"
;;
linux64)
# the directory where CEF is built. The documentation suggests that on
# Windows at least, this shouldn't be in a subdirectory since the
# complex build process generates enormous path names. This means we
# have a different location per build platform type
cef_build_dir="${stage}/cef_build"
# base directory structure
mkdir -p "$cef_build_dir/code"
mkdir -p "$cef_build_dir/code/automate"
mkdir -p "$cef_build_dir/code/chromium_git"
# Clone the Git repo with the Chromium/CEF build tools
cd "$cef_build_dir/code"
rm -rf depot_tools
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
# Grab the main build script (-k or --insecure to bypass curl failing on team city host)
# Note: using curl here to grab the file directly fails in TeamCity so we must use git
tmp_cef=tmp_cef_git
git clone --depth 1 https://bitbucket.org/chromiumembedded/cef "$tmp_cef"
cp "$tmp_cef/tools/automate/automate-git.py" "$cef_build_dir/code/automate/automate-git.py"
rm -rf "$tmp_cef"
# PATH needs to include the depot tools folder we cloned
export PATH=$cef_build_dir/code/depot_tools:$PATH
# Generally want media codecs enabled but switch them off above if that's not the case
# Note: we use quotation marks around the GN_DEFINES variable otherwise the build scripts
# ignore anything after the first space - maybe a bash limitation?
if [ $use_proprietary_codecs = "1" ]; then
export GN_DEFINES="is_official_build=true use_sysroot=true symbol_level=1 is_cfi=false proprietary_codecs=true ffmpeg_branding=Chrome"
else
export GN_DEFINES="is_official_build=true use_sysroot=true symbol_level=1 is_cfi=false"
fi
# create .tar.bz2 format package archives
export CEF_ARCHIVE_FORMAT=tar.bz2
# the location of the distributable files is based on the long, complex CEF/Chromium
# version numbers and that makes it difficult to deduce and find so we invoke the
# automate-git.py option to set the sub-dir ourselves
cef_distrib_subdir="cef_binary_linux64"
# The main build script that does everything and based on command line parameter
# (--client-distrib) also generates the distributable packages just like we used
# to take from Spotify. Note too that unlike the Windows version, we always invoke
# the 64bit command line parameter. Moreover, note that we never invoke the option
# to turn off debug builds since doing so produces a build result that is not
# compatible with autobuild and packages that consume it downstream.
cd "$cef_build_dir/code/chromium_git"
python3 ../automate/automate-git.py \
--download-dir="$cef_build_dir/code/chromium_git" \
--depot-tools-dir="$cef_build_dir/code/depot_tools" \
--branch="$cef_branch_number" \
--client-distrib \
--build-target=cefsimple \
--force-clean \
--no-chromium-history \
--x64-build \
--no-debug-build \
--no-debug-tests \
--no-release-tests \
--with-pgo-profiles \
--distrib-subdir="$cef_distrib_subdir"
# copy over the bits of the build we need to package
cp -a "$cef_build_dir/code/chromium_git/chromium/src/cef/binary_distrib/$cef_distrib_subdir/" "$cef_stage_dir/"
# return to the directory above where we built CEF
cd "${cef_stage_dir}"
# licence file
mkdir -p "${stage}/LICENSES"
cp "${cef_stage_dir}/LICENSE.txt" "$stage/LICENSES/cef.txt"
# write version using original CEF package includes
g++ \
-I "$cef_stage_dir/include" \
-I "$cef_stage_dir/" \
-o "$stage/version" \
"$top/version.cpp"
"$stage/version" > "$stage/VERSION.txt"
esac