Skip to content

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

Merged
kwabenantim merged 2 commits into
developfrom
125-scope-instantiation-scan
Aug 14, 2026
Merged

Scope the scan to the project's own source#127
kwabenantim merged 2 commits 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 (e94c85f).

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      534           
========================================
+ Hits          2469     2472    +3     
  Misses           5        5           
  Partials         1        1           
Flag Coverage Δ
cells 71.08% <80.00%> (-0.01%) ⬇️
shapes 71.30% <80.00%> (+0.19%) ⬆️
unit 93.25% <100.00%> (+0.08%) ⬆️

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

Files with missing lines Coverage Δ
cppwg/generators.py 99.43% <100.00%> (-0.02%) ⬇️
cppwg/info/module_info.py 100.00% <ø> (ø)
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
Comment thread cppwg/info/package_info.py
@kwabenantim
kwabenantim force-pushed the 125-scope-instantiation-scan branch from 2df4458 to b8659f0 Compare August 13, 2026 18:31
@kwabenantim

This comment was marked as outdated.

@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
kwabenantim and others added 2 commits August 13, 2026 19:42
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.

Two complementary bounds:
- Prune CMake build trees from the walk (a directory containing a
  CMakeCache.txt is skipped wholesale). This is not gated on
  source_locations, so every project gets it - build output and
  dependencies vendored under the build tree are never collected as
  source. An out-of-source build is assumed; in-source builds are not
  supported.
- Scope the .cpp instantiation scan to the module source_locations, the
  same directories that already bound which declarations are wrapped
  (ModuleInfo.is_decl_in_source_path). This lets a project exclude a
  same-named class in any other (non-build) tree under the source root. A
  module with no source_locations wraps everything and leaves the scan
  unrestricted. The source_locations docs are updated to note it now bounds
  the instantiation scan too.

No-op for a clean single-tree project: shapes regenerates byte-identical
and the unit tests pass (with build-tree-exclusion and source_locations-
scoping cases added). 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>
log_unknown_classes rebuilt the per-module source_locations scope inline,
duplicating PackageInfo._module_source_locations (added when the .cpp scan
was scoped). Call the helper instead so the scope is computed in one place,
shared by the instantiation scan, the auto-include type map and this logging.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

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

Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.

@kwabenantim
kwabenantim merged commit ca85410 into develop Aug 14, 2026
18 checks passed
@kwabenantim
kwabenantim deleted the 125-scope-instantiation-scan branch August 14, 2026 09:26
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