mirror of
https://github.com/libretro/parallel-ps2.git
synced 2026-11-09 17:28:25 -10:00
Spelling out the iterator unstable_remove_if returned named libstdc++'s own __gnu_cxx::__normal_iterator, which only libstdc++ has: the Android, macOS and Windows builds (libc++, MSVC) failed on page_tracker.cpp. The two handle-list sweeps are now plain index loops that swap a dropped handle with the last kept one and cut the tail off, the same compaction in the same order, with no iterator, lambda or library-specific type in them. tests/stdlib fails when a core source names a standard library's internals, and syntax-checks every C++ unit of the CMake build against libc++; the test workflow installs clang and libc++ for it.
60 lines
1.6 KiB
Python
60 lines
1.6 KiB
Python
"""Syntax-checks every C++ unit of a configured CMake build.
|
|
|
|
Usage: sweep.py <compile_commands.json>
|
|
|
|
Each unit's own compile command is run with -fsyntax-only in place of
|
|
-c/-o, in parallel. A unit whose source is generated during the build
|
|
(and so is not there yet) is skipped. Exits non-zero if any unit fails,
|
|
or if there was nothing to check.
|
|
"""
|
|
import concurrent.futures
|
|
import json
|
|
import os
|
|
import shlex
|
|
import subprocess
|
|
import sys
|
|
|
|
|
|
def command(entry):
|
|
args = shlex.split(entry["command"])
|
|
out = []
|
|
skip = False
|
|
for a in args:
|
|
if skip:
|
|
skip = False
|
|
continue
|
|
if a == "-o":
|
|
skip = True
|
|
continue
|
|
if a == "-c":
|
|
continue
|
|
out.append(a)
|
|
out.append("-fsyntax-only")
|
|
return out
|
|
|
|
|
|
def check(entry):
|
|
r = subprocess.run(command(entry), cwd=entry["directory"],
|
|
capture_output=True, text=True)
|
|
errors = [l for l in r.stderr.splitlines() if "error" in l]
|
|
return entry["file"], r.returncode, errors
|
|
|
|
|
|
def main():
|
|
entries = [e for e in json.load(open(sys.argv[1]))
|
|
if e["file"].endswith(".cpp") and os.path.exists(e["file"])]
|
|
failed = 0
|
|
with concurrent.futures.ThreadPoolExecutor(os.cpu_count() or 2) as ex:
|
|
for name, rc, errors in ex.map(check, entries):
|
|
if rc:
|
|
failed += 1
|
|
print("FAIL " + name)
|
|
for l in errors[:10]:
|
|
print(" " + l)
|
|
print("%d C++ units checked against libc++, %d failed" % (len(entries), failed))
|
|
return 1 if failed or not entries else 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|