Commit 38ef7101 authored by Michael Froman's avatar Michael Froman Committed by mfroman@mozilla.com
Browse files

Bug 1967834 - remove the preprocessing scripts in favor of direct changes in...

Bug 1967834 - remove the preprocessing scripts in favor of direct changes in gn_processor.py r=ng DONTBUILD

Using 'module' will cause trouble (unable to pickle 'module') as we try to
run some of the script in parallel.

Differential Revision: https://phabricator.services.mozilla.com/D250516
parent fcefbdba
Loading
Loading
Loading
Loading
+11 −22
Original line number Diff line number Diff line
@@ -10,7 +10,6 @@ import sys
import tempfile
from collections import defaultdict, deque
from copy import deepcopy
from importlib import util
from pathlib import Path
from shutil import which

@@ -720,7 +719,6 @@ def generate_gn_config(
    input_variables,
    sandbox_variables,
    gn_target,
    preprocessor,
    moz_build_flag,
):
    def str_for_arg(v):
@@ -775,25 +773,19 @@ def generate_gn_config(
        subprocess.check_call(gen_args, cwd=build_root_dir, stderr=subprocess.STDOUT)

        gn_config_file = resolved_tempdir / "project.json"
        if preprocessor:
            preprocessor.main(gn_config_file)

        with open(gn_config_file) as fh:
            gn_out = json.load(fh)
            gn_out = filter_gn_config(
                resolved_tempdir, gn_out, sandbox_variables, input_variables, gn_target
            raw_json = fh.read()
            raw_json = raw_json.replace(f"{target_dir}/", "")
            raw_json = raw_json.replace(f"{target_dir}:", ":")
            gn_config = json.loads(raw_json)
            gn_config = filter_gn_config(
                resolved_tempdir,
                gn_config,
                sandbox_variables,
                input_variables,
                gn_target,
            )
            return gn_out


def load_preprocessor(script_name):
    if script_name and os.path.isfile(script_name):
        print(f"Loading preprocessor {script_name}")
        spec = util.spec_from_file_location("preprocess", script_name)
        module = util.module_from_spec(spec)
        spec.loader.exec_module(module)
        return module
    return None
            return gn_config


def main():
@@ -840,8 +832,6 @@ def main():
                        vars["use_x11"] = True
                    vars_set.append(vars)

    preprocessor = load_preprocessor(config.get("preprocessing_script", None))

    gn_configs = []
    for vars in vars_set:
        gn_configs.append(
@@ -852,7 +842,6 @@ def main():
                vars,
                config["gn_sandbox_variables"],
                config["gn_target"],
                preprocessor,
                config["moz_build_flag"],
            )
        )
+0 −1
Original line number Diff line number Diff line
{
  "build_root_dir": "third_party",
  "target_dir": "abseil-cpp",
  "preprocessing_script": "dom/media/webrtc/third_party_build/gn-configs/abseil_preprocessor.py",
  "moz_build_flag": "build_mozilla_absl",
  "gn_target": "//:absl",
  "gn_sandbox_variables": {
+0 −14
Original line number Diff line number Diff line
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.


def main(gn_config_file):
    target_dir = "abseil-cpp"
    raw_file_contents = ""
    with open(gn_config_file) as fh:
        raw_file_contents = fh.read()
    raw_file_contents = raw_file_contents.replace(f"{target_dir}/", "")
    raw_file_contents = raw_file_contents.replace(f"{target_dir}:", ":")
    with open(gn_config_file, "w") as fh:
        fh.write(raw_file_contents)
+0 −1
Original line number Diff line number Diff line
{
  "build_root_dir": "third_party",
  "target_dir": "libwebrtc",
  "preprocessing_script": "dom/media/webrtc/third_party_build/gn-configs/webrtc_preprocessor.py",
  "moz_build_flag": "build_mozilla_webrtc",
  "gn_target": "//:webrtc",
  "gn_sandbox_variables": {
+0 −14
Original line number Diff line number Diff line
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.


def main(gn_config_file):
    target_dir = "libwebrtc"
    raw_file_contents = ""
    with open(gn_config_file) as fh:
        raw_file_contents = fh.read()
    raw_file_contents = raw_file_contents.replace(f"{target_dir}/", "")
    raw_file_contents = raw_file_contents.replace(f"{target_dir}:", ":")
    with open(gn_config_file, "w") as fh:
        fh.write(raw_file_contents)