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 system improvements #330

Merged
merged 23 commits into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
1dafbc7
Fix PodioExampleDatamodel generation & install
nathanwbrei Aug 2, 2024
419fb56
Isolate plugin install directories
nathanwbrei Aug 2, 2024
c8c9614
Update JPluginLoader search paths
nathanwbrei Aug 2, 2024
8e16f9f
Vendored headers installed to include/JANA/external
nathanwbrei Aug 2, 2024
a8e5d8d
Fix LD_LIBRARY_PATH on docker CI workflow
nathanwbrei Aug 3, 2024
b2fb89f
Pull JANAConfig.cmake generation out of src/libraries/JANA
nathanwbrei Aug 5, 2024
7e11026
Install cmake files to $PREFIX/lib/JANA/cmake
nathanwbrei Aug 5, 2024
d33a994
Vendored catch2 dependency is now a CMake target
nathanwbrei Aug 5, 2024
74530b7
Introduce add_jana_plugin() macro
nathanwbrei Aug 5, 2024
7fb01a8
Update janacontrol to use new testing concept
nathanwbrei Aug 6, 2024
4959240
Update janapy
nathanwbrei Aug 6, 2024
ec0959e
Fix warning in JTablePrinter
nathanwbrei Aug 6, 2024
acab1ac
Introduce add_jana_test macro
nathanwbrei Aug 6, 2024
a823fae
Add CTest tests for examples
nathanwbrei Aug 7, 2024
bf80259
CI workflows use ctest suite
nathanwbrei Aug 7, 2024
9168ba3
Tests install to $PREFIX/bin again
nathanwbrei Aug 8, 2024
b7827a6
Set build rpath to install rpath so that plugins run from build dir
nathanwbrei Aug 8, 2024
eb0fa45
Fix PodioExample
nathanwbrei Aug 8, 2024
79667d2
CI: Fix LD_LIBRARY_PATH on eic-shell
nathanwbrei Aug 8, 2024
b4e877b
CI: Add podio back to LD_LIBRARY_PATH
nathanwbrei Aug 8, 2024
cbb3b9b
CMake add_jana_plugin() supports glob matching
nathanwbrei Aug 9, 2024
3356232
CMake add_jana_plugin() works both internally and externally
nathanwbrei Aug 9, 2024
d095d48
Prune plugin dependencies that should be inherited instead
nathanwbrei Aug 9, 2024
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
57 changes: 27 additions & 30 deletions .github/workflows/ccpp-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,53 +12,50 @@ jobs:
runs-on: ubuntu-latest
container:
image: nbrei/jana2_env_everything_except_cuda

# Build Docker container and run the entrypoint.sh script in it
steps:

- uses: actions/checkout@v4

