diff options
author | Xavier Claessens <xavier.claessens@collabora.com> | 2023-08-23 09:09:06 -0400 |
---|---|---|
committer | Eli Schwartz <eschwartz93@gmail.com> | 2023-08-24 19:09:20 -0400 |
commit | b4b1395ef5d2a625389902797816109c2e8340e3 (patch) | |
tree | b49e5304d6279cf1f5f7b70c9fd7aa7541b8b6c9 | |
parent | f720105e242111f4b68c0cb2aa77a4301a2fd10f (diff) | |
download | meson-b4b1395ef5d2a625389902797816109c2e8340e3.zip meson-b4b1395ef5d2a625389902797816109c2e8340e3.tar.gz meson-b4b1395ef5d2a625389902797816109c2e8340e3.tar.bz2 |
Suggest using --reconfigure only when not already using it
-rw-r--r-- | mesonbuild/coredata.py | 10 | ||||
-rw-r--r-- | mesonbuild/environment.py | 4 | ||||
-rw-r--r-- | mesonbuild/utils/universal.py | 16 |
3 files changed, 15 insertions, 15 deletions
diff --git a/mesonbuild/coredata.py b/mesonbuild/coredata.py index d59d9b8..b0dad13 100644 --- a/mesonbuild/coredata.py +++ b/mesonbuild/coredata.py @@ -89,10 +89,10 @@ def get_genvs_default_buildtype_list() -> list[str]: class MesonVersionMismatchException(MesonException): '''Build directory generated with Meson version is incompatible with current version''' - def __init__(self, old_version: str, current_version: str) -> None: + def __init__(self, old_version: str, current_version: str, extra_msg: str = '') -> None: super().__init__(f'Build directory has been generated with Meson version {old_version}, ' - f'which is incompatible with the current version {current_version}. ' - f'Consider reconfiguring the directory with meson setup --reconfigure.') + f'which is incompatible with the current version {current_version}.' + + extra_msg) self.old_version = old_version self.current_version = current_version @@ -1099,9 +1099,9 @@ def major_versions_differ(v1: str, v2: str) -> bool: # Major version differ, or one is development version but not the other. return v1_major != v2_major or ('99' in {v1_minor, v2_minor} and v1_minor != v2_minor) -def load(build_dir: str) -> CoreData: +def load(build_dir: str, suggest_reconfigure: bool = True) -> CoreData: filename = os.path.join(build_dir, 'meson-private', 'coredata.dat') - return pickle_load(filename, 'Coredata', CoreData) + return pickle_load(filename, 'Coredata', CoreData, suggest_reconfigure) def save(obj: CoreData, build_dir: str) -> str: diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py index 36106e4..7590931 100644 --- a/mesonbuild/environment.py +++ b/mesonbuild/environment.py @@ -490,7 +490,7 @@ class Environment: os.makedirs(self.log_dir, exist_ok=True) os.makedirs(self.info_dir, exist_ok=True) try: - self.coredata: coredata.CoreData = coredata.load(self.get_build_dir()) + self.coredata: coredata.CoreData = coredata.load(self.get_build_dir(), suggest_reconfigure=False) self.first_invocation = False except FileNotFoundError: self.create_new_coredata(options) @@ -508,7 +508,7 @@ class Environment: coredata.read_cmd_line_file(self.build_dir, options) self.create_new_coredata(options) else: - raise e + raise MesonException(f'{str(e)} Try regenerating using "meson setup --wipe".') else: # Just create a fresh coredata in this case self.scratch_dir = '' diff --git a/mesonbuild/utils/universal.py b/mesonbuild/utils/universal.py index c0fa15f..a39825f 100644 --- a/mesonbuild/utils/universal.py +++ b/mesonbuild/utils/universal.py @@ -2411,22 +2411,22 @@ class OptionKey: return self.type is OptionType.BASE -def pickle_load(filename: str, object_name: str, object_type: T.Type[_PL]) -> _PL: - load_fail_msg = f'{object_name} file {filename!r} is corrupted. Try with a fresh build tree.' +def pickle_load(filename: str, object_name: str, object_type: T.Type[_PL], suggest_reconfigure: bool = True) -> _PL: + load_fail_msg = f'{object_name} file {filename!r} is corrupted.' + extra_msg = ' Consider reconfiguring the directory with "meson setup --reconfigure".' if suggest_reconfigure else '' try: with open(filename, 'rb') as f: obj = pickle.load(f) except (pickle.UnpicklingError, EOFError): - raise MesonException(load_fail_msg) + raise MesonException(load_fail_msg + extra_msg) except (TypeError, ModuleNotFoundError, AttributeError): - build_dir = os.path.dirname(os.path.dirname(filename)) raise MesonException( f"{object_name} file {filename!r} references functions or classes that don't " "exist. This probably means that it was generated with an old " - "version of meson. Try running from the source directory " - f'meson setup {build_dir} --wipe') + "version of meson." + extra_msg) + if not isinstance(obj, object_type): - raise MesonException(load_fail_msg) + raise MesonException(load_fail_msg + extra_msg) # Because these Protocols are not available at runtime (and cannot be made # available at runtime until we drop support for Python < 3.8), we have to @@ -2440,7 +2440,7 @@ def pickle_load(filename: str, object_name: str, object_type: T.Type[_PL]) -> _P from ..coredata import version as coredata_version from ..coredata import major_versions_differ, MesonVersionMismatchException if major_versions_differ(version, coredata_version): - raise MesonVersionMismatchException(version, coredata_version) + raise MesonVersionMismatchException(version, coredata_version, extra_msg) return obj |