docs/rationale/generated-file-filter-globs.md
Users repeatedly ask to keep machine-generated sources - Qt moc_*.cpp,
protobuf *.pb.cc, and the output of other code generators - out of
compile_commands.json, so that clang-tidy and editor tooling run only over
hand-written code. Two shapes were considered:
Glob matching needs a dependency. The candidates were glob (rust-lang owned,
no transitive dependencies) and globset (faster, but pulls in
regex-automata and its dependencies). Bear's source filtering runs once per
entry over a set that is small relative to a whole build; matching speed is not
a bottleneck.
User-supplied glob rules, evaluated with the same last-match-wins semantics as
the directory rules. Use the glob crate for its zero-transitive-dependency
footprint. Split basename-vs-full-path matching on whether the pattern contains
a path separator, following the gitignore convention so that users' intuition
carries over.
There is no out-of-the-box filtering: a user writes two lines of configuration
to exclude a generator's output. The man page carries the moc/protobuf recipes
so the common cases are copy-paste. Directory rules and file-pattern rules
compose (both must accept an entry), so the two mechanisms mix without
surprising interactions. Revisit the globset choice only if profiling ever
shows glob matching to be a real cost.
output-generated-file-filtersource-filter-last-match-wins