Skip to content

Commit

Permalink
devops: introduce goma infrastructure for Chromium builds (#5377)
Browse files Browse the repository at this point in the history
This patch adds `//browser_patches/chromium/goma.sh` script that
manages goma to build chromium.
  • Loading branch information
aslushnikov committed Feb 9, 2021
1 parent 0871a9c commit ad557dc
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 7 deletions.
1 change: 1 addition & 0 deletions browser_patches/chromium/.gitignore
@@ -1,2 +1,3 @@
/output
/depot_tools
/electron-build-tools
31 changes: 24 additions & 7 deletions browser_patches/chromium/build.sh
Expand Up @@ -6,7 +6,7 @@ trap "cd $(pwd -P)" EXIT
cd "$(dirname $0)"

USAGE=$(cat<<EOF
usage: $(basename $0) [--mirror|--mirror-linux|--mirror-win32|--mirror-win64|--mirror-mac|--compile-mac-arm64]
usage: $(basename $0) [--mirror|--mirror-linux|--mirror-win32|--mirror-win64|--mirror-mac|--compile-mac-arm64|--compile-linux|--compile-win32|--compile-win64|--compile-mac]
Either compiles chromium or mirrors it from Chromium Continuous Builds CDN.
EOF
Expand Down Expand Up @@ -121,6 +121,9 @@ compile_chromium() {
"swiftshader"
"v8_context_snapshot.bin"
)
else
echo "ERROR: unknown command, use --help for details"
exit 1
fi

# Get chromium SHA from the build revision.
Expand Down Expand Up @@ -163,15 +166,29 @@ EOF
echo 'target_cpu = "x86"' >> ./out/Default/args.gn
fi
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-win"* ]]; then
/c/Windows/System32/cmd.exe "/c $(cygpath -w ${SCRIPT_PATH}/buildwin.bat)"
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
autoninja -C out/Default chrome
fi
if [[ $1 == "--compile-linux" ]]; then
autoninja -C out/Default chrome_sandbox clear_key_cdm
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.
Expand Down
2 changes: 2 additions & 0 deletions browser_patches/chromium/buildwingoma.bat
@@ -0,0 +1,2 @@
CALL gn gen out/Default
CALL ninja -j 200 -C out/Default chrome
41 changes: 41 additions & 0 deletions 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

0 comments on commit ad557dc

Please sign in to comment.