commit 654e2800514174ef09fbf57b09496387d23f498e
parent 4f0a8341419376d8da8aebeb76d9f73525aea2f8
Author: Michael Froman <mfroman@mozilla.com>
Date: Wed, 8 Oct 2025 16:59:36 -0500
Bug 1993083 - Vendor libwebrtc from 5fd1d990ab
Upstream commit: https://webrtc.googlesource.com/src/+/5fd1d990abf38d8e6149fc307ca512234929e5a8
IWYU: only apply include cleaner to files that compile in the current config
utilizing the return value of
gn refs -C workdir path/to/file
Bug: webrtc:42226242
Change-Id: I87d38429ad120770dd1acd7ef2ad175f463cdd85
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/396941
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Jeremy Leconte <jleconte@google.com>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#45025}
Diffstat:
2 files changed, 24 insertions(+), 3 deletions(-)
diff --git a/third_party/libwebrtc/README.mozilla.last-vendor b/third_party/libwebrtc/README.mozilla.last-vendor
@@ -1,4 +1,4 @@
# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /home/mfroman/mozilla/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc
-libwebrtc updated from /home/mfroman/mozilla/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2025-10-08T21:52:50.800744+00:00.
+libwebrtc updated from /home/mfroman/mozilla/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2025-10-08T21:59:27.254249+00:00.
# base of lastest vendoring
-c7bcf5ba9a
+5fd1d990ab
diff --git a/third_party/libwebrtc/tools_webrtc/iwyu/apply_include_cleaner.py b/third_party/libwebrtc/tools_webrtc/iwyu/apply_include_cleaner.py
@@ -40,6 +40,7 @@
import argparse
import re
import pathlib
+import os
import subprocess
import sys
from typing import Tuple
@@ -75,6 +76,23 @@ _IGNORED_HEADERS = [
"openssl/.*.h", # openssl/boringssl.
]
+_SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
+_SRC_DIR = os.path.abspath(os.path.join(_SCRIPT_DIR, os.pardir, os.pardir))
+sys.path.append(os.path.join(_SRC_DIR, "build"))
+import find_depot_tools
+
+_GN_BINARY_PATH = os.path.join(find_depot_tools.DEPOT_TOOLS_PATH, "gn.py")
+
+
+# Check that the file is part of a build target on this platform.
+def _is_built(filename, work_dir):
+ gn_cmd = (_GN_BINARY_PATH, "refs", "-C", work_dir, filename)
+ gn_result = subprocess.run(gn_cmd,
+ capture_output=True,
+ text=True,
+ check=False)
+ return gn_result.returncode == 0
+
def _parse_args() -> argparse.Namespace:
parser = argparse.ArgumentParser(
description="Runs the include-cleaner tool on a list of files",
@@ -191,7 +209,6 @@ def _modified_content(content: str) -> str:
return modified_content
-
# Transitioning the cmd type to tuple to prevent modification of
# the original command from the callsite in main...
def apply_include_cleaner_to_file(file_path: pathlib.Path, should_modify: bool,
@@ -266,6 +283,10 @@ def main() -> None:
for file in args.files:
if not file.suffix in _SUFFICES:
continue
+ if not _is_built(file, args.work_dir):
+ print(
+ f"Skipping include cleaner as {file} is not referenced by GN.")
+ continue
changes_generated = bool(
apply_include_cleaner_to_file(file, should_modify, tuple(cmd))
or changes_generated)