Skip to content

Commit 853cf30

Browse files
authored
DPL: move TPDGDatabase customization to plugin (#9983)
This will avoid that every single device links against libEG & co. Notice how we need to build the plugin before the workflows, to avoid it is not found at runtime.
1 parent b3d9bca commit 853cf30

7 files changed

Lines changed: 62 additions & 25 deletions

File tree

Framework/CMakeLists.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,14 @@ add_subdirectory(Core)
1717

1818
add_subdirectory(Utils)
1919

20-
add_subdirectory(AnalysisSupport)
20+
add_subdirectory(AnalysisSupport)
21+
add_subdirectory(PhysicsSupport)
2122

2223
add_subdirectory(RootAnalysisHelpers)
2324

2425
# Build the GUI support only if we have DebugGUI
2526
if (TARGET AliceO2::DebugGUI)
26-
add_subdirectory(GUISupport)
27+
add_subdirectory(GUISupport)
2728
endif()
2829

29-
add_subdirectory(TestWorkflows)
30+
add_subdirectory(TestWorkflows)

Framework/Core/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@ o2_add_library(Framework
145145
CURL::libcurl
146146
FairMQ::FairMQ
147147
O2::MathUtils
148-
ROOT::EG
149148
ROOT::Tree
150149
O2::CCDB
151150
O2::FrameworkFoundation

Framework/Core/include/Framework/CommonServices.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,13 @@ struct CommonServices {
8080
};
8181

8282
struct CommonAnalysisServices {
83-
static ServiceSpec databasePDGSpec();
84-
8583
template <typename T>
8684
static void addAnalysisService(std::vector<ServiceSpec>& specs)
8785
{
88-
if constexpr (std::is_same_v<T, TDatabasePDG>) {
89-
specs.push_back(databasePDGSpec());
90-
}
86+
std::vector<LoadableService> loadableServices = {};
87+
char const* analysisServices = "O2FrameworkPhysicsSupport:PDGSupport";
88+
loadableServices = ServiceHelpers::parseServiceSpecString(analysisServices);
89+
ServiceHelpers::loadFromPlugin(loadableServices, specs);
9190
}
9291
};
9392

Framework/Core/src/CommonServices.cxx

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@
4242
#include "DecongestionService.h"
4343
#include "ArrowSupport.h"
4444
#include "DPLMonitoringBackend.h"
45-
#include "TDatabasePDG.h"
46-
#include "../../../DataFormats/simulation/include/SimulationDataFormat/O2DatabasePDG.h"
4745
#include "Headers/STFHeader.h"
4846
#include "Headers/DataHeader.h"
4947

@@ -956,18 +954,5 @@ std::vector<ServiceSpec> CommonServices::defaultServices(int numThreads)
956954
return specs;
957955
}
958956

959-
o2::framework::ServiceSpec CommonAnalysisServices::databasePDGSpec()
960-
{
961-
return ServiceSpec{
962-
.name = "database-pdg",
963-
.init = [](ServiceRegistry&, DeviceState&, fair::mq::ProgOptions&) -> ServiceHandle {
964-
auto* ptr = new TDatabasePDG();
965-
o2::O2DatabasePDG::addALICEParticles(ptr);
966-
return ServiceHandle{TypeIdHelpers::uniqueId<TDatabasePDG>(), ptr, ServiceKind::Serial, "database-pdg"};
967-
},
968-
.configure = CommonServices::noConfiguration(),
969-
.exit = [](ServiceRegistry&, void* service) { reinterpret_cast<TDatabasePDG*>(service)->Delete(); },
970-
.kind = ServiceKind::Serial};
971-
}
972957
} // namespace o2::framework
973958
#pragma GCC diagnostic pop
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2+
# See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3+
# All rights not expressly granted are reserved.
4+
#
5+
# This software is distributed under the terms of the GNU General Public
6+
# License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7+
#
8+
# In applying this license CERN does not waive the privileges and immunities
9+
# granted to it by virtue of its status as an Intergovernmental Organization
10+
# or submit itself to any jurisdiction.
11+
o2_add_library(FrameworkPhysicsSupport
12+
SOURCES src/Plugin.cxx
13+
PRIVATE_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_LIST_DIR}/src
14+
PUBLIC_LINK_LIBRARIES O2::Framework O2::SimulationDataFormat)
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2+
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3+
// All rights not expressly granted are reserved.
4+
//
5+
// This software is distributed under the terms of the GNU General Public
6+
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7+
//
8+
// In applying this license CERN does not waive the privileges and immunities
9+
// granted to it by virtue of its status as an Intergovernmental Organization
10+
// or submit itself to any jurisdiction.
11+
//
12+
#include "Framework/Plugins.h"
13+
#include "Framework/ServiceHandle.h"
14+
#include "Framework/ServiceSpec.h"
15+
#include "Framework/CommonServices.h"
16+
#include "TDatabasePDG.h"
17+
#include "SimulationDataFormat/O2DatabasePDG.h"
18+
19+
using namespace o2::framework;
20+
21+
struct PDGSupport : o2::framework::ServicePlugin {
22+
o2::framework::ServiceSpec* create() final
23+
{
24+
return new ServiceSpec{
25+
.name = "database-pdg",
26+
.init = [](ServiceRegistry&, DeviceState&, fair::mq::ProgOptions&) -> ServiceHandle {
27+
auto* ptr = new TDatabasePDG();
28+
o2::O2DatabasePDG::addALICEParticles(ptr);
29+
return ServiceHandle{TypeIdHelpers::uniqueId<TDatabasePDG>(), ptr, ServiceKind::Serial, "database-pdg"};
30+
},
31+
.configure = CommonServices::noConfiguration(),
32+
.exit = [](ServiceRegistry&, void* service) { reinterpret_cast<TDatabasePDG*>(service)->Delete(); },
33+
.kind = ServiceKind::Serial};
34+
}
35+
};
36+
37+
DEFINE_DPL_PLUGINS_BEGIN
38+
DEFINE_DPL_PLUGIN_INSTANCE(PDGSupport, CustomService);
39+
DEFINE_DPL_PLUGINS_END

cmake/O2AddWorkflow.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ function(o2_add_dpl_workflow baseTargetName)
5454
add_custom_command(
5555
TARGET ${targetExeName} POST_BUILD
5656
COMMAND ${CMAKE_COMMAND} -E env ASAN_OPTIONS=detect_leaks=0,detect_container_overflow=0,detect_odr_violation=0 "LD_LIBRARY_PATH=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}:$$LD_LIBRARY_PATH" $<TARGET_FILE:${targetExeName}> -b --dump-workflow --dump-workflow-file ${jsonFile})
57-
add_dependencies(${targetExeName} O2::FrameworkAnalysisSupport)
57+
add_dependencies(${targetExeName} O2::FrameworkAnalysisSupport O2::FrameworkPhysicsSupport)
5858

5959
install(
6060
FILES ${CMAKE_CURRENT_BINARY_DIR}/${jsonFile}

0 commit comments

Comments
 (0)