diff --git a/.github/skills/memory-safety/scripts/memory_safety.py b/.github/skills/memory-safety/scripts/memory_safety.py index cab818a63..fa87f8f8c 100644 --- a/.github/skills/memory-safety/scripts/memory_safety.py +++ b/.github/skills/memory-safety/scripts/memory_safety.py @@ -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] diff --git a/.github/skills/static-analysis/scripts/static_analysis.py b/.github/skills/static-analysis/scripts/static_analysis.py index aa64d883d..65f87e731 100644 --- a/.github/skills/static-analysis/scripts/static_analysis.py +++ b/.github/skills/static-analysis/scripts/static_analysis.py @@ -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)