From db528e3bb9c986a28abf38ca5d28e32506d388e9 Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Thu, 16 Dec 2021 17:47:43 -0500 Subject: fix crash during MesonException In commit e5a6283c4cf288fdfc9b43a92bf0ddd74dbf90f8, this function was reorganized to assign value -> newvalue instead of overwriting newvalue, but the error message case wasn't updated to match. As a result, actually hitting the error would report an even more errory error, i.e. a traceback. (Actually hitting the error requires passing an array option as a python object that isn't a list or a string. This is impossible to do from the command line or meson_options.txt, but can be done with builtin options.) --- mesonbuild/coredata.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mesonbuild/coredata.py b/mesonbuild/coredata.py index f444cf1..6ac2151 100644 --- a/mesonbuild/coredata.py +++ b/mesonbuild/coredata.py @@ -234,7 +234,7 @@ class UserArrayOption(UserOption[T.List[str]]): elif isinstance(value, list): newvalue = value else: - raise MesonException(f'"{newvalue}" should be a string array, but it is not') + raise MesonException(f'"{value}" should be a string array, but it is not') return newvalue def validate_value(self, value: T.Union[str, T.List[str]], user_input: bool = True) -> T.List[str]: -- cgit v1.1 From 19c9f32cefdffb7d633eedada2b31059301fb106 Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Thu, 16 Dec 2021 22:48:25 -0500 Subject: correct type annotations for File.endswith It should accept whatever str.endswith accepts, which means optionally a tuple of options. --- mesonbuild/mesonlib/universal.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mesonbuild/mesonlib/universal.py b/mesonbuild/mesonlib/universal.py index bae80d4..493acef 100644 --- a/mesonbuild/mesonlib/universal.py +++ b/mesonbuild/mesonlib/universal.py @@ -425,7 +425,7 @@ class File(HoldableObject): def suffix(self) -> str: return os.path.splitext(self.fname)[1][1:].lower() - def endswith(self, ending: str) -> bool: + def endswith(self, ending: T.Union[str, T.Tuple[str, ...]]) -> bool: return self.fname.endswith(ending) def split(self, s: str, maxsplit: int = -1) -> T.List[str]: -- cgit v1.1 From 9f384e92075022af73f1a75bb746b71ea11b2f21 Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Thu, 16 Dec 2021 22:50:15 -0500 Subject: fix type annotations for compiler toolchain rpaths We pass around a tuple of rpaths, because rpaths *can* be more than one. But all the annotations said it would be a str instead. --- mesonbuild/compilers/compilers.py | 2 +- mesonbuild/compilers/cuda.py | 2 +- mesonbuild/compilers/d.py | 2 +- mesonbuild/compilers/mixins/islinker.py | 2 +- mesonbuild/linkers/linkers.py | 24 ++++++++++++------------ 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py index e0745c2..b652f5a 100644 --- a/mesonbuild/compilers/compilers.py +++ b/mesonbuild/compilers/compilers.py @@ -875,7 +875,7 @@ class Compiler(HoldableObject, metaclass=abc.ABCMeta): return None def build_rpath_args(self, env: 'Environment', build_dir: str, from_dir: str, - rpath_paths: str, build_rpath: str, + rpath_paths: T.Tuple[str, ...], build_rpath: str, install_rpath: str) -> T.Tuple[T.List[str], T.Set[bytes]]: return self.linker.build_rpath_args( env, build_dir, from_dir, rpath_paths, build_rpath, install_rpath) diff --git a/mesonbuild/compilers/cuda.py b/mesonbuild/compilers/cuda.py index 1f396e4..32e75a5 100644 --- a/mesonbuild/compilers/cuda.py +++ b/mesonbuild/compilers/cuda.py @@ -706,7 +706,7 @@ class CudaCompiler(Compiler): return self._to_host_flags(self.host_compiler.get_buildtype_linker_args(buildtype), _Phase.LINKER) def build_rpath_args(self, env: 'Environment', build_dir: str, from_dir: str, - rpath_paths: str, build_rpath: str, + rpath_paths: T.Tuple[str, ...], build_rpath: str, install_rpath: str) -> T.Tuple[T.List[str], T.Set[bytes]]: (rpath_args, rpath_dirs_to_remove) = self.host_compiler.build_rpath_args( env, build_dir, from_dir, rpath_paths, build_rpath, install_rpath) diff --git a/mesonbuild/compilers/d.py b/mesonbuild/compilers/d.py index 4201d82..a83c15b 100644 --- a/mesonbuild/compilers/d.py +++ b/mesonbuild/compilers/d.py @@ -249,7 +249,7 @@ class DmdLikeCompilerMixin(CompilerMixinBase): return self.linker.import_library_args(implibname) def build_rpath_args(self, env: 'Environment', build_dir: str, from_dir: str, - rpath_paths: str, build_rpath: str, + rpath_paths: T.Tuple[str, ...], build_rpath: str, install_rpath: str) -> T.Tuple[T.List[str], T.Set[bytes]]: if self.info.is_windows(): return ([], set()) diff --git a/mesonbuild/compilers/mixins/islinker.py b/mesonbuild/compilers/mixins/islinker.py index 144bc70..9513aa5 100644 --- a/mesonbuild/compilers/mixins/islinker.py +++ b/mesonbuild/compilers/mixins/islinker.py @@ -108,7 +108,7 @@ class BasicLinkerIsCompilerMixin(Compiler): raise MesonException("This linker doesn't support soname args") def build_rpath_args(self, env: 'Environment', build_dir: str, from_dir: str, - rpath_paths: str, build_rpath: str, + rpath_paths: T.Tuple[str, ...], build_rpath: str, install_rpath: str) -> T.Tuple[T.List[str], T.Set[bytes]]: return ([], set()) diff --git a/mesonbuild/linkers/linkers.py b/mesonbuild/linkers/linkers.py index 5491558..c8489da 100644 --- a/mesonbuild/linkers/linkers.py +++ b/mesonbuild/linkers/linkers.py @@ -72,7 +72,7 @@ class StaticLinker: return [] def build_rpath_args(self, env: 'Environment', build_dir: str, from_dir: str, - rpath_paths: str, build_rpath: str, + rpath_paths: T.Tuple[str, ...], build_rpath: str, install_rpath: str) -> T.Tuple[T.List[str], T.Set[bytes]]: return ([], set()) @@ -309,7 +309,7 @@ class AIXArLinker(ArLikeLinker): std_args = ['-csr', '-Xany'] -def prepare_rpaths(raw_rpaths: str, build_dir: str, from_dir: str) -> T.List[str]: +def prepare_rpaths(raw_rpaths: T.Tuple[str, ...], build_dir: str, from_dir: str) -> T.List[str]: # The rpaths we write must be relative if they point to the build dir, # because otherwise they have different length depending on the build # directory. This breaks reproducible builds. @@ -518,7 +518,7 @@ class DynamicLinker(metaclass=abc.ABCMeta): raise MesonException('This linker does not support bitcode bundles') def build_rpath_args(self, env: 'Environment', build_dir: str, from_dir: str, - rpath_paths: str, build_rpath: str, + rpath_paths: T.Tuple[str, ...], build_rpath: str, install_rpath: str) -> T.Tuple[T.List[str], T.Set[bytes]]: return ([], set()) @@ -627,7 +627,7 @@ class GnuLikeDynamicLinkerMixin: return self._apply_prefix(f'-soname,{prefix}{shlib_name}.{suffix}{sostr}') def build_rpath_args(self, env: 'Environment', build_dir: str, from_dir: str, - rpath_paths: str, build_rpath: str, + rpath_paths: T.Tuple[str, ...], build_rpath: str, install_rpath: str) -> T.Tuple[T.List[str], T.Set[bytes]]: m = env.machines[self.for_machine] if m.is_windows() or m.is_cygwin(): @@ -765,7 +765,7 @@ class AppleDynamicLinker(PosixDynamicLinkerMixin, DynamicLinker): return args def build_rpath_args(self, env: 'Environment', build_dir: str, from_dir: str, - rpath_paths: str, build_rpath: str, + rpath_paths: T.Tuple[str, ...], build_rpath: str, install_rpath: str) -> T.Tuple[T.List[str], T.Set[bytes]]: if not rpath_paths and not install_rpath and not build_rpath: return ([], set()) @@ -846,7 +846,7 @@ class WASMDynamicLinker(GnuLikeDynamicLinkerMixin, PosixDynamicLinkerMixin, Dyna return [] def build_rpath_args(self, env: 'Environment', build_dir: str, from_dir: str, - rpath_paths: str, build_rpath: str, + rpath_paths: T.Tuple[str, ...], build_rpath: str, install_rpath: str) -> T.Tuple[T.List[str], T.Set[bytes]]: return ([], set()) @@ -924,7 +924,7 @@ class Xc16DynamicLinker(DynamicLinker): return [] def build_rpath_args(self, env: 'Environment', build_dir: str, from_dir: str, - rpath_paths: str, build_rpath: str, + rpath_paths: T.Tuple[str, ...], build_rpath: str, install_rpath: str) -> T.Tuple[T.List[str], T.Set[bytes]]: return ([], set()) @@ -967,7 +967,7 @@ class CompCertDynamicLinker(DynamicLinker): raise MesonException(f'{self.id} does not support shared libraries.') def build_rpath_args(self, env: 'Environment', build_dir: str, from_dir: str, - rpath_paths: str, build_rpath: str, + rpath_paths: T.Tuple[str, ...], build_rpath: str, install_rpath: str) -> T.Tuple[T.List[str], T.Set[bytes]]: return ([], set()) @@ -1065,7 +1065,7 @@ class NAGDynamicLinker(PosixDynamicLinkerMixin, DynamicLinker): id = 'nag' def build_rpath_args(self, env: 'Environment', build_dir: str, from_dir: str, - rpath_paths: str, build_rpath: str, + rpath_paths: T.Tuple[str, ...], build_rpath: str, install_rpath: str) -> T.Tuple[T.List[str], T.Set[bytes]]: if not rpath_paths and not install_rpath and not build_rpath: return ([], set()) @@ -1110,7 +1110,7 @@ class PGIDynamicLinker(PosixDynamicLinkerMixin, DynamicLinker): return [] def build_rpath_args(self, env: 'Environment', build_dir: str, from_dir: str, - rpath_paths: str, build_rpath: str, + rpath_paths: T.Tuple[str, ...], build_rpath: str, install_rpath: str) -> T.Tuple[T.List[str], T.Set[bytes]]: if not env.machines[self.for_machine].is_windows(): return (['-R' + os.path.join(build_dir, p) for p in rpath_paths], set()) @@ -1317,7 +1317,7 @@ class SolarisDynamicLinker(PosixDynamicLinkerMixin, DynamicLinker): return ['-z', 'fatal-warnings'] def build_rpath_args(self, env: 'Environment', build_dir: str, from_dir: str, - rpath_paths: str, build_rpath: str, + rpath_paths: T.Tuple[str, ...], build_rpath: str, install_rpath: str) -> T.Tuple[T.List[str], T.Set[bytes]]: if not rpath_paths and not install_rpath and not build_rpath: return ([], set()) @@ -1364,7 +1364,7 @@ class AIXDynamicLinker(PosixDynamicLinkerMixin, DynamicLinker): return self._apply_prefix(['-berok']) def build_rpath_args(self, env: 'Environment', build_dir: str, from_dir: str, - rpath_paths: str, build_rpath: str, + rpath_paths: T.Tuple[str, ...], build_rpath: str, install_rpath: str) -> T.Tuple[T.List[str], T.Set[bytes]]: all_paths = mesonlib.OrderedSet() # type: mesonlib.OrderedSet[str] # install_rpath first, followed by other paths, and the system path last -- cgit v1.1 From 812ad2e6d19148f8b93d6051620ad185222436f1 Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Thu, 16 Dec 2021 22:51:43 -0500 Subject: fix type annotations for mlog nesting In commit 8cd4d0b2832666f19660b9006040e5ff7e5d4576 we added a feature that took True/False but said it took str. --- mesonbuild/mlog.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mesonbuild/mlog.py b/mesonbuild/mlog.py index 60bc09e..bdc9da5 100644 --- a/mesonbuild/mlog.py +++ b/mesonbuild/mlog.py @@ -206,7 +206,7 @@ def process_markup(args: T.Sequence[TV_Loggable], keep: bool) -> T.List[str]: arr.append(str(arg)) return arr -def force_print(*args: str, nested: str, **kwargs: T.Any) -> None: +def force_print(*args: str, nested: bool, **kwargs: T.Any) -> None: if log_disable_stdout: return iostr = io.StringIO() -- cgit v1.1