Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: Add cmake helper function for header compilation #4083

Merged
merged 12 commits into from
Feb 13, 2025

Conversation

paulgessinger
Copy link
Member

@paulgessinger paulgessinger commented Feb 11, 2025

This PR adds a CMake function that will

  • Take all headers given explicitly either by glob or explicitly
  • The first argument is a sort of scope target
  • The function creates a new target with the suffix _HEADERS
  • It loops over all input headers, creates a .cpp file which includes that header, and adds it to the _HEADERS target for compilation
  • The target is excluded from the "default" build to not slow it down.

This will help static analysis tools like clang-tidy, because the compile_commands.json will be populated.

This PR also removes a leftover ACTS_BUILD_NONCOMPILE_TESTS that was unused.

--- END COMMIT MESSAGE ---

Any further description goes here, @-mentions are ok here!

  • Use a conventional commits prefix: quick summary
    • We mostly use feat, fix, refactor, docs, chore and build types.
  • A milestone will be assigned by one of the maintainers

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Integrated an automated header compilation process into various libraries, streamlining the build workflow.
    • Enhanced public interfaces to support improved covariance handling and advanced binning data options for more robust data processing.
  • Bug Fixes

    • Addressed issues related to header file discovery and inclusion for multiple libraries.
  • Refactor / Chores

    • Removed deprecated simulated hit conversion functionality and updated linkage configurations, contributing to a cleaner and more efficient framework.
    • Updated CMake configurations to improve header file management and library dependencies.
    • Added a new CMake option for generating targets to compile header files, enhancing configuration capabilities.
    • Removed the ACTS_BUILD_NONCOMPILE_TESTS option from the configuration settings.

@paulgessinger paulgessinger added this to the next milestone Feb 11, 2025
Copy link

coderabbitai bot commented Feb 11, 2025

Walkthrough

New functionality for header management, introduced across the project it is. A helper function, acts_compile_headers, added to automate header file discovery and compilation via glob patterns in various CMakeLists.txt files. Additional header inclusions and modifications support improvements in covariance handling, binning operations, and dynamic key iteration. Updated test configurations, and some obsolete files removed. Streamlined the overall build and linking process, without altering core library logic, it does.

Changes

Files Change Summary
Core/CMakeLists.txt
Examples/.../CMakeLists.txt
(Digitization, MaterialMapping, Propagation, Traccc, TrackFinding, TrackFindingML, TrackFitting, Detectors (Contextual, Generic, MagneticField, TGeoDetector), Framework, Io/Json, Io/Obj)
Added acts_compile_headers commands with glob patterns to auto-compile header files; consolidated link libraries and include directories.
Core/include/Acts/Propagator/detail/LoopStepperUtils.hpp
Examples/Algorithms/Digitization/include/ActsExamples/Digitization/Smearers.hpp
Examples/Algorithms/MaterialMapping/include/ActsExamples/MaterialMapping/MappingMaterialDecorator.hpp
Examples/Io/Csv/src/CsvOutputData.hpp
Tests/CommonHelpers/include/Acts/Tests/CommonHelpers/TestSpacePoint.hpp
Plugins/Podio/include/Acts/Plugins/Podio/PodioTrackContainer.hpp
Added new header inclusions and code modifications for enhanced functionality (covariance, binning data, tracking geometry, CSV I/O, test source link, dynamic key iteration).
Tests/CommonHelpers/CMakeLists.txt Updated source file paths, include directories, and linking dependencies; added acts_compile_headers call to include headers from the include/Acts directory.
Examples/Algorithms/Propagation/src/SimHitToSummaryConversion.cpp
Examples/Algorithms/TrackFinding/include/ActsExamples/TrackFinding/HoughVectors.hpp
Examples/Io/Obj/include/ActsExamples/Io/Obj/ObjWriterOptions.hpp
Removed obsolete source files and headers no longer needed.
Examples/Io/Json/CMakeLists.txt Added dependency on ActsExamplesTrackFinding in target linking and the acts_compile_headers command for header compilation.
cmake/ActsFunctions.cmake Introduced the acts_compile_headers function to automate header inclusion by generating helper targets, assisting tools like clangd.

Sequence Diagram(s)

sequenceDiagram
    participant CMake as "CMake Build System"
    participant ACHF as "acts_compile_headers()"
    participant FS as "File System"
    participant Target as "Helper Target"

    CMake->>ACHF: Call acts_compile_headers(target, GLOB pattern)
    ACHF->>FS: Scan for header files matching the glob pattern
    FS-->>ACHF: Return list of headers found
    ACHF->>FS: Generate temporary source file for each header
    ACHF->>Target: Create helper target with generated sources
    Target-->>CMake: Link helper target to main target
