diff options
author | Tobias Hunger <tobias.hunger@qt.io> | 2017-06-12 18:58:57 +0200 |
---|---|---|
committer | Tobias Hunger <tobias.hunger@qt.io> | 2017-06-15 08:43:21 +0000 |
commit | b8f1b43b4c72574df97f6e917f38f652a91d9aa6 (patch) | |
tree | 5d52f03334ac5f2bcd3f2cb280a9137c3b3afd76 | |
parent | a570614f3c54fe4bffb1cce6d60e94e769382806 (diff) | |
download | qt-creator-b8f1b43b4c72574df97f6e917f38f652a91d9aa6.tar.gz |
Scripts: Add ninjawrapper.py
Add a small python program to wrap ninja and split its output nicely
into stdout and stderr.
Change-Id: Ib2fae405c170ea15910de20d5f45aaab75aa89cb
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
-rwxr-xr-x | scripts/ninjawrapper.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/scripts/ninjawrapper.py b/scripts/ninjawrapper.py new file mode 100755 index 0000000000..9259d52bc9 --- /dev/null +++ b/scripts/ninjawrapper.py @@ -0,0 +1,31 @@ +#!/usr/bin/python + +'''A simple wrapper around ninja that enables Qt Creator to parse compile errors + + This wrapper splits up ninja output in such a way that Qt Creator will be able + to extract compile errors from the output of this script. + + Make sure that ninja is found in PATH and then override the make build step in + Qt Creator with this script to use it. +''' + +import os, subprocess, sys + +def main(): + stdout = os.fdopen(sys.stdout.fileno(), 'wb') + stderr = os.fdopen(sys.stderr.fileno(), 'wb') + + proc = subprocess.Popen(['ninja'] + sys.argv[1:], stdout=subprocess.PIPE, bufsize=256) + + for line in iter(proc.stdout.readline, b''): + if (line.startswith(b'[') or line.startswith(b'ninja: no work to do')) : + stdout.write(line) + stdout.flush() + else: + stderr.write(line) + stderr.flush() + + return proc.returncode + +if __name__ == '__main__': + sys.exit(main()) |