aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavier Claessens <xavier.claessens@collabora.com>2022-03-17 15:07:07 -0400
committerXavier Claessens <xclaesse@gmail.com>2022-09-26 15:39:06 -0400
commitfa254229b717d921c64f182cba33b30a10e19ace (patch)
treed70d40d520792353d44ac4ec0edfe9077b2fc882
parent462759dd3319d47f4c09a63ee8dfc5deab7eef63 (diff)
downloadmeson-fa254229b717d921c64f182cba33b30a10e19ace.zip
meson-fa254229b717d921c64f182cba33b30a10e19ace.tar.gz
meson-fa254229b717d921c64f182cba33b30a10e19ace.tar.bz2
ninjabackend: Fix get_target_generated_sources() return type
Type annotation, documentation string, and implementation were doing 3 different things. Change implementation to match type annotation which makes the most sense because it match what get_target_sources() does. All callers only use keys from the returned dictionary any way, but that's going to change in next commits.
-rw-r--r--mesonbuild/backend/ninjabackend.py17
-rw-r--r--mesonbuild/mesonlib/universal.py5
2 files changed, 12 insertions, 10 deletions
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py
index 9733465..d8f2122 100644
--- a/mesonbuild/backend/ninjabackend.py
+++ b/mesonbuild/backend/ninjabackend.py
@@ -707,14 +707,14 @@ class NinjaBackend(backends.Backend):
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.
+ (relative to the build directory) and the value being the File object
+ representing the same path.
"""
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
+ rel_src = self.get_target_generated_dir(target, gensrc, s)
+ srcs[rel_src] = File.from_built_relative(rel_src)
return srcs
def get_target_sources(self, target: build.BuildTarget) -> T.MutableMapping[str, File]:
@@ -881,8 +881,7 @@ class NinjaBackend(backends.Backend):
# same time, also deal with generated sources that need to be compiled.
generated_source_files = []
for rel_src in generated_sources.keys():
- dirpart, fnamepart = os.path.split(rel_src)
- raw_src = File(True, dirpart, fnamepart)
+ raw_src = File.from_built_relative(rel_src)
if self.environment.is_source(rel_src) and not self.environment.is_header(rel_src):
if is_unity and self.get_target_source_can_unity(target, rel_src):
unity_deps.append(raw_src)
@@ -943,8 +942,7 @@ class NinjaBackend(backends.Backend):
# often contain duplicate symbols and will fail to compile properly
vala_generated_source_files = []
for src in transpiled_sources:
- dirpart, fnamepart = os.path.split(src)
- raw_src = File(True, dirpart, fnamepart)
+ raw_src = File.from_built_relative(src)
# Generated targets are ordered deps because the must exist
# before the sources compiling them are used. After the first
# compile we get precise dependency info from dep files.
@@ -1327,8 +1325,7 @@ class NinjaBackend(backends.Backend):
generated_sources = self.get_target_generated_sources(target)
gen_src_list = []
for rel_src in generated_sources.keys():
- dirpart, fnamepart = os.path.split(rel_src)
- raw_src = File(True, dirpart, fnamepart)
+ raw_src = File.from_built_relative(rel_src)
if rel_src.endswith('.java'):
gen_src_list.append(raw_src)
diff --git a/mesonbuild/mesonlib/universal.py b/mesonbuild/mesonlib/universal.py
index f5a69a6..bdf3d49 100644
--- a/mesonbuild/mesonlib/universal.py
+++ b/mesonbuild/mesonlib/universal.py
@@ -419,6 +419,11 @@ class File(HoldableObject):
return File(True, subdir, fname)
@staticmethod
+ def from_built_relative(relative: str) -> 'File':
+ dirpart, fnamepart = os.path.split(relative)
+ return File(True, dirpart, fnamepart)
+
+ @staticmethod
def from_absolute_file(fname: str) -> 'File':
return File(False, '', fname)