Skip to content

Add whole-project multi-file analysis: pagurus-check script and pagurus.mk Makefile include#20

Merged
DavidLee18 merged 3 commits intomainfrom
copilot/extend-plugin-functionality-makefile
Mar 12, 2026
Merged

Add whole-project multi-file analysis: pagurus-check script and pagurus.mk Makefile include#20
DavidLee18 merged 3 commits intomainfrom
copilot/extend-plugin-functionality-makefile

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 12, 2026

The plugin analyzed one translation unit at a time with no tooling to run it across a Makefile-based project. This adds two standalone integration artifacts and a test suite for them.

pagurus-check — CLI script for project-wide analysis

Runs the plugin across many files, aggregates results, exits non-zero on any error.

# Scan a directory with 4 parallel workers
./pagurus-check --plugin=./build/pagurus_plugin.so \
                --cflags="-Iinclude" --jobs=4 --dir=src

# Use exact per-file flags from a compilation database (bear make)
bear make
./pagurus-check --compile-db=compile_commands.json

# Dry-run: report all diagnostics, no .pagurus.c written
./pagurus-check --dry-run --dir=src

Key options: --dir (recursive *.c scan), --compile-db (awk-parsed compile_commands.json, compatible with bear make and cmake), --jobs (continuous job pool, not batch), --dry-run, --ir-pass.

Dependencies: pagurus_plugin.so, clang, and standard POSIX tools (bash ≥ 4, awk, find, grep) — no Python, Perl, or jq required.

pagurus.mk — drop-in Makefile include

SOURCES        = src/main.c src/widget.c
PAGURUS_PLUGIN = /path/to/build/pagurus_plugin.so
include /path/to/pagurus.mk
make pagurus-check      # compile mode — borrow-check PAGURUS_SOURCES
make pagurus-dry-run    # inspect only, no output files
make pagurus-clean      # remove *.pagurus.c artefacts

Inherits CFLAGS/SOURCES automatically; all variables are overridable (PAGURUS_CLANG, PAGURUS_CFLAGS, PAGURUS_JOBS, PAGURUS_IR_PASS).

Dependencies: pagurus_plugin.so, clang, and make — no extra tools required.

Tests

  • tests/multifile/ — two-file project (widget.c with intentional E001, main.c clean) with an embedded Makefile using pagurus.mk
  • tests/run_multifile_tests.sh — 10 tests covering --dir, --compile-db, --dry-run, exit codes, and both pagurus.mk targets
  • Registered as CTest test pagurus_multifile

README

New "Multi-file project integration" section covering both tools, the bear make + --compile-db workflow, and a per-TU analysis scope table.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

…akefile include

Co-authored-by: DavidLee18 <36877989+DavidLee18@users.noreply.github.com>
Copilot AI changed the title [WIP] Add multi-file project analysis support to plugin Add whole-project multi-file analysis: pagurus-check script and pagurus.mk Makefile include Mar 12, 2026
@DavidLee18 DavidLee18 marked this pull request as ready for review March 12, 2026 05:01
@DavidLee18
Copy link
Copy Markdown
Owner

@copilot so, pagurus-ckeck and pagurus.mk depends on the plugin only, right? if not, make so, and if that's not possible, demonstrate why thoroughly.

…ompile_commands.json parser

Co-authored-by: DavidLee18 <36877989+DavidLee18@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 12, 2026

@copilot so, pagurus-ckeck and pagurus.mk depends on the plugin only, right? if not, make so, and if that's not possible, demonstrate why thoroughly.

Both tools now depend only on the plugin + standard POSIX tools:

  • pagurus.mk — was already dependency-free beyond make, clang, and pagurus_plugin.so
  • pagurus-check — had a python3 dependency for parsing compile_commands.json (--compile-db). Replaced with a pure awk implementation in commit 662b162.

The only dependencies for both tools are now:

Dependency Why Avoidable?
pagurus_plugin.so The checker itself No
clang Runs the plugin No — same requirement as any pagurus usage
bash ≥ 4, awk, find, grep Standard POSIX tools Present on any system where clang is installed

The awk parser handles both "command" (string, from bear) and "arguments" (array, from cmake) formats. One documented limitation: arguments with spaces in their values are not supported in the "command" string format (since space is the token separator); the "arguments" array format handles spaces correctly. In practice, bear and cmake produce absolute paths without spaces.

@DavidLee18 DavidLee18 merged commit 3d0c24c into main Mar 12, 2026
45 checks passed
@DavidLee18 DavidLee18 deleted the copilot/extend-plugin-functionality-makefile branch March 12, 2026 07:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants