From f3a5bba2c4ec00432304e58cf961a8d417f280e5 Mon Sep 17 00:00:00 2001 From: Andrey Lushnikov Date: Sun, 7 Feb 2021 23:54:10 -0800 Subject: [PATCH] devops: infra to automate chromium builds (#5347) --- .../checkout_build_archive_upload.sh | 10 ++++ browser_patches/chromium/build.sh | 52 ++++++++++++++++--- browser_patches/chromium/buildwin.bat | 2 + 3 files changed, 58 insertions(+), 6 deletions(-) create mode 100644 browser_patches/chromium/buildwin.bat diff --git a/browser_patches/checkout_build_archive_upload.sh b/browser_patches/checkout_build_archive_upload.sh index 0ed045e59a..4a6eade825 100755 --- a/browser_patches/checkout_build_archive_upload.sh +++ b/browser_patches/checkout_build_archive_upload.sh @@ -66,6 +66,16 @@ elif [[ "$BUILD_FLAVOR" == "ffmpeg-cross-compile-win64" ]]; then EXPECTED_HOST_OS="Ubuntu" EXPECTED_HOST_OS_VERSION="20.04" BUILD_BLOB_NAME="ffmpeg-win64.zip" +elif [[ "$BUILD_FLAVOR" == "chromium-win32" ]]; then + BROWSER_NAME="chromium" + EXTRA_BUILD_ARGS="--compile-win32" + EXPECTED_HOST_OS="MINGW" + BUILD_BLOB_NAME="chromium-win32.zip" +elif [[ "$BUILD_FLAVOR" == "chromium-win64" ]]; then + BROWSER_NAME="chromium" + EXTRA_BUILD_ARGS="--compile-win64" + EXPECTED_HOST_OS="MINGW" + BUILD_BLOB_NAME="chromium-win64.zip" elif [[ "$BUILD_FLAVOR" == "chromium-mac" ]]; then BROWSER_NAME="chromium" EXTRA_BUILD_ARGS="--compile-mac" diff --git a/browser_patches/chromium/build.sh b/browser_patches/chromium/build.sh index b943b0f64b..fdc43569e8 100755 --- a/browser_patches/chromium/build.sh +++ b/browser_patches/chromium/build.sh @@ -35,10 +35,15 @@ compile_chromium() { exit 1 fi - if [[ ! -d "${SCRIPT_PATH}/depot_tools" ]]; then - git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git "${SCRIPT_PATH}/depot_tools" + # install depot_tools if they are not in system + # NOTE: as of Feb 8, 2021, windows requires manual and separate + # installation of depot_tools. + if ! command -v autoninja >/dev/null; then + if [[ ! -d "${SCRIPT_PATH}/depot_tools" ]]; then + git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git "${SCRIPT_PATH}/depot_tools" + fi + export PATH="${SCRIPT_PATH}/depot_tools:$PATH" fi - export PATH="${SCRIPT_PATH}/depot_tools:$PATH" CHROMIUM_FOLDER_NAME="" CHROMIUM_FILES_TO_ARCHIVE=() @@ -90,6 +95,32 @@ compile_chromium() { "xdg-mime" "xdg-settings" ) + elif [[ $1 == "--compile-win"* ]]; then + CHROMIUM_FOLDER_NAME="chrome-win" + CHROMIUM_FILES_TO_ARCHIVE=( + "chrome.dll" + "chrome.exe" + "chrome_100_percent.pak" + "chrome_200_percent.pak" + "chrome_elf.dll" + "chrome_proxy.exe" + "chrome_pwa_launcher.exe" + "D3DCompiler_47.dll" + "elevation_service.exe" + "eventlog_provider.dll" + "First Run" + "icudtl.dat" + "libEGL.dll" + "libGLESv2.dll" + "locales" + "MEIPreload" + "mojo_core.dll" + "nacl_irt_x86_64.nexe" + "notification_helper.exe" + "resources.pak" + "swiftshader" + "v8_context_snapshot.bin" + ) fi # Get chromium SHA from the build revision. @@ -128,11 +159,16 @@ 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 - # Compile Chromium with correct Xcode version. - gn gen out/Default - autoninja -C out/Default chrome + 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 + fi if [[ $1 == "--compile-linux" ]]; then autoninja -C out/Default chrome_sandbox clear_key_cdm @@ -151,6 +187,10 @@ EOF for file in ${CHROMIUM_FILES_TO_ARCHIVE[@]}; do $COPY_COMMAND "${CR_CHECKOUT_PATH}/src/out/Default/${file}" "output/${CHROMIUM_FOLDER_NAME}/${file}" done + if [[ $1 == "--compile-win"* ]]; then + $COPY_COMMAND "${CR_CHECKOUT_PATH}/src/out/Default/"*.manifest "output/${CHROMIUM_FOLDER_NAME}/" + fi + cd output zip --symlinks -r build.zip "${CHROMIUM_FOLDER_NAME}" } diff --git a/browser_patches/chromium/buildwin.bat b/browser_patches/chromium/buildwin.bat new file mode 100644 index 0000000000..45f2328f1f --- /dev/null +++ b/browser_patches/chromium/buildwin.bat @@ -0,0 +1,2 @@ +CALL gn gen out/Default +CALL autoninja -C out/Default chrome