ninjabackend: Fix vala type annotations

pull/8782/head
Dylan Baker 4 years ago committed by Jussi Pakkanen
parent b1b8e777a2
commit 7659ae50a0
  1. 50
      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():

Loading…
Cancel
Save