-
Notifications
You must be signed in to change notification settings - Fork 2
/
build-cmd.sh
206 lines (169 loc) · 8.81 KB
/
build-cmd.sh
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
#!/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 5993 represents Chromium/CEF 118.x
cef_branch_number=5993
# 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 "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)
# 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"
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
# (CEF author mgreenblat asserts this allows for intel build on arm macs)
export CEF_ENABLE_AMD64=1
# 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_macosx"
# 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"
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 \
--x64-build \
--no-debug-build \
--no-debug-tests \
--no-release-tests \
--distrib-subdir="$cef_distrib_subdir" \
--with-pgo-profiles
# copy over the bits of the build we need to package
cp -R "$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}"
# Remove files from the raw CEF build that we do not use
rm -rf "tests"
rm "Release/cef_sandbox.a"
# 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"
;;
linux*)
echo "This project is not currently supported for $AUTOBUILD_PLATFORM" 1>&2 ; exit 1
;;
esac