Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
6387ef6
feat(Geometry): add GeometryModule infrastructure with loader and hel…
paulgessinger Mar 10, 2026
65e9b66
refactor(Geometry): update GeometryModule interfaces and loader
paulgessinger Mar 10, 2026
3511502
refactor(Geometry): remove GeometryModuleCommon, simplify helpers
paulgessinger Mar 10, 2026
5f789c8
refactor(Geometry): update GeometryModuleLoader interface
paulgessinger Mar 10, 2026
375addb
ci: add geometry module to CI and DownstreamProject
paulgessinger Mar 10, 2026
841615d
feat(Geometry): add GeometryModuleHelpers implementation
paulgessinger Mar 10, 2026
bf03985
refactor(Geometry): refine GeometryModule helpers and loader
paulgessinger Mar 10, 2026
a5812b2
refactor(Geometry): split GeometryModuleHelpers into Core and DD4hep …
paulgessinger Mar 10, 2026
7267115
refactor(Geometry): move GeometryModuleLoader to DD4hep plugin
paulgessinger Mar 11, 2026
4723312
refactor(DownstreamProject): simplify geometry module loading
paulgessinger Mar 11, 2026
b233793
refactor(Geometry): consolidate geometry module helpers
paulgessinger Mar 11, 2026
96678c5
feat(Geometry): add user_data_type to geometry module ABI
paulgessinger Mar 11, 2026
aa0295c
fix(Geometry): enforce Unix-only for geometry module loaders
paulgessinger Mar 11, 2026
92efa90
cmake format
paulgessinger Mar 12, 2026
6aa6034
add env
paulgessinger Mar 17, 2026
a1de109
make sonarcloud slightly happier
paulgessinger Mar 18, 2026
075045b
lint
paulgessinger Mar 20, 2026
2e2a151
docs with examples and compiles snippets
paulgessinger Mar 20, 2026
8f34e7d
more lint?
paulgessinger Mar 20, 2026
be71821
yet more lint
paulgessinger Mar 20, 2026
e4b70f5
if scoping, return nullptr
paulgessinger Mar 20, 2026
e17bb58
feat(dd4hep): include DD4hep in geometry module ABI tags
paulgessinger Mar 27, 2026
6202b37
cmake lint
paulgessinger Mar 30, 2026
183515f
Merge branch 'main' into feat/geo-dylib
kodiakhq[bot] Apr 9, 2026
1fd93af
Merge branch 'main' into feat/geo-dylib
kodiakhq[bot] Apr 9, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions .github/workflows/builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,10 @@ jobs:
- name: Downstream build
run: cmake --build build-downstream

- name: Downstream run
run: ./build-downstream/bin/ShowActsVersion
- name: Downstream tests
run: >
CI/dependencies/run.sh .env
ctest --test-dir build-downstream --output-on-failure

linux_examples_test:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -318,8 +320,8 @@ jobs:
- name: Downstream build
run: cmake --build build-downstream

- name: Downstream run
run: ./build-downstream/bin/ShowActsVersion
- name: Downstream tests
run: ctest --test-dir build-downstream --output-on-failure

macos:
runs-on: macos-26
Expand Down Expand Up @@ -406,8 +408,8 @@ jobs:
- name: Downstream build
run: cmake --build build-downstream

- name: Downstream run
run: ./build-downstream/bin/ShowActsVersion
- name: Downstream tests
run: ctest --test-dir build-downstream --output-on-failure

external_eic-shell:
runs-on: ubuntu-latest
Expand Down
8 changes: 4 additions & 4 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,8 @@ build_linux_ubuntu:
# Downstream build
- cmake --build build-downstream

# Downstream run
- ./build-downstream/bin/ShowActsVersion
# Downstream tests
- ctest --test-dir build-downstream --output-on-failure

after_script:
- !reference [.spack_cleanup, after_script]
Expand Down Expand Up @@ -369,8 +369,8 @@ linux_physmon:
# Downstream build
- cmake --build build-downstream

# Downstream run
- ./build-downstream/bin/ShowActsVersion
# Downstream tests
- ctest --test-dir build-downstream --output-on-failure

