diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2021-04-27 11:30:40 -0700 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2021-05-19 23:28:17 +0300 |
commit | 7659ae50a0e051311dc6b003ed5d66022669cf0b (patch) | |
tree | 8496b0c16b70f8e22a4f68b110dc06d07c915258 | |
parent | b1b8e777a226a347785a162161d1c68e041dc5c9 (diff) | |
download | meson-7659ae50a0e051311dc6b003ed5d66022669cf0b.zip meson-7659ae50a0e051311dc6b003ed5d66022669cf0b.tar.gz meson-7659ae50a0e051311dc6b003ed5d66022669cf0b.tar.bz2 |
ninjabackend: Fix vala type annotations
-rw-r--r-- | mesonbuild/backend/ninjabackend.py | 50 |
1 files changed, 26 insertions, 24 deletions
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index c2ce827..bf3a6d7 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -602,21 +602,21 @@ int dummy; target.cached_generated_headers = header_deps return header_deps - def get_target_generated_sources(self, target): + def get_target_generated_sources(self, target: build.BuildTarget) -> T.MutableMapping[str, File]: """ Returns a dictionary with the keys being the path to the file (relative to the build directory) of that type and the value being the GeneratorList or CustomTarget that generated it. """ - srcs = OrderedDict() + srcs: T.MutableMapping[str, File] = OrderedDict() for gensrc in target.get_generated_sources(): for s in gensrc.get_outputs(): f = self.get_target_generated_dir(target, gensrc, s) srcs[f] = s return srcs - def get_target_sources(self, target): - srcs = OrderedDict() + def get_target_sources(self, target: build.BuildTarget) -> T.MutableMapping[str, File]: + srcs: T.MutableMapping[str, File] = OrderedDict() for s in target.get_sources(): # BuildTarget sources are always mesonlib.File files which are # either in the source root, or generated with configure_file and @@ -722,26 +722,27 @@ int dummy; self.generate_swift_target(target) return - # Now we handle the following languages: - # ObjC++, ObjC, C++, C, D, Fortran, Vala - - # target_sources: - # Pre-existing target C/C++ sources to be built; dict of full path to - # source relative to build root and the original File object. - # generated_sources: - # GeneratedList and CustomTarget sources to be built; dict of the full - # path to source relative to build root and the generating target/list - # vala_generated_sources: - # Array of sources generated by valac that have to be compiled + # Pre-existing target C/C++ sources to be built; dict of full path to + # source relative to build root and the original File object. + target_sources: T.MutableMapping[str, File] + + # GeneratedList and CustomTarget sources to be built; dict of the full + # path to source relative to build root and the generating target/list + generated_sources: T.MutableMapping[str, File] + + # List of sources that have been transpiled from a DSL (like Vala) into + # a language that is haneled below, such as C or C++ + transpiled_sources: T.List[str] + if 'vala' in target.compilers: # Sources consumed by valac are filtered out. These only contain # C/C++ sources, objects, generated libs, and unknown sources now. target_sources, generated_sources, \ - vala_generated_sources = self.generate_vala_compile(target) + transpiled_sources = self.generate_vala_compile(target) else: target_sources = self.get_target_sources(target) generated_sources = self.get_target_generated_sources(target) - vala_generated_sources = [] + transpiled_sources = [] self.scan_fortran_module_outputs(target) # Generate rules for GeneratedLists self.generate_generator_list_rules(target) @@ -817,7 +818,7 @@ int dummy; # Do not try to unity-build the generated c files from vala, as these # often contain duplicate symbols and will fail to compile properly vala_generated_source_files = [] - for src in vala_generated_sources: + for src in transpiled_sources: dirpart, fnamepart = os.path.split(src) raw_src = File(True, dirpart, fnamepart) # Generated targets are ordered deps because the must exist @@ -1358,7 +1359,7 @@ int dummy; break return list(result) - def split_vala_sources(self, t: build.Target) -> \ + def split_vala_sources(self, t: build.BuildTarget) -> \ T.Tuple[T.MutableMapping[str, File], T.MutableMapping[str, File], T.Tuple[T.MutableMapping[str, File], T.MutableMapping]]: """ @@ -1372,7 +1373,7 @@ int dummy; vala: T.MutableMapping[str, File] = OrderedDict() vapi: T.MutableMapping[str, File] = OrderedDict() others: T.MutableMapping[str, File] = OrderedDict() - othersgen = OrderedDict() + othersgen: T.MutableMapping[str, File] = OrderedDict() # Split pre-existing sources for s in t.get_sources(): # BuildTarget sources are always mesonlib.File files which are @@ -1413,7 +1414,8 @@ int dummy; srctype[f] = gensrc return vala, vapi, (others, othersgen) - def generate_vala_compile(self, target: build.BuildTarget): + def generate_vala_compile(self, target: build.BuildTarget) -> \ + T.Tuple[T.MutableMapping[str, File], T.MutableMapping[str, File], T.List[str]]: """Vala is compiled into C. Set up all necessary build steps here.""" (vala_src, vapi_src, other_src) = self.split_vala_sources(target) extra_dep_files = [] @@ -1424,11 +1426,11 @@ int dummy; valac = target.compilers['vala'] c_out_dir = self.get_target_private_dir(target) # C files generated by valac - vala_c_src = [] + vala_c_src: T.List[str] = [] # Files generated by valac - valac_outputs = [] + valac_outputs: T.List = [] # All sources that are passed to valac on the commandline - all_files = list(vapi_src.keys()) + all_files = list(vapi_src) # Passed as --basedir srcbasedir = os.path.join(self.build_to_src, target.get_subdir()) for (vala_file, gensrc) in vala_src.items(): |