Bug 1867459 - Avoiding silently dismissing uses of CPU_ARCH. r=firefox-build-system-reviewers,sergesanspaille

In many cases, using CONFIG["CPU_ARCH"] will silently do the unexpected
thing now that it doesn't exist anymore. In case there are in-flight
patches using it, it's better to avoid those causing subtle problems
after a rebase by making most uses of the variable throw an exception.

Differential Revision: https://phabricator.services.mozilla.com/D195158
This commit is contained in:
Mike Hommey 2023-12-08 10:43:59 +00:00
parent 619672a8e4
commit b7bb7390ba
3 changed files with 21 additions and 0 deletions

View File

@ -825,6 +825,7 @@ set_config("OS_TARGET", target_variables.OS_TARGET)
add_old_configure_assignment("OS_TARGET", target_variables.OS_TARGET)
set_config("OS_ARCH", target_variables.OS_ARCH)
add_old_configure_assignment("OS_ARCH", target_variables.OS_ARCH)
obsolete_config("CPU_ARCH", replacement="TARGET_CPU")
set_config("INTEL_ARCHITECTURE", target_variables.INTEL_ARCHITECTURE)
set_config("TARGET_CPU", target.cpu)
add_old_configure_assignment("TARGET_CPU", target.cpu)

View File

@ -515,6 +515,12 @@ def project_flag(env=None, set_as_define=False, **kwargs):
set_define(env, option_implementation)
@template
@imports(_from="mozbuild.configure.constants", _import="RaiseErrorOnUse")
def obsolete_config(name, *, replacement):
set_config(name, RaiseErrorOnUse(f"{name} is obsolete. Use {replacement} instead."))
# Hacks related to old-configure
# ==============================

View File

@ -7,6 +7,20 @@ from collections import OrderedDict
from mozbuild.util import EnumString
class RaiseErrorOnUse(str):
def __init__(self, msg):
self.msg = msg
def __eq__(self, other):
raise RuntimeError(self.msg)
def __ne__(self, other):
self.__eq__(other)
def __repr__(self):
return f"{self.__class__.__name__}({self.msg!r})"
class CompilerType(EnumString):
POSSIBLE_VALUES = (
"clang",