Skip to content

Commit 2c008fd

Browse files
paulgessingerclaude
andcommitted
detray: generate propagator codegen headers at build time
Converge detray onto ACTS's build-time codegen model: the four propagator codegen headers are now generated into the build tree by the shared ACTS codegen package via acts_code_generation(), instead of being committed. - Make acts_code_generation() INTERFACE-aware: header-only targets (detray:: core) get the generated include dir on their INTERFACE; compiled targets keep PRIVATE as before. Add an optional RESULT_INCLUDE_DIR out-param used to install the generated headers. - Wire generation in Detray/core/CMakeLists.txt by reusing the in-tree ACTS infra via relative path (../../cmake, ../../codegen) — no published package. - Change the four `#include "./codegen/..."` to full-path includes so they resolve against the build-tree include dir, and delete the committed headers. Verified: configure succeeds; all four detray headers (and the three ACTS headers) generate byte-for-byte identically to the previous output; a consumer TU (ActsExamplesDetray DetrayPropagator.hpp) compiles against them; and the codegen step is correctly ordered before consumers compile. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent f27a897 commit 2c008fd

9 files changed

Lines changed: 70 additions & 2548 deletions

File tree

Detray/core/CMakeLists.txt

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,52 @@ target_include_directories(
7777
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}>
7878
)
7979

80+
# Generate the propagator codegen headers from the shared ACTS sympy codegen
81+
# core instead of committing them. detray is built here via add_subdirectory
82+
# from ACTS, so acts_code_generation is already available; when detray is
83+
# configured standalone inside the acts4 tree, pull the ACTS cmake infra in by
84+
# relative path (../../cmake -> acts4/cmake, ../../codegen -> acts4/codegen).
85+
if(NOT COMMAND acts_code_generation)
86+
include(${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/ActsCodegen.cmake)
87+
endif()
88+
89+
set(_detray_codegen_dir ${CMAKE_CURRENT_SOURCE_DIR}/../codegen/detray-sympy)
90+
set(_acts_codegen_pkg ${CMAKE_CURRENT_SOURCE_DIR}/../../codegen)
91+
92+
foreach(
93+
_spec IN
94+
ITEMS
95+
"gen_transport_covariance_to_bound_impl.py|detray/propagator/actors/codegen/covariance_transport.hpp"
96+
"gen_full_jacobian.py|detray/propagator/actors/codegen/full_jacobian.hpp"
97+
"gen_update_rk_transport_jacobian_impl.py|detray/propagator/codegen/update_rk_transport_jacobian.hpp"
98+
"gen_transport_jacobian_types.py|detray/propagator/codegen/transport_jacobian.hpp"
99+
)
100+
string(REPLACE "|" ";" _spec_parts "${_spec}")
101+
list(GET _spec_parts 0 _script)
102+
list(GET _spec_parts 1 _output)
103+
104+
acts_code_generation(
105+
ADD_TO_TARGET detray_core
106+
PYTHON ${_detray_codegen_dir}/${_script}
107+
WITH_REQUIREMENTS ${_acts_codegen_pkg}/requirements.txt
108+
WITH ${_acts_codegen_pkg}
109+
ISOLATED
110+
OUTPUT ${_output}
111+
RESULT_INCLUDE_DIR _gen_root
112+
)
113+
114+
# Install the generated header alongside the other detray headers so that
115+
# installed (non build-tree) consumers can find it too.
116+
get_filename_component(_output_subdir ${_output} DIRECTORY)
117+
install(
118+
FILES ${_gen_root}/${_output}
119+
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${_output_subdir}
120+
)
121+
endforeach()
122+
123+
unset(_detray_codegen_dir)
124+
unset(_acts_codegen_pkg)
125+
80126
# Set up the libraries that use specific algebra plugins.
81127
detray_add_library( detray_core_array core_array )
82128
target_link_libraries(

Detray/core/include/detray/propagator/actors/codegen/covariance_transport.hpp

Lines changed: 0 additions & 349 deletions
This file was deleted.

Detray/core/include/detray/propagator/actors/codegen/full_jacobian.hpp

Lines changed: 0 additions & 950 deletions
This file was deleted.

Detray/core/include/detray/propagator/actors/parameter_updater.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
#pragma once
1010

1111
// Project include(s).
12-
#include "./codegen/covariance_transport.hpp"
13-
#include "./codegen/full_jacobian.hpp"
12+
#include "detray/propagator/actors/codegen/covariance_transport.hpp"
13+
#include "detray/propagator/actors/codegen/full_jacobian.hpp"
1414
#include "detray/definitions/algebra.hpp"
1515
#include "detray/definitions/detail/qualifiers.hpp"
1616
#include "detray/definitions/track_parametrization.hpp"

0 commit comments

Comments
 (0)