From 8d68418a0492295bbae0947c47ce8684e461d1e9 Mon Sep 17 00:00:00 2001 From: Marian-Vasile Laza Date: Tue, 14 Jun 2022 01:36:48 +0300 Subject: [PATCH] Backed out 4 changesets (bug 1769405) for causing regression in Bug 1774100. CLOSED TREE Backed out changeset 813147df341c (bug 1769405) Backed out changeset 6de9495c467d (bug 1769405) Backed out changeset 9099ba749b1f (bug 1769405) Backed out changeset 5f8e0141a0ed (bug 1769405) --- build/moz.configure/init.configure | 18 ----- moz.configure | 15 ++++ python/mozboot/mozboot/bootstrap.py | 103 +++++----------------------- python/mozbuild/mozbuild/base.py | 24 +++---- 4 files changed, 42 insertions(+), 118 deletions(-) diff --git a/build/moz.configure/init.configure b/build/moz.configure/init.configure index cebdfc52ad76b..81f500a0b7527 100644 --- a/build/moz.configure/init.configure +++ b/build/moz.configure/init.configure @@ -402,24 +402,6 @@ def default_project(build_env, js_package): option("--enable-project", nargs=1, default=default_project, help="Project to build") -# Artifact builds -# ============================================================== - -option( - "--enable-artifact-builds", - env="MOZ_ARTIFACT_BUILDS", - help="Download and use prebuilt binary artifacts.", -) - - -@depends("--enable-artifact-builds") -def artifact_builds(value): - if value: - return True - - -set_config("MOZ_ARTIFACT_BUILDS", artifact_builds) - # Host and target systems # ============================================================== option("--host", nargs=1, help="Define the system type performing the build") diff --git a/moz.configure b/moz.configure index bab601180deb0..8b74afbabec18 100755 --- a/moz.configure +++ b/moz.configure @@ -14,6 +14,21 @@ include("build/moz.configure/init.configure") # - Spidermonkey-specific options and rules should go in js/moz.configure. # - etc. +option( + "--enable-artifact-builds", + env="MOZ_ARTIFACT_BUILDS", + help="Download and use prebuilt binary artifacts.", +) + + +@depends("--enable-artifact-builds") +def artifact_builds(value): + if value: + return True + + +set_config("MOZ_ARTIFACT_BUILDS", artifact_builds) + imply_option( "--enable-artifact-build-symbols", depends(artifact_builds)(lambda v: False if v is None else None), diff --git a/python/mozboot/mozboot/bootstrap.py b/python/mozboot/mozboot/bootstrap.py index cfb82372d77e2..7f8b7f7d20873 100644 --- a/python/mozboot/mozboot/bootstrap.py +++ b/python/mozboot/mozboot/bootstrap.py @@ -37,9 +37,8 @@ from mozboot.void import VoidBootstrapper from mozboot.windows import WindowsBootstrapper from mozboot.mozillabuild import MozillaBuildBootstrapper -from mozboot.mozconfig import MozconfigBuilder +from mozboot.mozconfig import find_mozconfig, MozconfigBuilder from mozfile import which -from mozbuild.base import MozbuildObject # Use distro package to retrieve linux platform information import distro @@ -82,21 +81,6 @@ <<< """ -MOZCONFIG_MISMATCH_WARNING_TEMPLATE = """ -WARNING! Mismatch detected between the selected build target and the -mozconfig file %s: - -Current config ->>> -%s -<<< - -Expected config ->>> -%s -<<< -""" - CONFIGURE_MERCURIAL = """ Mozilla recommends a number of changes to Mercurial to enhance your experience with it. @@ -387,8 +371,6 @@ def bootstrap(self, settings): if not self.instance.no_interactive and not settings.mach_telemetry.is_set_up: initialize_telemetry_setting(settings, str(checkout_root), str(state_dir)) - self._output_mozconfig(application, mozconfig_builder) - print(FINISHED % name) if not ( which("rustc") @@ -399,54 +381,7 @@ def bootstrap(self, settings): % name ) - def _default_mozconfig_path(self): - return Path(self.mach_context.topdir) / "mozconfig" - - def _read_default_mozconfig(self): - path = self._default_mozconfig_path() - with open(path, "r") as mozconfig_file: - return mozconfig_file.read() - - def _write_default_mozconfig(self, raw_mozconfig): - path = self._default_mozconfig_path() - with open(path, "w") as mozconfig_file: - mozconfig_file.write(raw_mozconfig) - print(f'Your requested configuration has been written to "{path}".') - - def _show_mozconfig_suggestion(self, raw_mozconfig): - suggestion = MOZCONFIG_SUGGESTION_TEMPLATE % ( - self._default_mozconfig_path(), - raw_mozconfig, - ) - print(suggestion, end="") - - def _check_default_mozconfig_mismatch( - self, current_mozconfig_info, expected_application, expected_raw_mozconfig - ): - current_raw_mozconfig = self._read_default_mozconfig() - current_application = current_mozconfig_info["project"][0].replace("/", "_") - if current_mozconfig_info["artifact-builds"]: - current_application += "_artifact_mode" - - if expected_application == current_application: - if expected_raw_mozconfig == current_raw_mozconfig: - return - - # There's minor difference, show the suggestion. - self._show_mozconfig_suggestion(expected_raw_mozconfig) - return - - warning = MOZCONFIG_MISMATCH_WARNING_TEMPLATE % ( - self._default_mozconfig_path(), - current_raw_mozconfig, - expected_raw_mozconfig, - ) - print(warning) - - if not self.instance.prompt_yesno("Do you want to overwrite the config?"): - return - - self._write_default_mozconfig(expected_raw_mozconfig) + self._output_mozconfig(application, mozconfig_builder) def _output_mozconfig(self, application, mozconfig_builder): # Like 'generate_browser_mozconfig' or 'generate_mobile_android_mozconfig'. @@ -457,26 +392,22 @@ def _output_mozconfig(self, application, mozconfig_builder): mozconfig_builder.append(additional_mozconfig) raw_mozconfig = mozconfig_builder.generate() - current_mozconfig_info = MozbuildObject.get_base_mozconfig_info( - self.mach_context.topdir, None, "" - ) - current_mozconfig_path = current_mozconfig_info["mozconfig"]["path"] - - if current_mozconfig_path: - # mozconfig file exists - if Path.samefile( - Path(current_mozconfig_path), self._default_mozconfig_path() - ): - # This mozconfig file may be created by bootstrap. - self._check_default_mozconfig_mismatch( - current_mozconfig_info, application, raw_mozconfig + if raw_mozconfig: + mozconfig_path = find_mozconfig(Path(self.mach_context.topdir)) + if not mozconfig_path: + # No mozconfig file exists yet + mozconfig_path = Path(self.mach_context.topdir) / "mozconfig" + with open(mozconfig_path, "w") as mozconfig_file: + mozconfig_file.write(raw_mozconfig) + print( + f'Your requested configuration has been written to "{mozconfig_path}".' + ) + else: + suggestion = MOZCONFIG_SUGGESTION_TEMPLATE % ( + mozconfig_path, + raw_mozconfig, ) - elif raw_mozconfig: - # The mozconfig file is created by user. - self._show_mozconfig_suggestion(raw_mozconfig) - elif raw_mozconfig: - # No mozconfig file exists yet - self._write_default_mozconfig(raw_mozconfig) + print(suggestion, end="") def _validate_python_environment(self, topsrcdir): valid = True diff --git a/python/mozbuild/mozbuild/base.py b/python/mozbuild/mozbuild/base.py index e2a6feb59f017..c336fdbeecfa6 100644 --- a/python/mozbuild/mozbuild/base.py +++ b/python/mozbuild/mozbuild/base.py @@ -281,7 +281,7 @@ def virtualenv_manager(self): @staticmethod @memoize - def get_base_mozconfig_info(topsrcdir, path, env_mozconfig): + def get_mozconfig_and_target(topsrcdir, path, env_mozconfig): # env_mozconfig is only useful for unittests, which change the value of # the environment variable, which has an impact on autodetection (when # path is MozconfigLoader.AUTODETECT), and memoization wouldn't account @@ -321,7 +321,7 @@ def depends_impl(self, *args, **kwargs): sandbox = ReducedConfigureSandbox( {}, environ=env, - argv=["mach"], + argv=["mach", "--help"], logger=logger, ) base_dir = os.path.join(topsrcdir, "build", "moz.configure") @@ -329,21 +329,17 @@ def depends_impl(self, *args, **kwargs): sandbox.include_file(os.path.join(base_dir, "init.configure")) # Force mozconfig options injection before getting the target. sandbox._value_for(sandbox["mozconfig_options"]) - return { - "mozconfig": sandbox._value_for(sandbox["mozconfig"]), - "target": sandbox._value_for(sandbox["real_target"]), - "project": sandbox._value_for(sandbox._options["project"]), - "artifact-builds": sandbox._value_for( - sandbox._options["artifact-builds"] - ), - } + return ( + sandbox._value_for(sandbox["mozconfig"]), + sandbox._value_for(sandbox["real_target"]), + ) except SystemExit: print(out.getvalue()) raise @property - def base_mozconfig_info(self): - return self.get_base_mozconfig_info( + def mozconfig_and_target(self): + return self.get_mozconfig_and_target( self.topsrcdir, self._mozconfig, os.environ.get("MOZCONFIG") ) @@ -353,7 +349,7 @@ def mozconfig(self): This a dict as returned by MozconfigLoader.read_mozconfig() """ - return self.base_mozconfig_info["mozconfig"] + return self.mozconfig_and_target[0] @property def config_environment(self): @@ -573,7 +569,7 @@ def get_binary_path(self, what="app", validate_exists=True, where="default"): return path def resolve_config_guess(self): - return self.base_mozconfig_info["target"].alias + return self.mozconfig_and_target[1].alias def notify(self, msg): """Show a desktop notification with the supplied message