diff options
author | Elliott Sales de Andrade <quantum.analyst@gmail.com> | 2016-08-24 04:35:15 -0400 |
---|---|---|
committer | Elliott Sales de Andrade <quantum.analyst@gmail.com> | 2016-08-26 20:46:42 -0400 |
commit | 70d94a555004563178878b73274e345adff5b4e8 (patch) | |
tree | a5944eecebc2992e322e42364148d63ba73acda8 /mesonbuild/scripts | |
parent | dcaf2d7b3d010526eb5035fec788f1b9a854262c (diff) | |
download | meson-70d94a555004563178878b73274e345adff5b4e8.zip meson-70d94a555004563178878b73274e345adff5b4e8.tar.gz meson-70d94a555004563178878b73274e345adff5b4e8.tar.bz2 |
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.
Diffstat (limited to 'mesonbuild/scripts')
-rw-r--r-- | mesonbuild/scripts/meson_exe.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/mesonbuild/scripts/meson_exe.py b/mesonbuild/scripts/meson_exe.py index f075fa0..cdfed09 100644 --- a/mesonbuild/scripts/meson_exe.py +++ b/mesonbuild/scripts/meson_exe.py @@ -59,6 +59,11 @@ def run_exe(exe): stderr=subprocess.PIPE, env=child_env, cwd=exe.workdir) + stdout, stderr = p.communicate() + if exe.capture and p.returncode == 0: + with open(exe.capture, 'wb') as output: + output.write(stdout) + return p.returncode def run(args): global options @@ -68,7 +73,7 @@ def run(args): print(sys.argv[0] + ' [data file]') exe_data_file = options.args[0] exe = pickle.load(open(exe_data_file, 'rb')) - run_exe(exe) + return run_exe(exe) if __name__ == '__main__': sys.exit(run(sys.argv[1:])) |