- name: cmake
- name: build
run: |
mkdir -p $GITHUB_WORKSPACE/build
cd $GITHUB_WORKSPACE/build
cmake ../ -DCMAKE_INSTALL_PREFIX=$GITHUB_WORKSPACE/Linux \
cmake -S . -B build -DCMAKE_INSTALL_PREFIX=`pwd` \
-DUSE_PYTHON=ON \
-DUSE_ROOT=ON \
-DUSE_PODIO=ON \
-DUSE_XERCES=ON \
-DXercesC_DIR=/usr \
-DUSE_ZEROMQ=ON \
-DXercesC_DIR=/usr \
-Dpodio_DIR=/app/podio/install/lib/cmake/podio/
- name: make
run: |
cd $GITHUB_WORKSPACE/build
make
- name: make install
cmake --build build --target install
- name: Examine dynamic linking
run: |
cd $GITHUB_WORKSPACE/build
make install
echo "ldd bin/jana"
ldd bin/jana
echo "ldd bin/libJANA.so"
ldd lib/libJANA.so
echo "bin/jana rpath"
objdump -x bin/jana | grep PATH
echo "lib/libJANA.so rpath"
objdump -x lib/libJANA.so | grep PATH
echo "lib/JANA/plugins/TimesliceExample.so"
objdump -x lib/JANA/plugins/TimesliceExample.so | grep PATH
echo "bin/PodioExample"
objdump -x bin/PodioExample | grep PATH
- name: JTest
run: |
echo "--- Running JTest plugin -----------------------"
export JANA_PLUGIN_PATH=$GITHUB_WORKSPACE/Linux/plugins
$GITHUB_WORKSPACE/Linux/bin/jana -PPLUGINS=JTest -Pjana:nevents=100
export LD_LIBRARY_PATH=/app/podio/install/lib:$LD_LIBRARY_PATH
# Note that podio needs to be on the LD_LIBRARY_PATH, not merely someone's RPath, because
# Cling needs to be able to find the libpodioDict*
ctest --test-dir build --output-on-failure -R jana-plugin-jtest-tests
- name: jana-unit-tests
run: |
echo "--- Running jana-unit-tests ------------------------------"
export JANA_PLUGIN_PATH=$GITHUB_WORKSPACE/Linux/plugins
$GITHUB_WORKSPACE/Linux/bin/jana-unit-tests
export LD_LIBRARY_PATH=/app/podio/install/lib:$LD_LIBRARY_PATH
ctest --test-dir build --output-on-failure -R jana-unit-tests
- name: TimesliceExample with simple (physics event) topology
run: |
echo "--- Running TimesliceExample with simple topology ------------------------------"
export JANA_PLUGIN_PATH=$GITHUB_WORKSPACE/Linux/plugins
export LD_LIBRARY_PATH=$GITHUB_WORKSPACE/Linux/lib:/app/podio/install/lib:$LD_LIBRARY_PATH
$GITHUB_WORKSPACE/Linux/bin/jana -Pplugins=TimesliceExample -Pjana:nevents=100 events.root
export LD_LIBRARY_PATH=/app/podio/install/lib:$LD_LIBRARY_PATH
ctest --test-dir build --output-on-failure -R jana-example-timeslices-simple-tests
- name: TimesliceExample with complex (timeslice) topology
run: |
echo "--- Running TimesliceExample with complex topology ------------------------------"
export JANA_PLUGIN_PATH=$GITHUB_WORKSPACE/Linux/plugins
export LD_LIBRARY_PATH=$GITHUB_WORKSPACE/Linux/lib:/app/podio/install/lib:$LD_LIBRARY_PATH
$GITHUB_WORKSPACE/Linux/bin/jana -Pplugins=TimesliceExample -Pjana:nevents=100 timeslices.root
export LD_LIBRARY_PATH=/app/podio/install/lib:$LD_LIBRARY_PATH
ctest --test-dir build --output-on-failure -R jana-example-timeslices-complex-tests


4 changes: 2 additions & 2 deletions .github/workflows/ccpp-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ jobs:
run: |
export JANA_PLUGIN_PATH=$GITHUB_WORKSPACE/Linux/plugins
echo "--- Running JTest plugin -----------------------"
$GITHUB_WORKSPACE/Linux/bin/jana -PPLUGINS=JTest -Pjana:nevents=100
ctest --test-dir build -R jana-plugin-jtest-tests
- name: jana-unit-tests
run: |
echo "--- Running jana-unit-tests ------------------------------"
$GITHUB_WORKSPACE/Linux/bin/jana-unit-tests
ctest --test-dir build -R jana-unit-tests
28 changes: 23 additions & 5 deletions .github/workflows/eicshell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,24 @@ jobs:
run: |
cd $GITHUB_WORKSPACE/build
make -j4 install