after_script:
- !reference [.spack_cleanup, after_script]
Expand Down
2 changes: 2 additions & 0 deletions CI/check_unused_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ def main():
"Core/include/Acts/EventData/detail/ParameterTraits.hpp",
"Core/include/Acts/Seeding/PathSeeder.hpp",
"Tests/CommonHelpers/include/ActsTests/CommonHelpers/TestSpacePoint.hpp",
"GeometryModule.h",
"runtime_geometry_modules.md",
)

suffix_header = (
Expand Down
18 changes: 18 additions & 0 deletions Core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@ target_sources(ActsCore PRIVATE src/ActsVersion.cpp)

target_compile_features(ActsCore PUBLIC ${ACTS_CXX_STANDARD_FEATURE})

set(ACTS_GEOMETRY_MODULE_CAPI 1)
set(_acts_geometry_module_abi_tag
"acts-${Acts_VERSION}|sys-${CMAKE_SYSTEM_NAME}|arch-${CMAKE_SYSTEM_PROCESSOR}|cxx-${CMAKE_CXX_COMPILER_ID}-${CMAKE_CXX_COMPILER_VERSION}|capi-${ACTS_GEOMETRY_MODULE_CAPI}"
)
set(ACTS_GEOMETRY_MODULE_ABI_TAG
"${_acts_geometry_module_abi_tag}"
CACHE INTERNAL
"ACTS geometry module ABI tag"
)

target_include_directories(
ActsCore
PUBLIC
Expand All @@ -19,6 +29,14 @@ target_include_directories(
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
target_link_libraries(ActsCore PUBLIC Boost::boost Eigen3::Eigen)
if(CMAKE_DL_LIBS)
target_link_libraries(ActsCore PRIVATE ${CMAKE_DL_LIBS})
endif()

target_compile_definitions(
ActsCore
PRIVATE ACTS_GEOMETRY_MODULE_ABI_TAG="${_acts_geometry_module_abi_tag}"
)

if(ACTS_PARAMETER_DEFINITIONS_HEADER)
target_compile_definitions(
Expand Down
18 changes: 18 additions & 0 deletions Core/include/Acts/Geometry/GeometryModule.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// This file is part of the ACTS project.
//
// Copyright (C) 2016 CERN for the benefit of the ACTS project
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

#pragma once

struct ActsGeometryModuleV1 {
const char* module_abi_tag;
const char* user_data_type;
void* (*build)(const void* user_data, const void* logger);
void (*destroy)(void* handle);
};

extern "C" const ActsGeometryModuleV1* acts_geometry_module_v1(void);
45 changes: 45 additions & 0 deletions Core/include/Acts/Geometry/GeometryModuleHelper.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// This file is part of the ACTS project.
//
// Copyright (C) 2016 CERN for the benefit of the ACTS project
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

#pragma once

#include "Acts/Geometry/GeometryModule.h"
#include "Acts/Geometry/TrackingGeometry.hpp"

#include <memory>

namespace Acts::detail {
using BuildFunction = std::unique_ptr<TrackingGeometry> (*)(const Logger&);
const ActsGeometryModuleV1* getGeometryModule(const char* module_abi_tag,
const char* user_data_type,
BuildFunction buildFunc);
// Low-level shared helper: accepts a raw build function pointer matching the
// C ABI struct's .build field. Handles static struct init and destroy.
const ActsGeometryModuleV1* getGeometryModuleFromRaw(
const char* module_abi_tag, const char* user_data_type,
void* (*buildFunc)(const void*, const void*));
} // namespace Acts::detail

// Internal — do not use directly.
#define ACTS_IMPL_GEOMETRY_MODULE_ENTRY(get_module_expr) \
extern "C" const ActsGeometryModuleV1* acts_geometry_module_v1(void) { \
return (get_module_expr); \
}

// Emit a clear error only when the macro is actually expanded without the tag,
// rather than at include time — Acts internal code includes this header too.
#ifdef ACTS_GEOMETRY_MODULE_ABI_TAG
#define ACTS_DEFINE_GEOMETRY_MODULE(build_function) \
ACTS_IMPL_GEOMETRY_MODULE_ENTRY(Acts::detail::getGeometryModule( \
ACTS_GEOMETRY_MODULE_ABI_TAG, nullptr, (build_function)))
#else
#define ACTS_DEFINE_GEOMETRY_MODULE(build_function) \
static_assert(false, \
"ACTS_GEOMETRY_MODULE_ABI_TAG must be provided via " \
"CMake (use acts_add_geometry_module).")
#endif
47 changes: 47 additions & 0 deletions Core/include/Acts/Geometry/GeometryModuleLoader.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// This file is part of the ACTS project.
//
// Copyright (C) 2016 CERN for the benefit of the ACTS project
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

#pragma once

#if !defined(__unix__) && !defined(__APPLE__)
#error \
"Runtime geometry modules are only supported on Unix-like systems (Linux, macOS)."
#endif

#include "Acts/Utilities/Logger.hpp"

#include <filesystem>
#include <memory>

namespace Acts {

class TrackingGeometry;

/// Load a module shared library, validate ABI compatibility, build and return
/// the tracking geometry. The returned deleter keeps the module loaded until
/// the geometry is destroyed. Throws if the module requires user data (e.g.
/// a DD4hep module) — use the appropriate typed loader instead.
/// @param modulePath Path to the geometry module shared library.
/// @param logger Logger instance used by the module loader.
/// @return Shared pointer to the loaded tracking geometry.
std::shared_ptr<TrackingGeometry> loadGeometryModule(
const std::filesystem::path& modulePath,
const Logger& logger = getDummyLogger());

namespace detail {
/// Low-level loader used by typed wrappers (e.g. loadDD4hepGeometryModule).
/// Validates that the module's ABI tag matches \a expectedAbiTag.
/// Validates that the module's user_data_type matches \a expectedUserDataType
/// (nullptr means the module must declare no user data requirement).
std::shared_ptr<TrackingGeometry> loadGeometryModuleImpl(
const std::filesystem::path& modulePath, const char* expectedAbiTag,
const char* expectedUserDataType, const void* userData,
const Logger& logger);
} // namespace detail

} // namespace Acts
2 changes: 2 additions & 0 deletions Core/src/Geometry/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ target_sources(
GenericApproachDescriptor.cpp
GenericCuboidVolumeBounds.cpp
GeometryIdentifier.cpp
GeometryModuleHelper.cpp
GeometryModuleLoader.cpp
GlueVolumesDescriptor.cpp
Layer.cpp
LayerArrayCreator.cpp
Expand Down
64 changes: 64 additions & 0 deletions Core/src/Geometry/GeometryModuleHelper.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// This file is part of the ACTS project.
//
// Copyright (C) 2016 CERN for the benefit of the ACTS project
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

#include "Acts/Geometry/GeometryModuleHelper.hpp"

#include "Acts/Geometry/GeometryModule.h"
#include "Acts/Geometry/TrackingGeometry.hpp"
#include "Acts/Utilities/Logger.hpp"

#include <exception>
#include <memory>

namespace Acts::detail {

const ActsGeometryModuleV1* getGeometryModuleFromRaw(
const char* module_abi_tag, const char* user_data_type,
void* (*buildFunc)(const void*, const void*)) {
static const ActsGeometryModuleV1 s_module = {
.module_abi_tag = module_abi_tag,
.user_data_type = user_data_type,
.build = buildFunc,
.destroy =
[](void* handle) noexcept {
if (handle == nullptr) {
return;
}

delete static_cast<TrackingGeometry*>(handle);
},
};

return &s_module;
}

const ActsGeometryModuleV1* getGeometryModule(const char* module_abi_tag,
const char* user_data_type,
BuildFunction buildFunc) {
static BuildFunction s_buildFunc = buildFunc;

return getGeometryModuleFromRaw(
module_abi_tag, user_data_type,
[](const void* /*userData*/, const void* loggerPtr) noexcept -> void* {
if (loggerPtr == nullptr) {
return nullptr;
}
const auto& logger = *static_cast<const Logger*>(loggerPtr);
try {
return s_buildFunc(logger).release();
} catch (const std::exception& e) {
ACTS_ERROR("Failed to build geometry module: " << e.what());
return nullptr;
} catch (...) {
ACTS_ERROR("Failed to build geometry module");
return nullptr;
}
});
}

} // namespace Acts::detail
Loading
Loading