From 86b8f114e0ed4dddac6a099ba577bd5cdb032dd9 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Thu, 9 Jan 2025 12:35:57 +0100 Subject: [PATCH] build: cache target id at time of first use --- mesonbuild/build.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mesonbuild/build.py b/mesonbuild/build.py index 58898e17b2d1..3e4798b2d74e 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -24,7 +24,7 @@ extract_as_list, typeslistify, stringlistify, classify_unity_sources, get_filenames_templates_dict, substitute_values, has_path_sep, PerMachineDefaultable, - MesonBugException, EnvironmentVariables, pickle_load, + MesonBugException, EnvironmentVariables, pickle_load, lazy_property, ) from .options import OptionKey @@ -637,13 +637,17 @@ def construct_id_from_path(subdir: str, name: str, type_suffix: str) -> str: return subdir_part + '@@' + my_id return my_id - def get_id(self) -> str: + @lazy_property + def __id(self) -> str: name = self.name if getattr(self, 'name_suffix_set', False): name += '.' + self.suffix return self.construct_id_from_path( self.subdir, name, self.type_suffix()) + def get_id(self) -> str: + return self.__id + def process_kwargs_base(self, kwargs: T.Dict[str, T.Any]) -> None: if 'build_by_default' in kwargs: self.build_by_default = kwargs['build_by_default']