From f752f19158593887e9d0509385749e488108b393 Mon Sep 17 00:00:00 2001 From: Alex Andres Date: Sun, 27 Sep 2026 10:47:51 +0200 Subject: [PATCH] build: sync the WebRTC checkout without git history The checkout was created with "fetch webrtc", which clones src and every git dependency with full history, and only then checks out the branch. The branch is now pinned in a .gclient written by CMake and synced with --no-history --shallow, and depot_tools is cloned at depth 1. The instrumented libraries, used only by sanitizer builds on Linux, are no longer checked out. A fresh Windows checkout of branch-heads/7977 shrinks from 26.6 GB to about 12 GB, nearly all of it git history. --- .../cpp/dependencies/webrtc/CMakeLists.txt | 56 ++++++++++++++----- 1 file changed, 41 insertions(+), 15 deletions(-) diff --git a/webrtc-jni/src/main/cpp/dependencies/webrtc/CMakeLists.txt b/webrtc-jni/src/main/cpp/dependencies/webrtc/CMakeLists.txt index 1bc2f7c0..d85aff56 100644 --- a/webrtc-jni/src/main/cpp/dependencies/webrtc/CMakeLists.txt +++ b/webrtc-jni/src/main/cpp/dependencies/webrtc/CMakeLists.txt @@ -254,7 +254,7 @@ if(NOT EXISTS "${WEBRTC_SRC_DIR}/depot_tools") message(STATUS "WebRTC: fetch depot tools") file(MAKE_DIRECTORY ${WEBRTC_SRC_DIR}) execute_command( - COMMAND git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git + COMMAND git clone --depth 1 https://chromium.googlesource.com/chromium/tools/depot_tools.git WORKING_DIRECTORY "${WEBRTC_SRC_DIR}" ) endif() @@ -274,25 +274,51 @@ endif() file(MAKE_DIRECTORY ${WEBRTC_DIR}) -message(STATUS "WebRTC: fetch") -execute_command( - COMMAND fetch --nohooks webrtc - WORKING_DIRECTORY "${WEBRTC_DIR}" -) +# The branch is pinned in the .gclient solution url, so gclient syncs src +# and every dependency at depth 1 instead of cloning their full histories +# (what "fetch webrtc" does). Branch names resolve to a ref: branch-heads/N +# lives under refs/, a plain branch under refs/heads/. +if(WEBRTC_BRANCH MATCHES "^refs/") + set(WEBRTC_REF "${WEBRTC_BRANCH}") +elseif(WEBRTC_BRANCH MATCHES "^branch-heads/") + set(WEBRTC_REF "refs/${WEBRTC_BRANCH}") +else() + set(WEBRTC_REF "refs/heads/${WEBRTC_BRANCH}") +endif() -message(STATUS "WebRTC: checkout \"${WEBRTC_BRANCH}\"") -execute_command( - COMMAND git checkout . - WORKING_DIRECTORY "${WEBRTC_SRC}" -) +# The instrumented libraries only serve sanitizer builds (Linux). +file(WRITE "${WEBRTC_DIR}/.gclient" +"solutions = [ + { + \"name\": \"src\", + \"url\": \"https://webrtc.googlesource.com/src.git@${WEBRTC_REF}\", + \"deps_file\": \"DEPS\", + \"managed\": False, + \"custom_deps\": {}, + \"custom_vars\": { + \"checkout_instrumented_libraries\": False, + }, + }, +] +") + +if(EXISTS "${WEBRTC_SRC}") + # Drop previously applied patches so the sync can move the tree. + execute_command( + COMMAND git checkout . + WORKING_DIRECTORY "${WEBRTC_SRC}" + ) +endif() + +message(STATUS "WebRTC: sync \"${WEBRTC_REF}\"") execute_command( - COMMAND git checkout ${WEBRTC_BRANCH} - WORKING_DIRECTORY "${WEBRTC_SRC}" + COMMAND gclient sync --no-history --shallow --nohooks + WORKING_DIRECTORY "${WEBRTC_DIR}" ) -message(STATUS "WebRTC: sync") +message(STATUS "WebRTC: run hooks") execute_command( - COMMAND gclient sync + COMMAND gclient runhooks WORKING_DIRECTORY "${WEBRTC_DIR}" )