[tbb-commits] [tor-browser] 31/179: Bug 1773223 - Move some json fixups into the GN processor. r=firefox-build-system-reviewers, andi a=RyanVM

gitolite role git at cupani.torproject.org
Fri Aug 19 08:35:28 UTC 2022


This is an automated email from the git hooks/post-receive script.

pierov pushed a commit to branch tor-browser-102.2.0esr-12.0-1
in repository tor-browser.

commit c7ec1425bf952d585ed44f555ee73ba8757b9d11
Author: Mike Hommey <mh+mozilla at glandium.org>
AuthorDate: Mon Jun 20 21:50:59 2022 +0000

    Bug 1773223 - Move some json fixups into the GN processor. r=firefox-build-system-reviewers,andi a=RyanVM
    
    As we're shortly going to stop producing the intermediate json files,
    we want the fixups to happen in the GN processor.
    
    Ideally, we'd move them all, but cleaning up -isysroot is more involved,
    while we won't need it once we don't use intermediate json files, so we
    leave the -isysroot cleanup in fixup_json.py for now.
    
    While here, `gn_out["targets"][target_fullname]` doesn't need to be set
    on every iteration of the loop.
    
    Differential Revision: https://phabricator.services.mozilla.com/D149209
---
 .../webrtc/third_party_build/gn-configs/fixup_json.py   |  6 ------
 python/mozbuild/mozbuild/gn_processor.py                | 17 ++++++++++++++---
 2 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/dom/media/webrtc/third_party_build/gn-configs/fixup_json.py b/dom/media/webrtc/third_party_build/gn-configs/fixup_json.py
index 67ce72f325bb9..99f28bbb8ddae 100755
--- a/dom/media/webrtc/third_party_build/gn-configs/fixup_json.py
+++ b/dom/media/webrtc/third_party_build/gn-configs/fixup_json.py
@@ -21,12 +21,6 @@ def main():
     f = open(filein, "r")
     file = f.read()
 
-    # Remove references to CR_XCODE_VERSION and the output directory of the gn process.
-    # This change does not cause a change in the generated moz.build files.
-    file = re.sub(r' *"CR_XCODE_VERSION=([0-9.]+)",\n', r"", file)
-    file = re.sub(r' *"CR_SYSROOT_HASH=[0-9a-f]+",\n', r"", file)
-    file = re.sub(r',\n *"(.\:)?/.*/third_party/libwebrtc/gn-output/gen/"', r"", file)
-
     # In practice, almost all of the entries in the cflags section have no affect
     # on the moz.build output files when running ./mach build-backend -b GnMozbuildWriter
     # There are few exceptions which do: -msse2, -mavx2, -mfma, -fobjc-arc
diff --git a/python/mozbuild/mozbuild/gn_processor.py b/python/mozbuild/mozbuild/gn_processor.py
index 17c25b215b0ac..233ec3260235a 100644
--- a/python/mozbuild/mozbuild/gn_processor.py
+++ b/python/mozbuild/mozbuild/gn_processor.py
@@ -6,6 +6,7 @@ from __future__ import absolute_import, print_function, unicode_literals
 
 from collections import defaultdict, deque
 from copy import deepcopy
+from pathlib import Path
 import glob
 import json
 import os
@@ -152,7 +153,8 @@ def find_deps(all_targets, target):
     return all_deps
 
 
-def filter_gn_config(gn_result, sandbox_vars, input_vars, gn_target):
+def filter_gn_config(path, gn_result, sandbox_vars, input_vars, gn_target):
+    gen_path = (Path(path) / "gen").resolve()
     # Translates the raw output of gn into just what we'll need to generate a
     # mozbuild configuration.
     gn_out = {"targets": {}, "sandbox_vars": sandbox_vars, "gn_gen_args": input_vars}
@@ -199,7 +201,16 @@ def filter_gn_config(gn_result, sandbox_vars, input_vars, gn_target):
             "libs",
         ):
             spec[spec_attr] = raw_spec.get(spec_attr, [])
-            gn_out["targets"][target_fullname] = spec
+            if spec_attr == "defines":
+                spec[spec_attr] = [
+                    d
+                    for d in spec[spec_attr]
+                    if "CR_XCODE_VERSION" not in d and "CR_SYSROOT_HASH" not in d
+                ]
+            if spec_attr == "include_dirs":
+                spec[spec_attr] = [d for d in spec[spec_attr] if gen_path != Path(d)]
+
+        gn_out["targets"][target_fullname] = spec
 
     return gn_out
 
@@ -628,7 +639,7 @@ def generate_gn_config(
     with open(gn_config_file, "r") as fh:
         gn_out = json.load(fh)
         gn_out = filter_gn_config(
-            gn_out, sandbox_variables, input_variables, gn_target
+            out_dir, gn_out, sandbox_variables, input_variables, gn_target
         )
 
     os.remove(gn_config_file)

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the tbb-commits mailing list