From 207833a017e52d7c1b5d21bedd49069639696688 Mon Sep 17 00:00:00 2001 From: Giulio Eulisse <10544+ktf@users.noreply.github.com> Date: Mon, 3 Oct 2022 19:48:03 +0200 Subject: [PATCH 1/2] DPL: move TPDGDatabase customization to plugin 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. --- Framework/CMakeLists.txt | 2 + Framework/Core/CMakeLists.txt | 1 - .../Core/include/Framework/CommonServices.h | 9 ++--- Framework/Core/src/CommonServices.cxx | 15 ------- Framework/PhysicsSupport/CMakeLists.txt | 14 +++++++ Framework/PhysicsSupport/src/Plugin.cxx | 39 +++++++++++++++++++ cmake/O2AddWorkflow.cmake | 2 +- 7 files changed, 60 insertions(+), 22 deletions(-) create mode 100644 Framework/PhysicsSupport/CMakeLists.txt create mode 100644 Framework/PhysicsSupport/src/Plugin.cxx diff --git a/Framework/CMakeLists.txt b/Framework/CMakeLists.txt index 0c0e22e9e85c0..3fc3a5ca1a356 100644 --- a/Framework/CMakeLists.txt +++ b/Framework/CMakeLists.txt @@ -18,9 +18,11 @@ add_subdirectory(Core) add_subdirectory(Utils) add_subdirectory(AnalysisSupport) +add_subdirectory(PhysicsSupport) add_subdirectory(RootAnalysisHelpers) + # Build the GUI support only if we have DebugGUI if (TARGET AliceO2::DebugGUI) add_subdirectory(GUISupport) diff --git a/Framework/Core/CMakeLists.txt b/Framework/Core/CMakeLists.txt index 1a4902873a2ea..da96070efcc4e 100644 --- a/Framework/Core/CMakeLists.txt +++ b/Framework/Core/CMakeLists.txt @@ -144,7 +144,6 @@ o2_add_library(Framework CURL::libcurl FairMQ::FairMQ O2::MathUtils - ROOT::EG ROOT::TreePlayer O2::CCDB O2::FrameworkFoundation diff --git a/Framework/Core/include/Framework/CommonServices.h b/Framework/Core/include/Framework/CommonServices.h index fd6e4aad3da9c..361a4518a6195 100644 --- a/Framework/Core/include/Framework/CommonServices.h +++ b/Framework/Core/include/Framework/CommonServices.h @@ -80,14 +80,13 @@ struct CommonServices { }; struct CommonAnalysisServices { - static ServiceSpec databasePDGSpec(); - template static void addAnalysisService(std::vector& specs) { - if constexpr (std::is_same_v) { - specs.push_back(databasePDGSpec()); - } + std::vector loadableServices = {}; + char const* analysisServices = "O2FrameworkPhysicsSupport:PDGSupport"; + loadableServices = ServiceHelpers::parseServiceSpecString(analysisServices); + ServiceHelpers::loadFromPlugin(loadableServices, specs); } }; diff --git a/Framework/Core/src/CommonServices.cxx b/Framework/Core/src/CommonServices.cxx index da483ff134d5b..b5fe0a0a62bbf 100644 --- a/Framework/Core/src/CommonServices.cxx +++ b/Framework/Core/src/CommonServices.cxx @@ -42,8 +42,6 @@ #include "DecongestionService.h" #include "ArrowSupport.h" #include "DPLMonitoringBackend.h" -#include "TDatabasePDG.h" -#include "../../../DataFormats/simulation/include/SimulationDataFormat/O2DatabasePDG.h" #include "Headers/STFHeader.h" #include "Headers/DataHeader.h" @@ -957,18 +955,5 @@ std::vector CommonServices::defaultServices(int numThreads) return specs; } -o2::framework::ServiceSpec CommonAnalysisServices::databasePDGSpec() -{ - return ServiceSpec{ - .name = "database-pdg", - .init = [](ServiceRegistry&, DeviceState&, fair::mq::ProgOptions&) -> ServiceHandle { - auto* ptr = new TDatabasePDG(); - o2::O2DatabasePDG::addALICEParticles(ptr); - return ServiceHandle{TypeIdHelpers::uniqueId(), ptr, ServiceKind::Serial, "database-pdg"}; - }, - .configure = CommonServices::noConfiguration(), - .exit = [](ServiceRegistry&, void* service) { reinterpret_cast(service)->Delete(); }, - .kind = ServiceKind::Serial}; -} } // namespace o2::framework #pragma GCC diagnostic pop diff --git a/Framework/PhysicsSupport/CMakeLists.txt b/Framework/PhysicsSupport/CMakeLists.txt new file mode 100644 index 0000000000000..08a74dd65fc65 --- /dev/null +++ b/Framework/PhysicsSupport/CMakeLists.txt @@ -0,0 +1,14 @@ +# Copyright 2019-2020 CERN and copyright holders of ALICE O2. +# See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +# All rights not expressly granted are reserved. +# +# This software is distributed under the terms of the GNU General Public +# License v3 (GPL Version 3), copied verbatim in the file "COPYING". +# +# In applying this license CERN does not waive the privileges and immunities +# granted to it by virtue of its status as an Intergovernmental Organization +# or submit itself to any jurisdiction. +o2_add_library(FrameworkPhysicsSupport + SOURCES src/Plugin.cxx + PRIVATE_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_LIST_DIR}/src + PUBLIC_LINK_LIBRARIES O2::Framework O2::SimulationDataFormat) diff --git a/Framework/PhysicsSupport/src/Plugin.cxx b/Framework/PhysicsSupport/src/Plugin.cxx new file mode 100644 index 0000000000000..b36c4ca9d6179 --- /dev/null +++ b/Framework/PhysicsSupport/src/Plugin.cxx @@ -0,0 +1,39 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. +// +#include "Framework/Plugins.h" +#include "Framework/ServiceHandle.h" +#include "Framework/ServiceSpec.h" +#include "Framework/CommonServices.h" +#include "TDatabasePDG.h" +#include "SimulationDataFormat/O2DatabasePDG.h" + +using namespace o2::framework; + +struct PDGSupport : o2::framework::ServicePlugin { + o2::framework::ServiceSpec* create() final + { + return new ServiceSpec{ + .name = "database-pdg", + .init = [](ServiceRegistry&, DeviceState&, fair::mq::ProgOptions&) -> ServiceHandle { + auto* ptr = new TDatabasePDG(); + o2::O2DatabasePDG::addALICEParticles(ptr); + return ServiceHandle{TypeIdHelpers::uniqueId(), ptr, ServiceKind::Serial, "database-pdg"}; + }, + .configure = CommonServices::noConfiguration(), + .exit = [](ServiceRegistry&, void* service) { reinterpret_cast(service)->Delete(); }, + .kind = ServiceKind::Serial}; + } +}; + +DEFINE_DPL_PLUGINS_BEGIN +DEFINE_DPL_PLUGIN_INSTANCE(PDGSupport, CustomService); +DEFINE_DPL_PLUGINS_END diff --git a/cmake/O2AddWorkflow.cmake b/cmake/O2AddWorkflow.cmake index 97a3ad8d80299..6a5fd5ba06efa 100644 --- a/cmake/O2AddWorkflow.cmake +++ b/cmake/O2AddWorkflow.cmake @@ -54,7 +54,7 @@ function(o2_add_dpl_workflow baseTargetName) add_custom_command( TARGET ${targetExeName} POST_BUILD 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" $ -b --dump-workflow --dump-workflow-file ${jsonFile}) - add_dependencies(${targetExeName} O2::FrameworkAnalysisSupport) + add_dependencies(${targetExeName} O2::FrameworkAnalysisSupport O2::FrameworkPhysicsSupport) install( FILES ${CMAKE_CURRENT_BINARY_DIR}/${jsonFile} From 359f9beaa0286ae30e868d02b703a226fa213daf Mon Sep 17 00:00:00 2001 From: Giulio Eulisse <10544+ktf@users.noreply.github.com> Date: Thu, 6 Oct 2022 11:09:56 +0200 Subject: [PATCH 2/2] Drop extra spaces --- Framework/CMakeLists.txt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Framework/CMakeLists.txt b/Framework/CMakeLists.txt index 3fc3a5ca1a356..40a33ea80fdfe 100644 --- a/Framework/CMakeLists.txt +++ b/Framework/CMakeLists.txt @@ -17,15 +17,14 @@ add_subdirectory(Core) add_subdirectory(Utils) -add_subdirectory(AnalysisSupport) +add_subdirectory(AnalysisSupport) add_subdirectory(PhysicsSupport) add_subdirectory(RootAnalysisHelpers) - # Build the GUI support only if we have DebugGUI if (TARGET AliceO2::DebugGUI) -add_subdirectory(GUISupport) +add_subdirectory(GUISupport) endif() -add_subdirectory(TestWorkflows) +add_subdirectory(TestWorkflows)