Skip to content

Scope the scan to the project's own source - #127

Open
kwabenantim wants to merge 1 commit into
developfrom
125-scope-instantiation-scan
Open

Scope the scan to the project's own source#127
kwabenantim wants to merge 1 commit into
developfrom
125-scope-instantiation-scan

Conversation

@kwabenantim

Copy link
Copy Markdown
Member

Supports #125

Restrict the scan to the project's real source

Changes:

  • Skip CMake build trees in the source walk (a directory containing a CMakeCache.txt).
  • Scope the .cpp instantiation scan to the module source_locations. A module that wraps everything (no source_locations) is left unrestricted.

@kwabenantim
kwabenantim marked this pull request as ready for review August 13, 2026 18:12
@kwabenantim
kwabenantim requested a balanced review from Copilot August 13, 2026 18:12
@kwabenantim kwabenantim linked an issue Aug 13, 2026 that may be closed by this pull request
@codecov

codecov Bot commented Aug 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.75%. Comparing base (f570136) to head (b8659f0).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##           develop     #127   +/-   ##
========================================
  Coverage    99.75%   99.75%           
========================================
  Files           31       31           
  Lines         2475     2478    +3     
  Branches       534      535    +1     
========================================
+ Hits          2469     2472    +3     
  Misses           5        5           
  Partials         1        1           
Flag Coverage Δ
cells 71.04% <50.00%> (-0.05%) ⬇️
shapes 71.06% <50.00%> (-0.05%) ⬇️
unit 93.17% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
cppwg/info/package_info.py 99.43% <100.00%> (+<0.01%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Restricts source scanning to reduce wrapper-generation overhead and avoid foreign files.

Changes:

  • Prunes detected CMake build trees.
  • Filters implementation files using module source locations.
Suppressed comments (1)

cppwg/info/package_info.py:356

  • source_locations scopes where declarations/headers are wrapped; it is not an implementation-root contract (see examples/shapes/wrapper/package_info.yaml:81-83). With a conventional include/foo source location and explicit instantiations under src/foo, this silently removes every relevant .cpp and template discovery produces incomplete wrappers. Use an explicit implementation-source scope, or exclude known foreign/build trees without assuming .cpp files are colocated with their headers.
            cpp_files = [
                filepath
                for filepath in cpp_files
                if any(location in Path(filepath).parents for location in locations)

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread cppwg/info/package_info.py Outdated
Comment on lines +351 to +352
locations = self._module_source_locations()
if locations:

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The source_locations .cpp scoping this refers to has been removed (see the PR comment below), so there's no restricted-location branch left to cover. The remaining change — pruning CMake build trees — is now covered by test_collect_source_files_skips_cmake_build_trees: a nested build tree (marked by CMakeCache.txt) containing a stale Foo.cpp and a vendored dependency is excluded, while the real source Foo.cpp is kept.

# foreign copy of a file is never wanted. In particular a dependency
# vendored under the build tree must not have its classes mistaken for
# the project's own by unqualified base name.
if "CMakeCache.txt" in filenames:

@kwabenantim kwabenantim Aug 13, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure it's useful to support in-source builds since this is generally bad practice. We want to be able to tell real source files from generated build-tree files.

cppwg walks the source root for .cpp/.hpp and matches classes by
unqualified base name, so any same-named class from another tree under the
root is conflated with a wrapped class. For pychaste this happens in
practice: the build tree carries cppwg's own cells example (fetched under
_deps), whose Node/PottsMesh/... share base names with Chaste's, so their
differing explicit instantiations merged into the wrapped classes' data.
The generated output then depended on transient build-tree contents.

Prune CMake build trees from the walk: a directory containing a
CMakeCache.txt is skipped wholesale, so build output and dependencies
vendored under it are never collected as source. This is not gated on
source_locations, so it applies to every project (an out-of-source build
is assumed; in-source builds are not supported).

No-op for a clean single-tree project: shapes regenerates byte-identical
and 481 unit tests pass (incl. a new build-tree-exclusion test). For
pychaste it removes the contamination; the only change to the committed
package is Node/PottsMesh instantiation ordering (("1",) restored to the
front), no set change.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@kwabenantim
kwabenantim force-pushed the 125-scope-instantiation-scan branch from 2df4458 to b8659f0 Compare August 13, 2026 18:31
@kwabenantim

kwabenantim commented Aug 13, 2026

Copy link
Copy Markdown
Member Author

N/A

@kwabenantim kwabenantim changed the title #125 Scope the scan to the project's own source Scope the scan to the project's own source Aug 13, 2026
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.

Speed up wrapper generation

2 participants