diff options
Diffstat (limited to 'mesonbuild/build.py')
-rw-r--r-- | mesonbuild/build.py | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/mesonbuild/build.py b/mesonbuild/build.py index c54abbd..d3c0b54 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -425,7 +425,7 @@ class BuildTarget(Target): if s not in added_sources: self.sources.append(s) added_sources[s] = True - elif isinstance(s, (GeneratedList, CustomTarget)): + elif isinstance(s, (GeneratedList, CustomTarget, CustomTargetIndex)): self.generated.append(s) else: msg = 'Bad source of type {!r} in target {!r}.'.format(type(s).__name__, self.name) @@ -1676,6 +1676,15 @@ class CustomTarget(Target): def type_suffix(self): return "@cus" + def __getitem__(self, index): + return CustomTargetIndex(self, self.outputs[index]) + + def __setitem__(self, index, value): + raise NotImplementedError + + def __delitem__(self, index): + raise NotImplementedError + class RunTarget(Target): def __init__(self, name, command, args, dependencies, subdir): super().__init__(name, subdir, False) @@ -1735,6 +1744,29 @@ class Jar(BuildTarget): pass +class CustomTargetIndex: + + """A special opaque object returned by indexing a CustomTaget. This object + exists in meson, but acts as a proxy in the backends, making targets depend + on the CustomTarget it's derived from, but only adding one source file to + the sources. + """ + + def __init__(self, target, output): + self.target = target + self.output = output + + def __repr__(self): + return '<CustomTargetIndex: {!r}[{}]>'.format( + self.target, self.target.output.index(self.output)) + + def get_outputs(self): + return [self.output] + + def get_subdir(self): + return self.target.get_subdir() + + class ConfigureFile: def __init__(self, subdir, sourcename, targetname, configuration_data): |