#!/bin/bash set -e set +x trap "cd $(pwd -P)" EXIT cd "$(dirname $0)" USAGE=$(cat<./out/Default/args.gn is_debug = false symbol_level = 0 EOF if [[ $1 == "--compile-mac-arm64" ]]; then echo 'target_cpu = "arm64"' >> ./out/Default/args.gn elif [[ $1 == "--compile-win32" ]]; then echo 'target_cpu = "x86"' >> ./out/Default/args.gn fi if [[ ! -z "$USE_GOMA" ]]; then PLAYWRIGHT_GOMA_PATH="${SCRIPT_PATH}/electron-build-tools/third_party/goma" if [[ $1 == "--compile-win"* ]]; then PLAYWRIGHT_GOMA_PATH=$(cygpath -w "${PLAYWRIGHT_GOMA_PATH}") fi echo 'use_goma = true' >> ./out/Default/args.gn echo "goma_dir = \"${PLAYWRIGHT_GOMA_PATH}\"" >> ./out/Default/args.gn fi if [[ $1 == "--compile-win"* ]]; then if [[ -z "$USE_GOMA" ]]; then /c/Windows/System32/cmd.exe "/c $(cygpath -w ${SCRIPT_PATH}/buildwin.bat)" else /c/Windows/System32/cmd.exe "/c $(cygpath -w ${SCRIPT_PATH}/buildwingoma.bat)" fi else gn gen out/Default 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 fi } mirror_chromium() { cd "$SCRIPT_PATH" 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 CRREV=$(head -1 "${SCRIPT_PATH}/BUILD_NUMBER") 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" else echo "ERROR: unknown platform to build: $1" exit 1 fi echo "--> Pulling Chromium ${CRREV} for ${PLATFORM#--}" curl --output chromium-upstream.zip "${CHROMIUM_URL}" unzip chromium-upstream.zip } main $1