Loading

Suggested labels

automerge

Suggested reviewers

  • andiwand

Poem

In code’s deep force, a change we find,
Automate headers, wise and aligned.
Globs scan paths, secrets to reveal,
Helper targets form, the build to seal.
Removed the old, embraced the new,
The force in the build flows strong and true.
Hmmm, progress and clarity, our path it did construe.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5a7d03a and c3d65fd.

📒 Files selected for processing (1)
  • cmake/ActsFunctions.cmake (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • cmake/ActsFunctions.cmake
⏰ Context from checks skipped due to timeout of 90000ms (20)
  • GitHub Check: merge-sentinel
  • GitHub Check: unused_files
  • GitHub Check: CI Bridge / lcg_106a: [alma9, gcc14]
  • GitHub Check: CI Bridge / lcg_106a: [alma9, clang16]
  • GitHub Check: macos
  • GitHub Check: CI Bridge / lcg_106a: [alma9, gcc13]
  • GitHub Check: CI Bridge / lcg_105: [alma9, clang16]
  • GitHub Check: linux_ubuntu_extra (ubuntu2204, 20, clang++)
  • GitHub Check: missing_includes
  • GitHub Check: CI Bridge / linux_ubuntu_2204_clang
  • GitHub Check: CI Bridge / lcg_105: [alma9, gcc13]
  • GitHub Check: linux_ubuntu_extra (ubuntu2204, 20, g++)
  • GitHub Check: CI Bridge / linux_ubuntu_2204
  • GitHub Check: CI Bridge / build_linux_ubuntu
  • GitHub Check: linux_ubuntu
  • GitHub Check: build_debug
  • GitHub Check: CI Bridge / build_exatrkx
  • GitHub Check: docs
  • GitHub Check: CI Bridge / clang_tidy
  • GitHub Check: CI Bridge / build_exatrkx_cpu

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added Component - Core Affects the Core module Infrastructure Changes to build tools, continous integration, ... Component - Examples Affects the Examples module Component - Plugins Affects one or more Plugins Track Finding Track Fitting labels Feb 11, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🔭 Outside diff range comments (1)
Tests/CommonHelpers/include/Acts/Tests/CommonHelpers/TestSpacePoint.hpp (1)

56-56: ⚠️ Potential issue

A disturbance in the Force, I sense. Bug in time accessor, there is.

Return m_t instead of m_z, you must. A critical error this is.

Apply this fix, you should:

-  constexpr std::optional<float> t() const { return m_z; }
+  constexpr std::optional<float> t() const { return m_t; }
🧹 Nitpick comments (1)
Examples/Algorithms/Digitization/include/ActsExamples/Digitization/Smearers.hpp (1)

199-209: Optimize the Digital struct's operator(), we should.

Cache the bin boundaries, we could. Multiple lookups of the same values, you perform.

Improve performance thus, you can:

  Acts::Result<std::pair<double, double>> operator()(
      double value, RandomEngine& /*rnd*/) const {
    if (binningData.min < value && binningData.max > value) {
      auto bin = binningData.search(value);
+     const auto& boundaries = binningData.boundaries();
-     auto lower = binningData.boundaries()[bin];
-     auto higher = binningData.boundaries()[bin + 1];
+     auto lower = boundaries[bin];
+     auto higher = boundaries[bin + 1];
      double svalue = 0.5 * (lower + higher);
      return std::pair{svalue, (higher - lower) / std::sqrt(12.)};
    }
    return ActsFatras::DigitizationError::SmearingError;
  }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 25969ed and f410811.

📒 Files selected for processing (26)
  • Core/CMakeLists.txt (1 hunks)
  • Core/include/Acts/Propagator/detail/LoopStepperUtils.hpp (1 hunks)
  • Examples/Algorithms/Digitization/CMakeLists.txt (1 hunks)
  • Examples/Algorithms/Digitization/include/ActsExamples/Digitization/Smearers.hpp (1 hunks)
  • Examples/Algorithms/MaterialMapping/CMakeLists.txt (1 hunks)
  • Examples/Algorithms/MaterialMapping/include/ActsExamples/MaterialMapping/MappingMaterialDecorator.hpp (1 hunks)
  • Examples/Algorithms/Propagation/CMakeLists.txt (1 hunks)
  • Examples/Algorithms/Propagation/src/SimHitToSummaryConversion.cpp (0 hunks)
  • Examples/Algorithms/Traccc/CMakeLists.txt (1 hunks)
  • Examples/Algorithms/TrackFinding/CMakeLists.txt (1 hunks)
  • Examples/Algorithms/TrackFinding/include/ActsExamples/TrackFinding/HoughVectors.hpp (0 hunks)
  • Examples/Algorithms/TrackFindingML/CMakeLists.txt (1 hunks)
  • Examples/Algorithms/TrackFitting/CMakeLists.txt (1 hunks)
  • Examples/Detectors/ContextualDetector/CMakeLists.txt (1 hunks)
  • Examples/Detectors/GenericDetector/CMakeLists.txt (1 hunks)
  • Examples/Detectors/MagneticField/CMakeLists.txt (1 hunks)
  • Examples/Detectors/TGeoDetector/CMakeLists.txt (1 hunks)
  • Examples/Framework/CMakeLists.txt (1 hunks)
  • Examples/Io/Csv/src/CsvOutputData.hpp (1 hunks)
  • Examples/Io/Json/CMakeLists.txt (1 hunks)
  • Examples/Io/Obj/CMakeLists.txt (1 hunks)
  • Examples/Io/Obj/include/ActsExamples/Io/Obj/ObjWriterOptions.hpp (0 hunks)
  • Plugins/Podio/include/Acts/Plugins/Podio/PodioTrackContainer.hpp (1 hunks)
  • Tests/CommonHelpers/CMakeLists.txt (2 hunks)
  • Tests/CommonHelpers/include/Acts/Tests/CommonHelpers/TestSpacePoint.hpp (1 hunks)
  • cmake/ActsFunctions.cmake (1 hunks)
💤 Files with no reviewable changes (3)
  • Examples/Algorithms/TrackFinding/include/ActsExamples/TrackFinding/HoughVectors.hpp
  • Examples/Io/Obj/include/ActsExamples/Io/Obj/ObjWriterOptions.hpp
  • Examples/Algorithms/Propagation/src/SimHitToSummaryConversion.cpp
✅ Files skipped from review due to trivial changes (3)
  • Examples/Algorithms/MaterialMapping/include/ActsExamples/MaterialMapping/MappingMaterialDecorator.hpp
  • Examples/Io/Csv/src/CsvOutputData.hpp
  • Plugins/Podio/include/Acts/Plugins/Podio/PodioTrackContainer.hpp
⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: CI Bridge / build_gnn_tensorrt
  • GitHub Check: merge-sentinel
  • GitHub Check: missing_includes
  • GitHub Check: linux_ubuntu_extra (ubuntu2204, 20, clang++)
  • GitHub Check: linux_ubuntu_extra (ubuntu2204, 20, g++)
  • GitHub Check: linux_ubuntu
  • GitHub Check: docs
  • GitHub Check: macos
  • GitHub Check: build_debug
🔇 Additional comments (26)
cmake/ActsFunctions.cmake (4)

1-7: Well documented, this function is! Hmmmm.

Clear purpose and usage instructions in comments, I see. The force is strong with this documentation.


20-36: Wise error handling, you have implemented.

Prevent simultaneous use of GLOB and HEADERS, you do. Clear error message, you provide. Strong with the validation, this code is.


40-53: Thorough path validation, I sense.

Check for absolute paths, non-existent files, and directories, you do. Prevent confusion and errors early, this will.


70-71: Exclude from default build, you wisely do.

EXCLUDE_FROM_ALL flag, you use. Prevent build slowdown, this will. Link to original target correctly, you do.

Core/include/Acts/Propagator/detail/LoopStepperUtils.hpp (1)

11-13: Strong with types, this code has become.

Added necessary includes for covariance handling and type traits, you have. Improve type safety and clarity, this will.

Examples/Algorithms/Digitization/include/ActsExamples/Digitization/Smearers.hpp (1)

141-153: Wise implementation of binning, I see.

Good initialization of binningData with proper parameters, you have. Clear and maintainable, your code is.

Examples/Algorithms/Propagation/CMakeLists.txt (1)

13-14: Hmmmm, good this change is!

Properly placed after target configuration, the header compilation function is. The Force, strong with this implementation it is.

Examples/Algorithms/Traccc/CMakeLists.txt (1)

17-18: Verify the use with INTERFACE library, we must.

INTERFACE library this is, yet headers compile we attempt. Ensure functioning correctly with such library type, we should.

❌ Verification inconclusive

🏁 Script executed:

#!/bin/bash
# Check if there are any header files to compile
fd . "include" -e hpp

Length of output: 116


#!/bin/bash
# Re-verify header files existence for the TRACCC example.
# The 'acts_compile_headers' command in CMakeLists.txt uses a relative path "include/**/*.hpp".
# Check in the expected directory relative to the CMakeLists.txt file.
find Examples/Algorithms/Traccc/include -type f -name "*.hpp"

Manual verification, please perform. The original command searched in the wrong directory, it did. Ensure that header files exist in the Examples/Algorithms/Traccc/include directory for the INTERFACE library to compile correctly, you must. If header files are present and the INTERFACE target handles them properly as designed, you are. Otherwise, further investigation necessary, it might be.

Examples/Io/Obj/CMakeLists.txt (1)

18-19: Balanced and harmonious, this change is!

In the right place it sits, after target configuration but before installation. The path of the Jedi, this follows.

Examples/Algorithms/MaterialMapping/CMakeLists.txt (1)

18-19: Wise placement of header compilation, this is!

Like a well-trained Padawan, this change follows the established pattern. Pleased with this implementation, I am.

Examples/Algorithms/TrackFindingML/CMakeLists.txt (1)

18-19: Strong with the Force, this implementation is!

Perfect harmony it maintains with other changes. The way of the CMake, this follows.

Examples/Detectors/GenericDetector/CMakeLists.txt (1)

9-9: Hmmmm, good this change is!

Compile the headers, it will. Help the static analysis tools, this shall. Wise placement after library definition, you have chosen.

Examples/Algorithms/Digitization/CMakeLists.txt (1)

20-20: Placed well, this change is!

After library configurations, you have put it. Strong with the Force, this placement is. Compile all digitization headers, it shall.

Examples/Algorithms/TrackFitting/CMakeLists.txt (1)

20-20: Consistent with the Force, this change is!

Follow the ways of other files, you do. Compile the track fitting headers, this shall. Balanced and harmonious, your changes are.

Examples/Io/Json/CMakeLists.txt (2)

21-21: A new ally, ActsExamplesTrackFinding becomes!

Join forces with Json library, it does. Strong together, they shall be.


24-24: In harmony with other files, this change is!

Compile the Json headers, it shall. Follow the path of consistency, you do.

Examples/Detectors/ContextualDetector/CMakeLists.txt (1)

23-23: Complete the circle, this change does!

Like its siblings before it, placed well this function is. Compile the contextual detector headers, it shall. In balance with all other changes, this one is.

Examples/Detectors/MagneticField/CMakeLists.txt (1)

20-20: Approve this change, I do!

Correctly implemented, the header compilation function is. With the force of proper build configuration, strong this one will be.

Tests/CommonHelpers/CMakeLists.txt (3)

7-8: Reorganized source paths, wisdom shows!

To the 'src' directory, moved the source files are. Clear structure, this brings.


18-18: Include path, more specific it becomes!

From root to include directory, the path now points. Better organization, this creates.


26-26: Header compilation, added it is!

For Acts headers specifically, compilation configured is. Good practice, this follows.

Examples/Detectors/TGeoDetector/CMakeLists.txt (1)

25-25: Simple yet powerful, this change is!

Header compilation configuration, properly added it is. With the force of consistency, strong this one remains.

Examples/Algorithms/TrackFinding/CMakeLists.txt (2)

23-23: Consolidated dependencies, clearer they become!

On a single line, the public dependencies now rest. Better readability, this brings.


27-27: Header compilation, properly configured it is!

Following the way of the force, header compilation added it was.

Examples/Framework/CMakeLists.txt (1)

61-61: In harmony with the force, this change is!

After all configurations, header compilation properly placed it is. The way of CMake, followed it has.

Core/CMakeLists.txt (1)

115-116: Wise inclusion of ActsFunctions, this is!

Help with compiler flags, it will. Clear path to better header management, I see.

Copy link

github-actions bot commented Feb 11, 2025

📊: Physics performance monitoring for e22a3e0

Full contents

physmon summary

andiwand
andiwand previously approved these changes Feb 12, 2025
Copy link
Contributor

@andiwand andiwand left a comment

Choose a reason for hiding this comment

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

👍

@paulgessinger
Copy link
Member Author

Added the ability to turn this off via an option.

@github-actions github-actions bot added the Component - Documentation Affects the documentation label Feb 12, 2025
Copy link
Member

@benjaminhuth benjaminhuth left a comment

Choose a reason for hiding this comment

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

Looks good! Some comments here

@paulgessinger
Copy link
Member Author

Done, can you have another look @benjaminhuth?

Copy link
Member

@benjaminhuth benjaminhuth left a comment

Choose a reason for hiding this comment

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

LGTM

@kodiakhq kodiakhq bot merged commit 316a385 into acts-project:main Feb 13, 2025
43 checks passed
@paulgessinger paulgessinger modified the milestones: next, v39.1.0 Feb 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component - Core Affects the Core module Component - Documentation Affects the documentation Component - Examples Affects the Examples module Component - Plugins Affects one or more Plugins Infrastructure Changes to build tools, continous integration, ... Track Finding Track Fitting
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants