Skip to content

Commit 8c18b90

Browse files
authored
devops: refactor chromium automation scripts (#5486)
Split preparing checkout, archiving and compiling into separate scripts similarly how we do it with other browsers.
1 parent b2227c1 commit 8c18b90

File tree

4 files changed

+249
-161
lines changed

4 files changed

+249
-161
lines changed

browser_patches/checkout_build_archive_upload.sh

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,25 @@ fi
3333

3434
BROWSER_NAME=""
3535
EXTRA_BUILD_ARGS=""
36+
EXTRA_ARCHIVE_ARGS=""
3637
BUILD_FLAVOR="$1"
3738
BUILD_BLOB_NAME=""
3839
EXPECTED_HOST_OS=""
3940
EXPECTED_HOST_OS_VERSION=""
4041
EXPECTED_ARCH="x86_64"
42+
43+
# ===========================
44+
# WINLDD COMPILATION
45+
# ===========================
4146
if [[ "$BUILD_FLAVOR" == "winldd-win64" ]]; then
4247
BROWSER_NAME="winldd"
4348
EXPECTED_HOST_OS="MINGW"
4449
BUILD_BLOB_NAME="winldd-win64.zip"
50+
51+
52+
# ===========================
53+
# FFMPEG COMPILATION
54+
# ===========================
4555
elif [[ "$BUILD_FLAVOR" == "ffmpeg-mac" ]]; then
4656
BROWSER_NAME="ffmpeg"
4757
EXTRA_BUILD_ARGS="--mac"
@@ -66,58 +76,81 @@ elif [[ "$BUILD_FLAVOR" == "ffmpeg-cross-compile-win64" ]]; then
6676
EXPECTED_HOST_OS="Ubuntu"
6777
EXPECTED_HOST_OS_VERSION="20.04"
6878
BUILD_BLOB_NAME="ffmpeg-win64.zip"
79+
80+
# ===========================
81+
# CHROMIUM COMPILATION
82+
# ===========================
6983
elif [[ "$BUILD_FLAVOR" == "chromium-win32" ]]; then
7084
BROWSER_NAME="chromium"
7185
EXTRA_BUILD_ARGS="--compile-win32"
86+
EXTRA_ARCHIVE_ARGS="--compile-win32"
7287
EXPECTED_HOST_OS="MINGW"
7388
BUILD_BLOB_NAME="chromium-win32.zip"
7489
elif [[ "$BUILD_FLAVOR" == "chromium-win64" ]]; then
7590
BROWSER_NAME="chromium"
7691
EXTRA_BUILD_ARGS="--compile-win64"
92+
EXTRA_ARCHIVE_ARGS="--compile-win64"
7793
EXPECTED_HOST_OS="MINGW"
7894
BUILD_BLOB_NAME="chromium-win64.zip"
7995
elif [[ "$BUILD_FLAVOR" == "chromium-mac" ]]; then
8096
BROWSER_NAME="chromium"
8197
EXTRA_BUILD_ARGS="--compile-mac"
98+
EXTRA_ARCHIVE_ARGS="--compile-mac"
8299
EXPECTED_HOST_OS="Darwin"
83100
EXPECTED_HOST_OS_VERSION="10.15"
84101
BUILD_BLOB_NAME="chromium-mac.zip"
85102
elif [[ "$BUILD_FLAVOR" == "chromium-mac-arm64" ]]; then
86103
BROWSER_NAME="chromium"
87104
EXTRA_BUILD_ARGS="--compile-mac-arm64"
105+
EXTRA_ARCHIVE_ARGS="--compile-mac-arm64"
88106
EXPECTED_HOST_OS="Darwin"
89107
EXPECTED_HOST_OS_VERSION="10.15"
90108
BUILD_BLOB_NAME="chromium-mac-arm64.zip"
91109
elif [[ "$BUILD_FLAVOR" == "chromium-linux" ]]; then
92110
BROWSER_NAME="chromium"
93111
EXTRA_BUILD_ARGS="--compile-linux"
112+
EXTRA_ARCHIVE_ARGS="--compile-linux"
94113
EXPECTED_HOST_OS="Ubuntu"
95114
EXPECTED_HOST_OS_VERSION="18.04"
96115
BUILD_BLOB_NAME="chromium-linux.zip"
116+
117+
118+
# ===========================
119+
# CHROMIUM MIRRORING
120+
# ===========================
97121
elif [[ "$BUILD_FLAVOR" == "chromium-linux-mirror-to-cdn" ]]; then
98122
BROWSER_NAME="chromium"
99123
EXTRA_BUILD_ARGS="--mirror-linux"
124+
EXTRA_ARCHIVE_ARGS="--mirror-linux"
100125
EXPECTED_HOST_OS="Ubuntu"
101126
EXPECTED_HOST_OS_VERSION="18.04"
102127
BUILD_BLOB_NAME="chromium-linux.zip"
103128
elif [[ "$BUILD_FLAVOR" == "chromium-mac-mirror-to-cdn" ]]; then
104129
BROWSER_NAME="chromium"
105130
EXTRA_BUILD_ARGS="--mirror-mac"
131+
EXTRA_ARCHIVE_ARGS="--mirror-mac"
106132
EXPECTED_HOST_OS="Ubuntu"
107133
EXPECTED_HOST_OS_VERSION="18.04"
108134
BUILD_BLOB_NAME="chromium-mac.zip"
109135
elif [[ "$BUILD_FLAVOR" == "chromium-win32-mirror-to-cdn" ]]; then
110136
BROWSER_NAME="chromium"
111137
EXTRA_BUILD_ARGS="--mirror-win32"
138+
EXTRA_ARCHIVE_ARGS="--mirror-win32"
112139
EXPECTED_HOST_OS="Ubuntu"
113140
EXPECTED_HOST_OS_VERSION="18.04"
114141
BUILD_BLOB_NAME="chromium-win32.zip"
115142
elif [[ "$BUILD_FLAVOR" == "chromium-win64-mirror-to-cdn" ]]; then
116143
BROWSER_NAME="chromium"
117144
EXTRA_BUILD_ARGS="--mirror-win64"
145+
EXTRA_ARCHIVE_ARGS="--mirror-win64"
118146
EXPECTED_HOST_OS="Ubuntu"
119147
EXPECTED_HOST_OS_VERSION="18.04"
120148
BUILD_BLOB_NAME="chromium-win64.zip"
149+
150+
151+
# ===========================
152+
# FIREFOX COMPILATION
153+
# ===========================
121154
elif [[ "$BUILD_FLAVOR" == "firefox-ubuntu-18.04" ]]; then
122155
BROWSER_NAME="firefox"
123156
EXTRA_BUILD_ARGS="--full"
@@ -146,6 +179,11 @@ elif [[ "$BUILD_FLAVOR" == "firefox-win64" ]]; then
146179
EXTRA_BUILD_ARGS="--win64"
147180
EXPECTED_HOST_OS="MINGW"
148181
BUILD_BLOB_NAME="firefox-win64.zip"
182+
183+
184+
# ===========================
185+
# WEBKIT COMPILATION
186+
# ===========================
149187
elif [[ "$BUILD_FLAVOR" == "webkit-ubuntu-18.04" ]]; then
150188
BROWSER_NAME="webkit"
151189
EXTRA_BUILD_ARGS="--full"
@@ -255,7 +293,7 @@ function generate_and_upload_browser_build {
255293
fi
256294

257295
echo "-- archiving to $ZIP_PATH"
258-
if ! ./$BROWSER_NAME/archive.sh $ZIP_PATH; then
296+
if ! ./$BROWSER_NAME/archive.sh $ZIP_PATH "$EXTRA_ARCHIVE_ARGS"; then
259297
return 23
260298
fi
261299

browser_patches/chromium/archive.sh

Lines changed: 164 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,170 @@
22
set -e
33
set +x
44

5-
if [[ ("$1" == "-h") || ("$1" == "--help") ]]; then
6-
echo "usage: $(basename $0) [output-absolute-path]"
7-
echo
8-
echo "Generate distributable .zip archive from ./output folder that was previously downloaded."
9-
echo
10-
exit 0
11-
fi
12-
13-
ZIP_PATH=$1
14-
if [[ $ZIP_PATH != /* ]]; then
15-
echo "ERROR: path $ZIP_PATH is not absolute"
16-
exit 1
17-
fi
18-
if [[ $ZIP_PATH != *.zip ]]; then
19-
echo "ERROR: path $ZIP_PATH must have .zip extension"
20-
exit 1
21-
fi
22-
if [[ -f $ZIP_PATH ]]; then
23-
echo "ERROR: path $ZIP_PATH exists; can't do anything."
24-
exit 1
25-
fi
26-
if ! [[ -d $(dirname $ZIP_PATH) ]]; then
27-
echo "ERROR: folder for path $($ZIP_PATH) does not exist."
28-
exit 1
29-
fi
30-
315
trap "cd $(pwd -P)" EXIT
326
cd "$(dirname $0)"
7+
SCRIPT_PATH=$(pwd -P)
8+
9+
main() {
10+
if [[ ("$1" == "-h") || ("$1" == "--help") ]]; then
11+
echo "usage: $(basename $0) [output-absolute-path]"
12+
echo
13+
echo "Generate distributable .zip archive from ./output folder that was previously downloaded."
14+
echo
15+
exit 0
16+
fi
17+
18+
ZIP_PATH=$1
19+
20+
if [[ $ZIP_PATH != /* ]]; then
21+
echo "ERROR: path $ZIP_PATH is not absolute"
22+
exit 1
23+
fi
24+
if [[ $ZIP_PATH != *.zip ]]; then
25+
echo "ERROR: path $ZIP_PATH must have .zip extension"
26+
exit 1
27+
fi
28+
if [[ -f $ZIP_PATH ]]; then
29+
echo "ERROR: path $ZIP_PATH exists; can't do anything."
30+
exit 1
31+
fi
32+
if ! [[ -d $(dirname $ZIP_PATH) ]]; then
33+
echo "ERROR: folder for path $($ZIP_PATH) does not exist."
34+
exit 1
35+
fi
36+
37+
BUILD_TYPE=$2
38+
if [[ "${BUILD_TYPE}" == "--compile"* ]]; then
39+
archive_compiled_chromium "${BUILD_TYPE}"
40+
elif [[ "${BUILD_TYPE}" == "--mirror"* ]]; then
41+
archive_mirrored_chromium "${BUILD_TYPE}"
42+
else
43+
echo "ERROR: unknown build type - ${BUILD_TYPE}"
44+
exit 1
45+
fi
46+
47+
cd "${SCRIPT_PATH}"
48+
cp output/build.zip $ZIP_PATH
49+
}
50+
51+
function archive_compiled_chromium() {
52+
CHROMIUM_FOLDER_NAME=""
53+
CHROMIUM_FILES_TO_ARCHIVE=()
54+
55+
if [[ $1 == "--compile-mac"* ]]; then
56+
CHROMIUM_FOLDER_NAME="chrome-mac"
57+
CHROMIUM_FILES_TO_ARCHIVE=("Chromium.app")
58+
elif [[ $1 == "--compile-linux" ]]; then
59+
CHROMIUM_FOLDER_NAME="chrome-linux"
60+
CHROMIUM_FILES_TO_ARCHIVE=(
61+
"chrome"
62+
"chrome_100_percent.pak"
63+
"chrome_200_percent.pak"
64+
"chrome_sandbox"
65+
"chrome-wrapper"
66+
"ClearKeyCdm"
67+
"crashpad_handler"
68+
"icudtl.dat"
69+
"libEGL.so"
70+
"libGLESv2.so"
71+
"locales"
72+
"MEIPreload"
73+
"nacl_helper"
74+
"nacl_helper_bootstrap"
75+
"nacl_helper_nonsfi"
76+
"nacl_irt_x86_64.nexe"
77+
"product_logo_48.png"
78+
"resources"
79+
"resources.pak"
80+
"swiftshader"
81+
"v8_context_snapshot.bin"
82+
"xdg-mime"
83+
"xdg-settings"
84+
)
85+
elif [[ $1 == "--compile-win"* ]]; then
86+
CHROMIUM_FOLDER_NAME="chrome-win"
87+
CHROMIUM_FILES_TO_ARCHIVE=(
88+
"chrome.dll"
89+
"chrome.exe"
90+
"chrome_100_percent.pak"
91+
"chrome_200_percent.pak"
92+
"chrome_elf.dll"
93+
"chrome_proxy.exe"
94+
"chrome_pwa_launcher.exe"
95+
"D3DCompiler_47.dll"
96+
"elevation_service.exe"
97+
"eventlog_provider.dll"
98+
"First Run"
99+
"icudtl.dat"
100+
"libEGL.dll"
101+
"libGLESv2.dll"
102+
"locales"
103+
"MEIPreload"
104+
"mojo_core.dll"
105+
"nacl_irt_x86_64.nexe"
106+
"notification_helper.exe"
107+
"resources.pak"
108+
"swiftshader/libEGL.dll"
109+
"swiftshader/libGLESv2.dll"
110+
"v8_context_snapshot.bin"
111+
)
112+
else
113+
echo "ERROR: unknown command, use --help for details"
114+
exit 1
115+
fi
116+
117+
# Prepare resulting archive.
118+
cd "$SCRIPT_PATH"
119+
rm -rf output
120+
mkdir -p "output/${CHROMIUM_FOLDER_NAME}"
121+
122+
# On Mac, use 'ditto' to copy directories instead of 'cp'.
123+
COPY_COMMAND="cp -R"
124+
if [[ $(uname) == "Darwin" ]]; then
125+
COPY_COMMAND="ditto"
126+
fi
127+
128+
for ((i = 0; i < ${#CHROMIUM_FILES_TO_ARCHIVE[@]}; i++)) do
129+
file="${CHROMIUM_FILES_TO_ARCHIVE[$i]}"
130+
mkdir -p "output/${CHROMIUM_FOLDER_NAME}/$(dirname $file)"
131+
$COPY_COMMAND "${CR_CHECKOUT_PATH}/src/out/Default/${file}" "output/${CHROMIUM_FOLDER_NAME}/${file}"
132+
done
133+
134+
if [[ $1 == "--compile-win"* ]]; then
135+
$COPY_COMMAND "${CR_CHECKOUT_PATH}/src/out/Default/"*.manifest "output/${CHROMIUM_FOLDER_NAME}/"
136+
fi
137+
138+
cd output
139+
zip --symlinks -r build.zip "${CHROMIUM_FOLDER_NAME}"
140+
}
141+
142+
archive_mirrored_chromium() {
143+
cd "${SCRIPT_PATH}/output"
144+
145+
CHROMIUM_FOLDER_NAME=""
146+
CHROMIUM_FILES_TO_REMOVE=()
147+
148+
PLATFORM="$1"
149+
if [[ "${PLATFORM}" == "--mirror-win32" ]]; then
150+
CHROMIUM_FOLDER_NAME="chrome-win"
151+
CHROMIUM_FILES_TO_REMOVE+=("chrome-win/interactive_ui_tests.exe")
152+
elif [[ "${PLATFORM}" == "--mirror-win64" ]]; then
153+
CHROMIUM_FOLDER_NAME="chrome-win"
154+
CHROMIUM_FILES_TO_REMOVE+=("chrome-win/interactive_ui_tests.exe")
155+
elif [[ "${PLATFORM}" == "--mirror-mac" ]]; then
156+
CHROMIUM_FOLDER_NAME="chrome-mac"
157+
elif [[ "${PLATFORM}" == "--mirror-linux" ]]; then
158+
CHROMIUM_FOLDER_NAME="chrome-linux"
159+
else
160+
echo "ERROR: unknown platform to build: $PLATFORM"
161+
exit 1
162+
fi
163+
164+
for file in ${CHROMIUM_FILES_TO_REMOVE[@]}; do
165+
rm -f "${file}"
166+
done
167+
168+
zip --symlinks -r build.zip "${CHROMIUM_FOLDER_NAME}"
169+
}
33170

34-
cp output/build.zip $ZIP_PATH
171+
main "$@"

0 commit comments

Comments
 (0)