diff options
author | Oliver Reiche <oliver.reiche@huawei.com> | 2025-02-19 14:27:13 +0100 |
---|---|---|
committer | Oliver Reiche <oliver.reiche@huawei.com> | 2025-02-19 14:27:13 +0100 |
commit | 1dcac56d3f2b170617aba19726b92e267261c876 (patch) | |
tree | 84ea46de049bec5eddd5558fbfcff36cb080e9b3 /CC | |
parent | dd143d2ccf1d60ab4b2c077827db800269049393 (diff) | |
download | rules-cc-1dcac56d3f2b170617aba19726b92e267261c876.tar.gz |
Fix include scanner implementations
... which should abort if the preprocessor failed.
Diffstat (limited to 'CC')
-rwxr-xr-x | CC/include_scan | 3 | ||||
-rwxr-xr-x | CC/include_scan.py | 16 |
2 files changed, 7 insertions, 12 deletions
diff --git a/CC/include_scan b/CC/include_scan index 2876075..b7c1590 100755 --- a/CC/include_scan +++ b/CC/include_scan @@ -30,7 +30,8 @@ set -eu readonly OUT_DIR="$1" shift -for FILE in $("$@" | tr ' ' '\n' | sort | uniq); do +STDOUT="$("$@")" || exit $? +for FILE in $(echo "$STDOUT" | tr ' ' '\n' | sort | uniq); do FILE="$(realpath -s -m --relative-to=. "${FILE}")" if expr match "${FILE}" 'include/' >/dev/null; then OUT_PATH="${OUT_DIR}/${FILE}" diff --git a/CC/include_scan.py b/CC/include_scan.py index 1efa528..e169ec5 100755 --- a/CC/include_scan.py +++ b/CC/include_scan.py @@ -33,15 +33,13 @@ import shutil def include_scan(out_dir: str, cmd: list[str]): proc = subprocess.Popen(cmd, stdout=subprocess.PIPE) - if not proc.stdout: - proc.poll() + stdout, _ = proc.communicate() + if not stdout or proc.returncode != 0: exit(proc.returncode) - includes: set[str] = set() - for line in proc.stdout: - items = line.decode('utf-8').replace('\n', ' ') - paths = {os.path.normpath(i) for i in items.split(' ')} - includes |= {p for p in paths if p.startswith('include/')} + items = stdout.decode('utf-8').replace('\n', ' ') + paths = {os.path.normpath(i) for i in items.split(' ')} + includes = {p for p in paths if p.startswith('include/')} for path in includes: out_path = os.path.join(out_dir, path) @@ -55,10 +53,6 @@ def include_scan(out_dir: str, cmd: list[str]): print(e, file=sys.stderr) exit(1) - proc.poll() - if proc.returncode != 0: - exit(proc.returncode) - if __name__ == '__main__': include_scan(out_dir=sys.argv[1], cmd=sys.argv[2:]) |