2020-08-08 02:22:05 +03:00
|
|
|
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
set +x
|
|
|
|
|
|
|
|
trap "cd $(pwd -P)" EXIT
|
2021-08-07 15:32:18 +03:00
|
|
|
cd "$(dirname "$0")"
|
2020-08-08 02:22:05 +03:00
|
|
|
|
2021-01-22 11:27:40 +03:00
|
|
|
USAGE=$(cat<<EOF
|
2021-08-07 15:32:18 +03:00
|
|
|
usage: $(basename "$0") [--mirror|--mirror-linux|--mirror-win32|--mirror-win64|--mirror-mac|--compile-mac-arm64|--compile-linux|--compile-win32|--compile-win64|--compile-mac]
|
2021-01-22 11:27:40 +03:00
|
|
|
|
|
|
|
Either compiles chromium or mirrors it from Chromium Continuous Builds CDN.
|
|
|
|
EOF
|
|
|
|
)
|
|
|
|
|
2021-07-16 12:36:49 +03:00
|
|
|
SCRIPT_FOLDER=$(pwd -P)
|
2021-07-14 04:12:53 +03:00
|
|
|
source "${SCRIPT_FOLDER}/../utils.sh"
|
2021-01-22 11:27:40 +03:00
|
|
|
|
|
|
|
main() {
|
|
|
|
if [[ $1 == "--help" || $1 == "-h" ]]; then
|
|
|
|
echo "$USAGE"
|
|
|
|
exit 0
|
|
|
|
elif [[ $1 == "--mirror"* ]]; then
|
2021-08-07 15:32:18 +03:00
|
|
|
mirror_chromium "$1"
|
2021-01-22 11:27:40 +03:00
|
|
|
elif [[ $1 == "--compile"* ]]; then
|
2021-08-07 15:32:18 +03:00
|
|
|
compile_chromium "$1"
|
2021-01-22 11:27:40 +03:00
|
|
|
else
|
|
|
|
echo "ERROR: unknown first argument. Use --help for details."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2021-02-12 12:21:39 +03:00
|
|
|
|
2021-01-22 11:27:40 +03:00
|
|
|
compile_chromium() {
|
|
|
|
if [[ -z "${CR_CHECKOUT_PATH}" ]]; then
|
|
|
|
echo "ERROR: chromium compilation requires CR_CHECKOUT_PATH to be set to reuse checkout."
|
|
|
|
exit 1
|
|
|
|
fi
|
2021-01-28 12:43:54 +03:00
|
|
|
|
2021-02-18 01:43:19 +03:00
|
|
|
if [[ -z "${CR_CHECKOUT_PATH}/src" ]]; then
|
|
|
|
echo "ERROR: CR_CHECKOUT_PATH does not have src/ subfolder; is this a chromium checkout?"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2021-07-16 12:36:49 +03:00
|
|
|
source "${SCRIPT_FOLDER}/ensure_depot_tools.sh"
|
2021-01-22 11:27:40 +03:00
|
|
|
|
2021-02-18 01:43:19 +03:00
|
|
|
if [[ $1 == "--compile-mac"* ]]; then
|
2021-01-22 11:27:40 +03:00
|
|
|
# As of Jan, 2021 Chromium mac compilation requires Xcode12.2
|
2021-07-14 04:12:53 +03:00
|
|
|
selectXcodeVersionOrDie "12.2"
|
2021-01-22 11:27:40 +03:00
|
|
|
# As of Jan, 2021 Chromium mac compilation is only possible on Intel macbooks.
|
|
|
|
# See https://chromium.googlesource.com/chromium/src.git/+/master/docs/mac_arm64.md
|
2021-02-18 01:43:19 +03:00
|
|
|
if [[ $1 == "--compile-mac-arm64" && $(uname -m) != "x86_64" ]]; then
|
2021-01-22 11:27:40 +03:00
|
|
|
echo "ERROR: chromium mac arm64 compilation is (ironically) only supported on Intel Macbooks"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
cd "${CR_CHECKOUT_PATH}/src"
|
|
|
|
|
|
|
|
# Prepare build folder.
|
|
|
|
mkdir -p "./out/Default"
|
2021-06-15 11:18:00 +03:00
|
|
|
echo "is_debug = false" > ./out/Default/args.gn
|
2021-08-07 15:41:13 +03:00
|
|
|
echo "dcheck_always_on = false" >> ./out/Default/args.gn
|
2021-06-15 11:18:00 +03:00
|
|
|
if [[ $2 == "--symbols" ]]; then
|
|
|
|
echo "symbol_level = 1" >> ./out/Default/args.gn
|
|
|
|
else
|
|
|
|
echo "symbol_level = 0" >> ./out/Default/args.gn
|
|
|
|
fi
|
2021-01-22 11:27:40 +03:00
|
|
|
|
|
|
|
if [[ $1 == "--compile-mac-arm64" ]]; then
|
|
|
|
echo 'target_cpu = "arm64"' >> ./out/Default/args.gn
|
2021-02-08 10:54:10 +03:00
|
|
|
elif [[ $1 == "--compile-win32" ]]; then
|
|
|
|
echo 'target_cpu = "x86"' >> ./out/Default/args.gn
|
2021-01-22 11:27:40 +03:00
|
|
|
fi
|
|
|
|
|
2021-02-09 19:33:39 +03:00
|
|
|
if [[ ! -z "$USE_GOMA" ]]; then
|
2021-07-16 12:36:49 +03:00
|
|
|
PLAYWRIGHT_GOMA_PATH="${SCRIPT_FOLDER}/electron-build-tools/third_party/goma"
|
2021-02-09 20:06:50 +03:00
|
|
|
if [[ $1 == "--compile-win"* ]]; then
|
|
|
|
PLAYWRIGHT_GOMA_PATH=$(cygpath -w "${PLAYWRIGHT_GOMA_PATH}")
|
|
|
|
fi
|
2021-02-09 19:33:39 +03:00
|
|
|
echo 'use_goma = true' >> ./out/Default/args.gn
|
2021-02-09 20:11:03 +03:00
|
|
|
echo "goma_dir = \"${PLAYWRIGHT_GOMA_PATH}\"" >> ./out/Default/args.gn
|
2021-02-09 19:33:39 +03:00
|
|
|
fi
|
|
|
|
|
2021-02-08 10:54:10 +03:00
|
|
|
if [[ $1 == "--compile-win"* ]]; then
|
2021-02-09 19:33:39 +03:00
|
|
|
if [[ -z "$USE_GOMA" ]]; then
|
2021-08-07 15:32:18 +03:00
|
|
|
/c/Windows/System32/cmd.exe "/c $(cygpath -w "${SCRIPT_FOLDER}"/buildwin.bat)"
|
2021-02-09 19:33:39 +03:00
|
|
|
else
|
2021-08-07 15:32:18 +03:00
|
|
|
/c/Windows/System32/cmd.exe "/c $(cygpath -w "${SCRIPT_FOLDER}"/buildwingoma.bat)"
|
2021-02-09 19:33:39 +03:00
|
|
|
fi
|
2021-02-08 10:54:10 +03:00
|
|
|
else
|
|
|
|
gn gen out/Default
|
2021-02-09 19:33:39 +03:00
|
|
|
if [[ $1 == "--compile-linux" ]]; then
|
|
|
|
TARGETS="chrome chrome_sandbox clear_key_cdm"
|
|
|
|
else
|
|
|
|
TARGETS="chrome"
|
|
|
|
fi
|
|
|
|
if [[ -z "$USE_GOMA" ]]; then
|
|
|
|
autoninja -C out/Default $TARGETS
|
|
|
|
else
|
|
|
|
ninja -j 200 -C out/Default $TARGETS
|
|
|
|
fi
|
2021-02-03 17:35:29 +03:00
|
|
|
fi
|
2021-01-22 11:27:40 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
mirror_chromium() {
|
2021-07-16 12:36:49 +03:00
|
|
|
cd "$SCRIPT_FOLDER"
|
2021-01-22 11:27:40 +03:00
|
|
|
rm -rf output
|
|
|
|
mkdir -p output
|
|
|
|
cd output
|
|
|
|
|
|
|
|
CHROMIUM_URL=""
|
|
|
|
|
|
|
|
PLATFORM="$1"
|
|
|
|
if [[ "${PLATFORM}" == "--mirror" ]]; then
|
|
|
|
CURRENT_HOST_OS="$(uname)"
|
|
|
|
if [[ "${CURRENT_HOST_OS}" == "Darwin" ]]; then
|
|
|
|
PLATFORM="--mirror-mac"
|
|
|
|
elif [[ "${CURRENT_HOST_OS}" == "Linux" ]]; then
|
|
|
|
PLATFORM="--mirror-linux"
|
|
|
|
elif [[ "${CURRENT_HOST_OS}" == MINGW* ]]; then
|
|
|
|
PLATFORM="--mirror-win64"
|
|
|
|
else
|
|
|
|
echo "ERROR: unsupported host platform - ${CURRENT_HOST_OS}"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2021-07-16 12:36:49 +03:00
|
|
|
CRREV=$(head -1 "${SCRIPT_FOLDER}/BUILD_NUMBER")
|
2021-01-22 11:27:40 +03:00
|
|
|
if [[ "${PLATFORM}" == "--mirror-win32" ]]; then
|
|
|
|
CHROMIUM_URL="https://storage.googleapis.com/chromium-browser-snapshots/Win/${CRREV}/chrome-win.zip"
|
|
|
|
elif [[ "${PLATFORM}" == "--mirror-win64" ]]; then
|
|
|
|
CHROMIUM_URL="https://storage.googleapis.com/chromium-browser-snapshots/Win_x64/${CRREV}/chrome-win.zip"
|
|
|
|
elif [[ "${PLATFORM}" == "--mirror-mac" ]]; then
|
|
|
|
CHROMIUM_URL="https://storage.googleapis.com/chromium-browser-snapshots/Mac/${CRREV}/chrome-mac.zip"
|
|
|
|
elif [[ "${PLATFORM}" == "--mirror-linux" ]]; then
|
|
|
|
CHROMIUM_URL="https://storage.googleapis.com/chromium-browser-snapshots/Linux_x64/${CRREV}/chrome-linux.zip"
|
2020-09-04 14:23:13 +03:00
|
|
|
else
|
2021-01-22 11:27:40 +03:00
|
|
|
echo "ERROR: unknown platform to build: $1"
|
2020-09-04 14:23:13 +03:00
|
|
|
exit 1
|
|
|
|
fi
|
2021-01-22 11:27:40 +03:00
|
|
|
|
|
|
|
echo "--> Pulling Chromium ${CRREV} for ${PLATFORM#--}"
|
|
|
|
|
|
|
|
curl --output chromium-upstream.zip "${CHROMIUM_URL}"
|
|
|
|
unzip chromium-upstream.zip
|
|
|
|
}
|
|
|
|
|
2021-08-07 15:32:18 +03:00
|
|
|
main "$1"
|