diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2021-08-10 11:34:34 -0700 |
---|---|---|
committer | Daniel Mensinger <daniel@mensinger-ka.de> | 2021-08-20 18:57:19 +0200 |
commit | cd7d602f33a22c716ffbd6268eb8315701154ff1 (patch) | |
tree | e58e41fd5c7ff8a60cc418d2c0195381b5a63fd0 | |
parent | b7d5ecc2980912623c94719c64e0e79819499559 (diff) | |
download | meson-cd7d602f33a22c716ffbd6268eb8315701154ff1.zip meson-cd7d602f33a22c716ffbd6268eb8315701154ff1.tar.gz meson-cd7d602f33a22c716ffbd6268eb8315701154ff1.tar.bz2 |
build: Add type annotations for CustomTarget
Again, this is not complete and is just enough for backend.py. Again,
typing these is complicated massively by the layering violations in the
Target classes and the interpreter.
-rw-r--r-- | mesonbuild/build.py | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/mesonbuild/build.py b/mesonbuild/build.py index 64e2ae3..00e2ff1 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -2260,7 +2260,7 @@ class CustomTarget(Target, CommandBase): deps.append(c) return deps - def get_transitive_build_target_deps(self): + def get_transitive_build_target_deps(self) -> T.Set[T.Union[BuildTarget, 'CustomTarget']]: ''' Recursively fetch the build targets that this custom target depends on, whether through `command:`, `depends:`, or `sources:` The recursion is @@ -2269,7 +2269,7 @@ class CustomTarget(Target, CommandBase): F.ex, if you have a python script that loads a C module that links to other DLLs in your project. ''' - bdeps = set() + bdeps: T.Set[T.Union[BuildTarget, 'CustomTarget']] = set() deps = self.get_target_dependencies() for d in deps: if isinstance(d, BuildTarget): @@ -2394,26 +2394,26 @@ class CustomTarget(Target, CommandBase): def get_custom_install_dir(self): return self.install_dir - def get_custom_install_mode(self): + def get_custom_install_mode(self) -> T.Optional['FileMode']: return self.install_mode def get_outputs(self) -> T.List[str]: return self.outputs - def get_filename(self): + def get_filename(self) -> str: return self.outputs[0] - def get_sources(self): + def get_sources(self) -> T.List[T.Union[str, File, 'CustomTarget', 'CustomTargetIndex', 'GeneratedList', 'ExtractedObjects']]: return self.sources - def get_generated_lists(self): - genlists = [] + def get_generated_lists(self) -> T.List[GeneratedList]: + genlists: T.List[GeneratedList] = [] for c in self.sources: if isinstance(c, GeneratedList): genlists.append(c) return genlists - def get_generated_sources(self): + def get_generated_sources(self) -> T.List[GeneratedList]: return self.get_generated_lists() def get_dep_outname(self, infilenames): @@ -2428,12 +2428,11 @@ class CustomTarget(Target, CommandBase): raise InvalidArguments('Substitution in depfile for custom_target that does not have an input file.') return self.depfile - def is_linkable_target(self): + def is_linkable_target(self) -> bool: if len(self.outputs) != 1: return False suf = os.path.splitext(self.outputs[0])[-1] - if suf == '.a' or suf == '.dll' or suf == '.lib' or suf == '.so' or suf == '.dylib': - return True + return suf in {'.a', '.dll', '.lib', '.so', '.dylib'} def get_link_deps_mapping(self, prefix: str, environment: environment.Environment) -> T.Mapping[str, str]: return {} @@ -2453,7 +2452,7 @@ class CustomTarget(Target, CommandBase): return False return True - def extract_all_objects_recurse(self): + def extract_all_objects_recurse(self) -> T.List[T.Union[str, 'ExtractedObjects']]: return self.get_outputs() def type_suffix(self): |