aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild
diff options
context:
space:
mode:
authorRachel Mant <DX-MON@users.noreply.github.com>2019-08-17 19:12:56 +0100
committerJussi Pakkanen <jpakkane@gmail.com>2019-08-17 21:12:56 +0300
commitf431cff809ec7159c26792e96055747c724e669c (patch)
tree04d4574a7db6b9911ddb70263c455283d0e5b39f /mesonbuild
parent1cb6177f033dcdf59f354376c509f16906165a97 (diff)
downloadmeson-f431cff809ec7159c26792e96055747c724e669c.zip
meson-f431cff809ec7159c26792e96055747c724e669c.tar.gz
meson-f431cff809ec7159c26792e96055747c724e669c.tar.bz2
Make .extract_objects() work correctly as an input to custom_target
Diffstat (limited to 'mesonbuild')
-rw-r--r--mesonbuild/backend/backends.py2
-rw-r--r--mesonbuild/build.py19
-rw-r--r--mesonbuild/interpreter.py5
3 files changed, 19 insertions, 7 deletions
diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py
index 8c2752a..40f9411 100644
--- a/mesonbuild/backend/backends.py
+++ b/mesonbuild/backend/backends.py
@@ -918,6 +918,8 @@ class Backend:
fname = [os.path.join(self.get_target_dir(i), p) for p in i.get_outputs()]
elif isinstance(i, build.GeneratedList):
fname = [os.path.join(self.get_target_private_dir(target), p) for p in i.get_outputs()]
+ elif isinstance(i, build.ExtractedObjects):
+ fname = [os.path.join(self.get_target_private_dir(i.target), p) for p in i.get_outputs(self)]
else:
fname = [i.rel_to_builddir(self.build_to_src)]
if target.absolute_paths:
diff --git a/mesonbuild/build.py b/mesonbuild/build.py
index b77995a..eab2057 100644
--- a/mesonbuild/build.py
+++ b/mesonbuild/build.py
@@ -278,6 +278,13 @@ class ExtractedObjects:
'in Unity builds. You can only extract all '
'the object files for each compiler at once.')
+ def get_outputs(self, backend):
+ # TODO: Consider if we need to handle genlist here
+ return [
+ backend.object_filename_from_source(self.target, source)
+ for source in self.srclist
+ ]
+
class EnvironmentVariables:
def __init__(self):
self.envvars = []
@@ -1911,7 +1918,7 @@ class CustomTarget(Target):
'console',
])
- def __init__(self, name, subdir, subproject, kwargs, absolute_paths=False):
+ def __init__(self, name, subdir, subproject, kwargs, absolute_paths=False, backend=None):
self.typename = 'custom'
# TODO expose keyword arg to make MachineChoice.HOST configurable
super().__init__(name, subdir, subproject, False, MachineChoice.HOST)
@@ -1919,7 +1926,7 @@ class CustomTarget(Target):
self.extra_depends = []
self.depend_files = [] # Files that this target depends on but are not on the command line.
self.depfile = None
- self.process_kwargs(kwargs)
+ self.process_kwargs(kwargs, backend)
self.extra_files = []
# Whether to use absolute paths for all files on the commandline
self.absolute_paths = absolute_paths
@@ -1996,14 +2003,14 @@ class CustomTarget(Target):
raise InvalidArguments('Argument {!r} in "command" is invalid'.format(c))
return final_cmd
- def process_kwargs(self, kwargs):
+ def process_kwargs(self, kwargs, backend):
super().process_kwargs(kwargs)
self.sources = extract_as_list(kwargs, 'input', unholder=True)
if 'output' not in kwargs:
raise InvalidArguments('Missing keyword argument "output".')
self.outputs = listify(kwargs['output'])
# This will substitute values from the input into output and return it.
- inputs = get_sources_string_names(self.sources)
+ inputs = get_sources_string_names(self.sources, backend)
values = get_filenames_templates_dict(inputs, [])
for i in self.outputs:
if not(isinstance(i, str)):
@@ -2370,7 +2377,7 @@ class TestSetup:
self.timeout_multiplier = timeout_multiplier
self.env = env
-def get_sources_string_names(sources):
+def get_sources_string_names(sources, backend):
'''
For the specified list of @sources which can be strings, Files, or targets,
get all the output basenames.
@@ -2383,6 +2390,8 @@ def get_sources_string_names(sources):
names.append(s)
elif isinstance(s, (BuildTarget, CustomTarget, CustomTargetIndex, GeneratedList)):
names += s.get_outputs()
+ elif isinstance(s, ExtractedObjects):
+ names += s.get_outputs(backend)
elif isinstance(s, File):
names.append(s.fname)
else:
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py
index dad15cf..c102978 100644
--- a/mesonbuild/interpreter.py
+++ b/mesonbuild/interpreter.py
@@ -3314,7 +3314,7 @@ external dependencies (including libraries) must go to "dependencies".''')
except mesonlib.MesonException:
mlog.warning('''Custom target input \'%s\' can\'t be converted to File object(s).
This will become a hard error in the future.''' % kwargs['input'], location=self.current_node)
- tg = CustomTargetHolder(build.CustomTarget(name, self.subdir, self.subproject, kwargs), self)
+ tg = CustomTargetHolder(build.CustomTarget(name, self.subdir, self.subproject, kwargs, backend=self.backend), self)
self.add_target(name, tg.held_object)
return tg
@@ -4058,7 +4058,8 @@ Try setting b_lundef to false instead.'''.format(self.coredata.base_options['b_s
sources = [sources]
for s in sources:
if isinstance(s, (mesonlib.File, GeneratedListHolder,
- TargetHolder, CustomTargetIndexHolder)):
+ TargetHolder, CustomTargetIndexHolder,
+ GeneratedObjectsHolder)):
pass
elif isinstance(s, str):
self.validate_within_subproject(self.subdir, s)