- name: Examine dynamic linking
run: |
export JANA_HOME=$GITHUB_WORKSPACE
export JANA_PLUGIN_PATH=$JANA_HOME/plugins
export LD_LIBRARY_PATH=$JANA_HOME/lib:$JANA_HOME/lib/JANA/plugins:$LD_LIBRARY_PATH
echo "ldd bin/jana"
ldd bin/jana
echo "ldd bin/libJANA.so"
ldd lib/libJANA.so
echo "bin/jana rpath"
objdump -x bin/jana | grep PATH
echo "lib/libJANA.so rpath"
objdump -x lib/libJANA.so | grep PATH
echo "lib/JANA/plugins/TimesliceExample.so"
objdump -x lib/JANA/plugins/TimesliceExample.so | grep PATH
echo "bin/PodioExample"
objdump -x bin/PodioExample | grep PATH

- name: Run JTest plugin with 100 events
uses: eic/run-cvmfs-osg-eic-shell@main
Expand All @@ -47,7 +65,7 @@ jobs:
run: |
export JANA_HOME=$GITHUB_WORKSPACE
export JANA_PLUGIN_PATH=$JANA_HOME/plugins
export LD_LIBRARY_PATH=$JANA_HOME/lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=$JANA_HOME/lib:$JANA_HOME/lib/JANA/plugins:$LD_LIBRARY_PATH
$GITHUB_WORKSPACE/bin/jana -Pplugins=JTest -Pjana:nevents=100

- name: Run jana-unit-tests
Expand All @@ -57,7 +75,7 @@ jobs:
run: |
export JANA_HOME=$GITHUB_WORKSPACE
export JANA_PLUGIN_PATH=$JANA_HOME/plugins
export LD_LIBRARY_PATH=$JANA_HOME/lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=$JANA_HOME/lib:$JANA_HOME/lib/JANA/plugins:$LD_LIBRARY_PATH
$GITHUB_WORKSPACE/bin/jana-unit-tests

- name: Run TimesliceExample with simple (physics event) topology
Expand All @@ -68,7 +86,7 @@ jobs:
echo "--- Running TimesliceExample with simple topology ------------------------------"
export JANA_HOME=$GITHUB_WORKSPACE
export JANA_PLUGIN_PATH=$JANA_HOME/plugins
export LD_LIBRARY_PATH=$JANA_HOME/lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=$JANA_HOME/lib:$JANA_HOME/lib/JANA/plugins:$LD_LIBRARY_PATH
$GITHUB_WORKSPACE/bin/jana \
-Pplugins=TimesliceExample \
-Pjana:nevents=100 \
Expand All @@ -82,7 +100,7 @@ jobs:
echo "--- Running TimesliceExample with simple topology ------------------------------"
export JANA_HOME=$GITHUB_WORKSPACE
export JANA_PLUGIN_PATH=$JANA_HOME/plugins
export LD_LIBRARY_PATH=$JANA_HOME/lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=$JANA_HOME/lib:$JANA_HOME/lib/JANA/plugins:$LD_LIBRARY_PATH
$GITHUB_WORKSPACE/bin/jana -Pplugins=TimesliceExample -Pjana:nevents=100 timeslices.root


Expand Down Expand Up @@ -120,7 +138,7 @@ jobs:
run: |
echo "--- Running EICrecon ---"
export JANA_HOME=$GITHUB_WORKSPACE
export LD_LIBRARY_PATH=$GITHUB_WORKSPACE/../EICrecon/lib:$JANA_HOME/lib:$LD_LIBRARY_PATH
export JANA_PLUGIN_PATH=$GITHUB_WORKSPACE/../EICrecon/lib/EICrecon/plugins
export LD_LIBRARY_PATH=$GITHUB_WORKSPACE/../EICrecon/lib:$JANA_HOME/lib:$JANA_HOME/lib/JANA/plugins:$LD_LIBRARY_PATH
../EICrecon/bin/eicrecon sim_e_1GeV_20GeV_craterlake.edm4hep.root

6 changes: 0 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ Makefile
/bin/
/include/
/lib/
/plugins/

# Doxygen generated files
docs/html/*
Expand All @@ -65,9 +64,4 @@ cmake-build*/
.cache
compile_commands.json

