Skip to content

Allow selection of subdirectory-scoped 'all' targets when using Makefiles - #48

Open
cresswellp wants to merge 2 commits into
ecmwf:developfrom
cresswellp:feature/expose_makefile2_targets
Open

Allow selection of subdirectory-scoped 'all' targets when using Makefiles#48
cresswellp wants to merge 2 commits into
ecmwf:developfrom
cresswellp:feature/expose_makefile2_targets

Conversation

@cresswellp

Copy link
Copy Markdown
Contributor

Description

CMake gives each new add_subdirectory() call its own all target, for building everything in that scope. When using the Ninja generator we can select these targets as --target=foo/all (foo/bar/all, etc.), but when using Makefiles they're defined in CMakeFiles/Makefile2 and not visible to ecbundle. This change adds the relevant Makefile2 targets to the command list, so they can be selected with either generator. Other types of recursive targets (/clean, /install etc.) remain hidden.

Note that Makefile2 targets don't come with the same [XX%] progress counter that Makefile targets do, as they lack the necessary cmake_progress_start infrastructure. We could fake this within ecbundle itself, but it'd either be progress against the whole build which isn't especially useful (e.g. it'd stop at 20% instead of 100%), or else we can try to set up counters per subproject, but then it's not clear what's being measured if targets spanning multiple subprojects are selected. So I've left this as is (no counter).

A new helper function is used to streamline the new tests, so the existing build tests have been updated to use it too.

Contributor Declaration

By opening this pull request, I affirm the following:

  • All authors agree to the Contributor License Agreement.
  • The code follows the project's coding standards.
  • I have performed self-review and added comments where needed.
  • I have added or updated tests to verify that my changes are effective and functional.
  • I have run all existing tests and confirmed they pass.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 49.35%. Comparing base (de8a72c) to head (8cd5ff1).

Additional details and impacted files
@@             Coverage Diff             @@
##           develop      #48      +/-   ##
===========================================
+ Coverage    49.20%   49.35%   +0.14%     
===========================================
  Files           51       51              
  Lines        10385    10409      +24     
===========================================
+ Hits          5110     5137      +27     
+ Misses        5275     5272       -3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 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

Choose a reason for hiding this comment

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

Pull request overview

Adds Makefile support for CMake’s directory-scoped /all targets.

Changes:

  • Routes /all targets through CMakeFiles/Makefile2.
  • Refactors build-script test setup and adds target-routing tests.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
ecbundle/build.py Selects Makefile2 for directory-scoped targets.
tests/bundle_build/test_build.py Adds Make and Ninja routing tests.

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

Comment thread ecbundle/build.py
Comment on lines +97 to +100
if self._needs_directory_recursion_file(targets):
# "/all" targets only exist in Makefile2, not the top-level Makefile
command_list.append("-f CMakeFiles/Makefile2")
command_list.append(self.targets(targets))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this is a valid concern don't you agree? How about also including a test for this?

@wdeconinck

Copy link
Copy Markdown
Member

Thanks @cresswellp this is a very nice consolidation between backends. Please check the copilot suggestion.

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.

4 participants