3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2026-03-15 17:49:59 +00:00

add dependency checks to memory-safety and static-analysis

This commit is contained in:
Angelica Moreira 2026-03-11 21:53:27 +00:00
parent d74f610264
commit ed5b1929f1
2 changed files with 29 additions and 3 deletions

View file

@ -11,6 +11,7 @@ import argparse
import logging
import os
import re
import shutil
import subprocess
import sys
import time
@ -32,6 +33,25 @@ LEAK_ERROR = re.compile(r"ERROR:\s*LeakSanitizer:")
LOCATION = re.compile(r"(\S+\.(?:cpp|c|h|hpp)):(\d+)")
def check_dependencies():
"""Fail early if required build tools are not on PATH."""
missing = []
if not shutil.which("cmake"):
missing.append(("cmake", "sudo apt install cmake"))
if not shutil.which("make"):
missing.append(("make", "sudo apt install build-essential"))
cc = shutil.which("clang") or shutil.which("gcc")
if not cc:
missing.append(("clang or gcc", "sudo apt install clang"))
if missing:
print("required tools not found:", file=sys.stderr)
for tool, install in missing:
print(f" {tool}: {install}", file=sys.stderr)
sys.exit(1)
def find_repo_root() -> Path:
d = Path.cwd()
for _ in range(10):
@ -199,6 +219,7 @@ def main():
args = parser.parse_args()
setup_logging(args.debug)
check_dependencies()
repo_root = find_repo_root()
sanitizers = ["asan", "ubsan"] if args.sanitizer == "both" else [args.sanitizer]

View file

@ -34,9 +34,14 @@ def find_scan_build() -> str:
if path:
logger.debug("found scan-build: %s", path)
return path
logger.error(
"scan-build not found. Install clang-tools or set PATH. "
"Searched: %s", ", ".join(SCAN_BUILD_NAMES)
print(
"scan-build not found on PATH.\n"
"Install one of the following:\n"
" Ubuntu/Debian: sudo apt install clang-tools\n"
" macOS: brew install llvm\n"
" Fedora: sudo dnf install clang-tools-extra\n"
f"searched for: {', '.join(SCAN_BUILD_NAMES)}",
file=sys.stderr,
)
sys.exit(1)