Scope the scan to the project's own source - #127
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ 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
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
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_locationsscopes where declarations/headers are wrapped; it is not an implementation-root contract (seeexamples/shapes/wrapper/package_info.yaml:81-83). With a conventionalinclude/foosource location and explicit instantiations undersrc/foo, this silently removes every relevant.cppand template discovery produces incomplete wrappers. Use an explicit implementation-source scope, or exclude known foreign/build trees without assuming.cppfiles 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.
| locations = self._module_source_locations() | ||
| if locations: |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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>
2df4458 to
b8659f0
Compare
|
N/A |
Supports #125
Restrict the scan to the project's real source
Changes:
source_locations. A module that wraps everything (nosource_locations) is left unrestricted.