# PODIO generated artifacts
src/examples/PodioExample/datamodel/*
src/examples/PodioExample/src/*
src/examples/PodioExample/podio_generated_files.cmake

podio_build/
11 changes: 8 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ endif()
# TODO: detector MacOS and set MACOSX_RPATH to TRUE
set( CMAKE_SKIP_BUILD_RPATH FALSE )
set( CMAKE_BUILD_WITH_INSTALL_RPATH FALSE )
set( CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib" )
set( CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib:${CMAKE_INSTALL_PREFIX}/lib/JANA/plugins" )
set( CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE )

# Generate a compilation database, e.g. for IDE autocompletion
Expand Down Expand Up @@ -195,26 +195,31 @@ message(STATUS "-----------------------")
#---------

include_directories(src/libraries) # So that everyone can find the JANA header files
include_directories(src/external) # So that everyone can find our vendorized header-old libraries
include_directories(${CMAKE_CURRENT_BINARY_DIR}/src/libraries) # So that everyone can find JVersion.h

# This is needed on macos to allow plugins to link without resolving all JANA symbols until runtime
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
add_link_options(-undefined dynamic_lookup)
endif()

include(CTest)
include(cmake/AddJanaPlugin.cmake)
include(cmake/AddJanaTest.cmake)

add_subdirectory(src/external)
add_subdirectory(src/libraries/JANA)
add_subdirectory(src/examples)
add_subdirectory(src/plugins)
add_subdirectory(src/programs/jana)
add_subdirectory(src/programs/unit_tests)
add_subdirectory(src/programs/perf_tests)

add_subdirectory(src/python)

#---------------------------------------------------------------------------------------

install(DIRECTORY scripts/ DESTINATION bin FILES_MATCHING PATTERN "jana-*.py"
PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_READ WORLD_EXECUTE)

include(${CMAKE_SOURCE_DIR}/cmake/MakeConfig.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/MakeJanaThis.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/MakeJVersionH.cmake)
103 changes: 103 additions & 0 deletions cmake/AddJanaPlugin.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@

macro(add_jana_plugin plugin_name)

# Parse remaining arguments
set(options)
set(oneValueArgs EXPORT)
set(multiValueArgs SOURCES PUBLIC_HEADER TESTS)

cmake_parse_arguments(PLUGIN "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})

if (NOT PLUGIN_SOURCES AND NOT PLUGIN_PUBLIC_HEADER AND NOT PLUGIN_TESTS)
# If no arguments provided, glob everything
file(GLOB HEADERS_IN_SUBDIR "include/*")
file(GLOB SOURCES_IN_SUBDIR "src/*")
file(GLOB TESTS_IN_SUBDIR "test*/*")
file(GLOB HEADERS_IN_CWD "*.h*")
set(SOURCES_IN_CWD)
set(TESTS_IN_CWD)

file(GLOB ALL_SOURCES_IN_CWD "*.c*")
foreach(file IN LISTS ALL_SOURCES_IN_CWD)
string(TOLOWER "${file}" file_lower)
if(NOT file_lower MATCHES ".*/test[^/]*$|.*test$|.*tests$")
list(APPEND SOURCES_IN_CWD ${file})
else()
list(APPEND TESTS_IN_CWD ${file})
endif()
endforeach()

set(PLUGIN_SOURCES ${SOURCES_IN_CWD} ${SOURCES_IN_SUBDIR})
set(PLUGIN_PUBLIC_HEADER ${HEADERS_IN_CWD} ${HEADERS_IN_SUBDIR})
set(PLUGIN_TESTS ${TESTS_IN_CWD} ${TESTS_IN_SUBDIR})
message(STATUS "Plugin ${plugin_name}: found sources: ${PLUGIN_SOURCES}")
message(STATUS "Plugin ${plugin_name}: found headers: ${PLUGIN_PUBLIC_HEADER}")
message(STATUS "Plugin ${plugin_name}: found tests: ${PLUGIN_TESTS}")
endif()

