Files
RetroArch/tools/diff_guard_audit.py
T
libretroadmin 4285d72e87 tools: add the settings-group migrator and diff guard audit
The single-source settings campaign is performed by a reusable
migrator rather than by hand; committing it so the method that
produced and validated every migration is part of the history and
survives beyond any one development environment. The migrator
extracts every scattered piece of each setting, verifies
completeness up front, rewires all consumers by in-place
substitution and runs the full gate battery - syntax lanes,
preprocessor token-stream identity in both guard polarities,
structural audits, Crowdin source-json equality, full-language
lookup and settings-dump A/B - keeping nothing unless everything
passes.

The guard audit enumerates every preprocessor guard a diff touches
or sits adjacent to, so each one is either covered by a compile
lane or a structural audit before a commit exists; the rule it
enforces was earned four separate times.
2026-07-03 03:47:19 +02:00

12 lines
641 B
Python
Executable File

#!/usr/bin/env python3
"""Guard audit: given a git diff range, list every #ifdef guard the diff
touches or sits adjacent to, so each gets a -D lane or structural audit."""
import re, subprocess, sys
rng = sys.argv[1] if len(sys.argv) > 1 else 'HEAD~1..HEAD'
d = subprocess.run(['git','diff','-U6',rng], capture_output=True, text=True).stdout
guards = set()
for m in re.finditer(r'^[+\- ].*#\s*(?:ifdef|ifndef|elif|if)\s+(.*)$', d, re.M):
for tok in re.findall(r'\b(HAVE_\w+|RARCH_\w+|_3DS|ANDROID|IOS|OSX|_WIN32|__\w+__)\b', m.group(1)):
guards.add(tok)
print("guards in/adjacent to diff:", sorted(guards) if guards else "none")