aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2021-08-10 11:30:33 -0700
committerDaniel Mensinger <daniel@mensinger-ka.de>2021-08-20 18:57:19 +0200
commit225022abf6a6067e6453d96013cf0cc4b917b8a3 (patch)
tree8467551da764a3a65b225b5476369d08e183ffa4
parent65d5d9e20c33c55b1c6266041cf9d341deae121c (diff)
downloadmeson-225022abf6a6067e6453d96013cf0cc4b917b8a3.zip
meson-225022abf6a6067e6453d96013cf0cc4b917b8a3.tar.gz
meson-225022abf6a6067e6453d96013cf0cc4b917b8a3.tar.bz2
build: Add type annotations for ExtractedObjects
-rw-r--r--mesonbuild/build.py29
1 files changed, 18 insertions, 11 deletions
diff --git a/mesonbuild/build.py b/mesonbuild/build.py
index e82001a..3bf0e43 100644
--- a/mesonbuild/build.py
+++ b/mesonbuild/build.py
@@ -49,6 +49,8 @@ if T.TYPE_CHECKING:
from .modules import ModuleState
from .backend.backends import Backend, ExecutableSerialisation
+ GeneratedTypes = T.Union['CustomTarget', 'CustomTargetIndex', 'GeneratedList']
+
pch_kwargs = {'c_pch', 'cpp_pch'}
lang_arg_kwargs = {
@@ -364,21 +366,26 @@ class ExtractedObjects(HoldableObject):
'''
Holds a list of sources for which the objects must be extracted
'''
- def __init__(self, target, srclist=None, genlist=None, objlist=None, recursive=True):
+ def __init__(self, target: 'BuildTarget',
+ srclist: T.Optional[T.List[File]] = None,
+ genlist: T.Optional[T.List['GeneratedTypes']] = None,
+ objlist: T.Optional[T.List[T.Union[str, 'File', 'ExtractedObjects']]] = None,
+ recursive: bool = True):
self.target = target
self.recursive = recursive
- self.srclist = srclist if srclist is not None else []
- self.genlist = genlist if genlist is not None else []
- self.objlist = objlist if objlist is not None else []
+ self.srclist: T.List[File] = srclist if srclist is not None else []
+ self.genlist: T.List['GeneratedTypes'] = genlist if genlist is not None else []
+ self.objlist: T.Optional[T.List[T.Union[str, 'File', 'ExtractedObjects']]] = \
+ objlist if objlist is not None else []
if self.target.is_unity:
self.check_unity_compatible()
- def __repr__(self):
+ def __repr__(self) -> str:
r = '<{0} {1!r}: {2}>'
return r.format(self.__class__.__name__, self.target.name, self.srclist)
@staticmethod
- def get_sources(sources, generated_sources):
+ def get_sources(sources: T.Sequence['FileOrString'], generated_sources: T.Sequence['GeneratedTypes']) -> T.List['FileOrString']:
# Merge sources and generated sources
sources = list(sources)
for gensrc in generated_sources:
@@ -391,11 +398,11 @@ class ExtractedObjects(HoldableObject):
# Filter out headers and all non-source files
return [s for s in sources if environment.is_source(s) and not environment.is_header(s)]
- def classify_all_sources(self, sources, generated_sources):
- sources = self.get_sources(sources, generated_sources)
- return classify_unity_sources(self.target.compilers.values(), sources)
+ def classify_all_sources(self, sources: T.List[str], generated_sources: T.Sequence['GeneratedTypes']) -> T.Dict['Compiler', T.List['FileOrString']]:
+ sources_ = self.get_sources(sources, generated_sources)
+ return classify_unity_sources(self.target.compilers.values(), sources_)
- def check_unity_compatible(self):
+ def check_unity_compatible(self) -> None:
# Figure out if the extracted object list is compatible with a Unity
# build. When we're doing a Unified build, we go through the sources,
# and create a single source file from each subset of the sources that
@@ -411,7 +418,7 @@ class ExtractedObjects(HoldableObject):
'in Unity builds. You can only extract all '
'the object files for each compiler at once.')
- def get_outputs(self, backend):
+ def get_outputs(self, backend: 'Backend') -> T.List[str]:
return [
backend.object_filename_from_source(self.target, source)
for source in self.get_sources(self.srclist, self.genlist)