if (${PROJECT_NAME} STREQUAL "jana2")
# This is an internal plugin
set(INSTALL_NAMESPACE "JANA")
set(JANA_NAMESPACE "")
if (NOT PLUGIN_EXPORT)
set(PLUGIN_EXPORT "jana2_targets")
endif()
else()
# This is an external plugin
# Figure out install namespace, which _might_ be different than PROJECT_NAME
if (NOT DEFINED INSTALL_NAMESPACE)
set(INSTALL_NAMESPACE ${PROJECT_NAME} CACHE STRING "Project-specific namespace for installation paths, e.g. /lib/PROJECT_NAMESPACE/plugins")
endif()
set(JANA_NAMESPACE "JANA::")
endif()

# Set up target
add_library(${plugin_name} SHARED ${PLUGIN_SOURCES})

set_target_properties(${plugin_name} PROPERTIES
EXPORT_NAME ${plugin_name}
PREFIX ""
SUFFIX ".so"
SKIP_BUILD_RPATH FALSE
BUILD_WITH_INSTALL_RPATH TRUE
INSTALL_RPATH_USE_LINK_PATH TRUE
INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib;${CMAKE_INSTALL_PREFIX}/lib/${INSTALL_NAMESPACE}/plugins"
)

target_link_libraries(${plugin_name} PUBLIC "${JANA_NAMESPACE}jana2_static_lib")

# Handle public headers
if (PLUGIN_PUBLIC_HEADER)
set_target_properties(${plugin_name} PROPERTIES
PUBLIC_HEADER "${PLUGIN_PUBLIC_HEADER}"
)
target_include_directories(${plugin_name}
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:include/${INSTALL_NAMESPACE}/plugins/${plugin_name}>
)
endif()

# Install target
install(TARGETS ${plugin_name}
EXPORT ${PLUGIN_EXPORT}
PUBLIC_HEADER DESTINATION include/${INSTALL_NAMESPACE}/plugins/${plugin_name}
LIBRARY DESTINATION lib/${INSTALL_NAMESPACE}/plugins
)

# Handle tests
if (PLUGIN_TESTS)
add_executable(${plugin_name}_tests ${PLUGIN_TESTS})
target_link_libraries(${plugin_name}_tests PRIVATE ${plugin_name} "${JANA_NAMESPACE}VendoredCatch2")
set_target_properties(${plugin_name}_tests PROPERTIES
SKIP_BUILD_RPATH FALSE
BUILD_WITH_INSTALL_RPATH TRUE
INSTALL_RPATH_USE_LINK_PATH TRUE
INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib;${CMAKE_INSTALL_PREFIX}/lib/${INSTALL_NAMESPACE}/plugins"
)
#install(TARGETS ${plugin_name}_tests RUNTIME DESTINATION bin)
add_test(NAME ${plugin_name}_tests COMMAND ${plugin_name}_tests)
endif()
endmacro()


27 changes: 27 additions & 0 deletions cmake/AddJanaTest.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

macro(add_jana_test test_target_name)

cmake_parse_arguments(JANATEST "" "" "SOURCES" ${ARGN})

if (NOT JANATEST_SOURCES)
file(GLOB JANATEST_SOURCES "*.c*")
endif()

# Set up target
add_executable(${test_target_name} ${JANATEST_SOURCES})

target_link_libraries(${test_target_name} PRIVATE jana2_static_lib VendoredCatch2)

set_target_properties(${test_target_name} PROPERTIES
SKIP_BUILD_RPATH FALSE
BUILD_WITH_INSTALL_RPATH FALSE
INSTALL_RPATH_USE_LINK_PATH TRUE
INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib;${CMAKE_INSTALL_PREFIX}/lib/JANA/plugins")

install(TARGETS ${test_target_name} RUNTIME DESTINATION bin)

add_test(NAME ${test_target_name} COMMAND ${CMAKE_INSTALL_PREFIX}/bin/${test_target_name})

endmacro()


File renamed without changes.
Loading
Loading