Created
May 7, 2026 17:38
-
-
Save bonzini/f39ee1dd6e3c577c42470d6622b51ca8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| From 701876bf5ada7748226b4d0dd575639f9a918bd2 Mon Sep 17 00:00:00 2001 | |
| From: Paolo Bonzini <pbonzini@redhat.com> | |
| Date: Thu, 7 May 2026 19:37:51 +0200 | |
| Subject: [PATCH 0/3] *** SUBJECT HERE *** | |
| *** BLURB HERE *** | |
| Paolo Bonzini (3): | |
| build: fix type for depend_files | |
| build: use Sequence for covariance | |
| build: typing fixes for flatten_command | |
| mesonbuild/build.py | 38 +++++++++++++++++++------------------- | |
| 1 file changed, 19 insertions(+), 19 deletions(-) | |
| -- | |
| 2.54.0 | |
| From a87b8abe6470c62d35661153e0f8874e5578d33d Mon Sep 17 00:00:00 2001 | |
| From: Paolo Bonzini <pbonzini@redhat.com> | |
| Date: Thu, 7 May 2026 19:31:31 +0200 | |
| Subject: [PATCH 1/3] build: fix type for depend_files | |
| Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> | |
| --- | |
| mesonbuild/build.py | 4 ++-- | |
| 1 file changed, 2 insertions(+), 2 deletions(-) | |
| diff --git a/mesonbuild/build.py b/mesonbuild/build.py | |
| index 84a39a48f6..0cfd7eaadc 100644 | |
| --- a/mesonbuild/build.py | |
| +++ b/mesonbuild/build.py | |
| @@ -82,7 +82,7 @@ if T.TYPE_CHECKING: | |
| d_module_versions: T.List[T.Union[str, int]] | |
| d_unittest: bool | |
| dependencies: T.List[dependencies.Dependency] | |
| - depend_files: T.List[File] | |
| + depend_files: T.List[FileOrString] | |
| extra_files: T.List[File] | |
| gnu_symbol_visibility: Literal['default', 'internal', 'hidden', 'protected', 'inlineshidden', ''] | |
| implicit_include_directories: bool | |
| @@ -2920,7 +2920,7 @@ class BothLibraries(SecondLevelHolder): | |
| class CommandBase: | |
| - depend_files: T.List[File] | |
| + depend_files: T.List[FileOrString] | |
| dependencies: T.List[T.Union[BuildTarget, 'CustomTarget']] | |
| subproject: SubProject | |
| -- | |
| 2.54.0 | |
| From ea7b0c2e3fc6f1278358c8eaf959d5667ea66d8e Mon Sep 17 00:00:00 2001 | |
| From: Paolo Bonzini <pbonzini@redhat.com> | |
| Date: Thu, 7 May 2026 19:13:00 +0200 | |
| Subject: [PATCH 2/3] build: use Sequence for covariance | |
| Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> | |
| --- | |
| mesonbuild/build.py | 30 +++++++++++++++--------------- | |
| 1 file changed, 15 insertions(+), 15 deletions(-) | |
| diff --git a/mesonbuild/build.py b/mesonbuild/build.py | |
| index 0cfd7eaadc..55ec04cc03 100644 | |
| --- a/mesonbuild/build.py | |
| +++ b/mesonbuild/build.py | |
| @@ -281,7 +281,7 @@ class Headers(HoldableObject): | |
| def get_install_subdir(self) -> T.Optional[str]: | |
| return self.install_subdir | |
| - def get_sources(self) -> T.List[File]: | |
| + def get_sources(self) -> T.Sequence[File]: | |
| return self.sources | |
| def get_custom_install_dir(self) -> T.Optional[str]: | |
| @@ -306,7 +306,7 @@ class Man(HoldableObject): | |
| def get_custom_install_mode(self) -> 'FileMode': | |
| return self.custom_install_mode | |
| - def get_sources(self) -> T.List['File']: | |
| + def get_sources(self) -> T.Sequence[File]: | |
| return self.sources | |
| @@ -1001,7 +1001,7 @@ class BuildTarget(Target): | |
| FeatureDeprecated.single_use(f'Source file {deprecated_non_objects[0]} in the \'objects\' kwarg is not an object.', | |
| '1.3.0', self.subproject) | |
| - def process_sourcelist(self, sources: T.List['SourceOutputs']) -> None: | |
| + def process_sourcelist(self, sources: T.Sequence[SourceOutputs]) -> None: | |
| """Split sources into generated and static sources. | |
| Sources can be: | |
| @@ -1557,13 +1557,13 @@ class BuildTarget(Target): | |
| uses_rust_abi = isinstance(t, BuildTarget) and t.uses_rust_abi() | |
| t.get_dependencies_recurse(result, visited, include_internals, handled_by_rustc and uses_rust_abi) | |
| - def get_sources(self) -> T.List[File]: | |
| + def get_sources(self) -> T.Sequence[File]: | |
| return self.sources | |
| def get_objects(self) -> T.List[T.Union[str, 'File', 'ExtractedObjects']]: | |
| return self.objects | |
| - def get_generated_sources(self) -> T.List['GeneratedTypes']: | |
| + def get_generated_sources(self) -> T.Sequence[GeneratedTypes]: | |
| return self.generated | |
| def should_install(self) -> bool: | |
| @@ -1621,14 +1621,14 @@ class BuildTarget(Target): | |
| def is_internal(self) -> bool: | |
| return False | |
| - def link(self, targets: T.List[BuildTargetTypes]) -> None: | |
| + def link(self, targets: T.Sequence[BuildTargetTypes]) -> None: | |
| for t in targets: | |
| self.check_can_link_together(t) | |
| self.link_targets.append(t) | |
| def link_whole( | |
| self, | |
| - targets: T.List[StaticTargetTypes], | |
| + targets: T.Sequence[StaticTargetTypes], | |
| promoted: bool = False) -> None: | |
| for t in targets: | |
| self.check_can_link_together(t) | |
| @@ -2470,7 +2470,7 @@ class StaticLibrary(BuildTarget): | |
| def link_whole( | |
| self, | |
| - targets: T.List[StaticTargetTypes], | |
| + targets: T.Sequence[StaticTargetTypes], | |
| promoted: bool = False) -> None: | |
| for t in targets: | |
| self.check_can_link_together(t) | |
| @@ -2486,7 +2486,7 @@ class StaticLibrary(BuildTarget): | |
| self._bundle_static_library(lib, True) | |
| self.link_whole_targets.append(t) | |
| - def link(self, targets: T.List[BuildTargetTypes]) -> None: | |
| + def link(self, targets: T.Sequence[BuildTargetTypes]) -> None: | |
| for t in targets: | |
| if self.install and t.is_internal(): | |
| # When we're a static library and we link_with to an | |
| @@ -2831,7 +2831,7 @@ class SharedLibrary(BuildTarget): | |
| def link_whole( | |
| self, | |
| - targets: T.List[StaticTargetTypes], | |
| + targets: T.Sequence[StaticTargetTypes], | |
| promoted: bool = False) -> None: | |
| for t in targets: | |
| self.check_can_link_together(t) | |
| @@ -2841,7 +2841,7 @@ class SharedLibrary(BuildTarget): | |
| raise InvalidArguments(msg) | |
| self.link_whole_targets.append(t) | |
| - def link(self, targets: T.List[BuildTargetTypes]) -> None: | |
| + def link(self, targets: T.Sequence[BuildTargetTypes]) -> None: | |
| for t in targets: | |
| if isinstance(t, StaticLibrary) and not t.pic: | |
| msg = f"Can't link non-PIC static library {t.name!r} into shared library {self.name!r}. " | |
| @@ -3114,7 +3114,7 @@ class CustomTarget(Target, CustomTargetBase, CommandBase): | |
| def get_filename(self) -> str: | |
| return self.outputs[0] | |
| - def get_sources(self) -> T.List[T.Union[str, File, BuildTarget, GeneratedTypes, ExtractedObjects, programs.Program]]: | |
| + def get_sources(self) -> T.Sequence[T.Union[str, File, BuildTarget, GeneratedTypes, ExtractedObjects, programs.Program]]: | |
| return self.sources | |
| def get_generated_lists(self) -> T.List[GeneratedList]: | |
| @@ -3124,7 +3124,7 @@ class CustomTarget(Target, CustomTargetBase, CommandBase): | |
| genlists.append(c) | |
| return genlists | |
| - def get_generated_sources(self) -> T.List[GeneratedList]: | |
| + def get_generated_sources(self) -> T.Sequence[GeneratedTypes]: | |
| return self.get_generated_lists() | |
| def get_dep_outname(self, infilenames: list[str]) -> str: | |
| @@ -3288,10 +3288,10 @@ class RunTarget(Target, CommandBase): | |
| def get_dependencies(self) -> T.List[BuildTargetTypes]: | |
| return self.dependencies | |
| - def get_generated_sources(self) -> T.List[GeneratedTypes]: | |
| + def get_generated_sources(self) -> T.Sequence[GeneratedTypes]: | |
| return [] | |
| - def get_sources(self) -> T.List[File]: | |
| + def get_sources(self) -> T.Sequence[File]: | |
| return [] | |
| def should_install(self) -> bool: | |
| -- | |
| 2.54.0 | |
| From 701876bf5ada7748226b4d0dd575639f9a918bd2 Mon Sep 17 00:00:00 2001 | |
| From: Paolo Bonzini <pbonzini@redhat.com> | |
| Date: Thu, 7 May 2026 19:13:20 +0200 | |
| Subject: [PATCH 3/3] build: typing fixes for flatten_command | |
| --- | |
| mesonbuild/build.py | 4 ++-- | |
| 1 file changed, 2 insertions(+), 2 deletions(-) | |
| diff --git a/mesonbuild/build.py b/mesonbuild/build.py | |
| index 55ec04cc03..1c143c5baf 100644 | |
| --- a/mesonbuild/build.py | |
| +++ b/mesonbuild/build.py | |
| @@ -2927,7 +2927,7 @@ class CommandBase: | |
| def flatten_command(self, cmd: T.Sequence[T.Union[str, File, programs.Program, BuildTargetTypes]]) -> \ | |
| T.List[T.Union[str, File, BuildTarget, CustomTarget, programs.Program]]: | |
| cmd = listify(cmd) | |
| - final_cmd: T.List[T.Union[str, File, BuildTarget, 'CustomTarget']] = [] | |
| + final_cmd: T.List[T.Union[str, File, BuildTarget, CustomTarget, programs.Program]] = [] | |
| for c in cmd: | |
| if isinstance(c, LocalProgram): | |
| c = c.program | |
| @@ -2952,7 +2952,7 @@ class CommandBase: | |
| elif isinstance(c, CustomTargetIndex): | |
| FeatureNew.single_use('CustomTargetIndex for command argument', '0.60', self.subproject) | |
| self.dependencies.append(c.target) | |
| - final_cmd += self.flatten_command(File.from_built_file(c.get_subdir(), c.get_filename())) | |
| + final_cmd += self.flatten_command([File.from_built_file(c.get_subdir(), c.get_filename())]) | |
| elif isinstance(c, list): | |
| final_cmd += self.flatten_command(c) | |
| else: | |
| -- | |
| 2.54.0 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment