From ad557dc6da3ddd3cb02869c2378fba4322a73d3d Mon Sep 17 00:00:00 2001 From: Andrey Lushnikov Date: Tue, 9 Feb 2021 08:33:39 -0800 Subject: [PATCH] devops: introduce goma infrastructure for Chromium builds (#5377) This patch adds `//browser_patches/chromium/goma.sh` script that manages goma to build chromium. --- browser_patches/chromium/.gitignore | 1 + browser_patches/chromium/build.sh | 33 +++++++++++++----- browser_patches/chromium/buildwingoma.bat | 2 ++ browser_patches/chromium/goma.sh | 41 +++++++++++++++++++++++ 4 files changed, 69 insertions(+), 8 deletions(-) create mode 100644 browser_patches/chromium/buildwingoma.bat create mode 100755 browser_patches/chromium/goma.sh diff --git a/browser_patches/chromium/.gitignore b/browser_patches/chromium/.gitignore index 23b33df7f1..2658404cd7 100644 --- a/browser_patches/chromium/.gitignore +++ b/browser_patches/chromium/.gitignore @@ -1,2 +1,3 @@ /output /depot_tools +/electron-build-tools diff --git a/browser_patches/chromium/build.sh b/browser_patches/chromium/build.sh index fdc43569e8..306d668f1a 100755 --- a/browser_patches/chromium/build.sh +++ b/browser_patches/chromium/build.sh @@ -6,7 +6,7 @@ trap "cd $(pwd -P)" EXIT cd "$(dirname $0)" USAGE=$(cat<> ./out/Default/args.gn fi - if [[ $1 == "--compile-win"* ]]; then - /c/Windows/System32/cmd.exe "/c $(cygpath -w ${SCRIPT_PATH}/buildwin.bat)" - else - gn gen out/Default - autoninja -C out/Default chrome + if [[ ! -z "$USE_GOMA" ]]; then + echo 'use_goma = true' >> ./out/Default/args.gn + echo "goma_dir = '${SCRIPT_PATH}/electron-build-tools/third_party/goma'" >> ./out/Default/args.gn fi - if [[ $1 == "--compile-linux" ]]; then - autoninja -C out/Default chrome_sandbox clear_key_cdm + 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 # Prepare resulting archive. diff --git a/browser_patches/chromium/buildwingoma.bat b/browser_patches/chromium/buildwingoma.bat new file mode 100644 index 0000000000..2ae3174fc9 --- /dev/null +++ b/browser_patches/chromium/buildwingoma.bat @@ -0,0 +1,2 @@ +CALL gn gen out/Default +CALL ninja -j 200 -C out/Default chrome diff --git a/browser_patches/chromium/goma.sh b/browser_patches/chromium/goma.sh new file mode 100755 index 0000000000..970abb96fc --- /dev/null +++ b/browser_patches/chromium/goma.sh @@ -0,0 +1,41 @@ +#!/bin/bash +set -e +set +x + +trap "cd $(pwd -P)" EXIT +cd "$(dirname $0)" + +if [[ ! -d ./electron-build-tools ]]; then + git clone --single-branch --branch msft-goma https://github.com/electron/build-tools/ electron-build-tools + cd electron-build-tools + npm install + mkdir -p third_party + ./src/e update-goma msftGoma + cd .. +fi + +cd electron-build-tools + +if [[ $1 == "--help" ]]; then + echo "$(basename $0) [login|start|stop|--help]" + exit 0 +elif [[ $1 == "login" ]]; then + python ./third_party/goma/goma_auth.py login +elif [[ $1 == "start" ]]; then + if [[ ! -z "$GOMA_LOGIN_COOKIE" ]]; then + echo "$GOMA_LOGIN_COOKIE" > "$HOME/.goma_oauth2_config" + fi + if [[ ! -f "$HOME/.goma_oauth2_config" ]]; then + echo "ERROR: goma is not logged in!" + echo "run '$(basename $0) login'" + exit 1 + fi + python ./third_party/goma/goma_ctl.py ensure_start +elif [[ $1 == "stop" ]]; then + python ./third_party/goma/goma_ctl.py stop +else + echo "ERROR: unknown command - $1" + echo "Use --help to list all available commands" + exit 1 +fi +