build: guard against compiler path truncation warnings
This commit is contained in:
@@ -11,6 +11,7 @@ REQUIRED_COMMANDS = [
|
||||
"python3 tools/validate_typecheck_diagnostics.py",
|
||||
"python3 tools/validate_version_convention.py",
|
||||
"python3 tools/validate_package_security.py",
|
||||
"python3 tools/validate_compiler_warnings.py",
|
||||
"python3 tools/validate_ci_workflow.py",
|
||||
]
|
||||
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Keep the release build free of known path-truncation warnings."""
|
||||
import subprocess
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
|
||||
def main():
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
result = subprocess.run(
|
||||
["gcc", "-std=c99", "-O0", "-c", "src/claro.c", "-o", str(Path(tmp) / "claro.o")],
|
||||
cwd=ROOT,
|
||||
text=True,
|
||||
capture_output=True,
|
||||
)
|
||||
if result.returncode != 0:
|
||||
raise SystemExit(result.stderr or "compiler warning validation could not compile src/claro.c")
|
||||
if "format-truncation" in result.stderr:
|
||||
raise SystemExit("compiler warning validation found -Wformat-truncation warnings:\n" + result.stderr)
|
||||
print("Compiler warning validation complete")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user