From 70d94a555004563178878b73274e345adff5b4e8 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Wed, 24 Aug 2016 04:35:15 -0400 Subject: Allow capturing command output of a custom target. For commands that always output to stdout and don't have a "-o" or "--output" or some other similar option, this 'capture' setting allows the build to capture the result and place it in the output file. --- mesonbuild/build.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'mesonbuild/build.py') diff --git a/mesonbuild/build.py b/mesonbuild/build.py index dd03d81..48d7843 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -927,6 +927,7 @@ class CustomTarget: known_kwargs = {'input' : True, 'output' : True, 'command' : True, + 'capture' : False, 'install' : True, 'install_dir' : True, 'build_always' : True, @@ -982,6 +983,10 @@ class CustomTarget: raise InvalidArguments('Output argument not a string.') if '/' in i: raise InvalidArguments('Output must not contain a path segment.') + self.capture = kwargs.get('capture', False) + if self.capture and len(self.output) != 1: + raise InvalidArguments( + 'Capturing can only output to a single file.') if 'command' not in kwargs: raise InvalidArguments('Missing keyword argument "command".') cmd = kwargs['command'] -- cgit v1.1 From 3e09aa9f11e855bc0979d4e0920c1059a4c2e319 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Wed, 24 Aug 2016 15:47:07 -0400 Subject: Don't allow @OUTPUT@ when capturing output. --- mesonbuild/build.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'mesonbuild/build.py') diff --git a/mesonbuild/build.py b/mesonbuild/build.py index 48d7843..ace4853 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -1015,6 +1015,9 @@ class CustomTarget: else: raise InvalidArguments('Argument %s in "command" is invalid.' % i) self.command = final_cmd + if self.capture and '@OUTPUT@' in self.command: + raise InvalidArguments( + '@OUTPUT@ is not allowed when capturing output.') if 'install' in kwargs: self.install = kwargs['install'] if not isinstance(self.install, bool): -- cgit v1.1