Skip to content

Commit 4f22e18

Browse files
committed
Get rid of wrapper script for creating ROOT dictionaries
The sole need for the wrapper was to properly handle warnings and complain on missing options. Since long rootcling is now gracefully handling both, so we remove the wrapper.
1 parent 7675f01 commit 4f22e18

4 files changed

Lines changed: 77 additions & 164 deletions

File tree

‎cmake/AddRootDictionary.cmake‎

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111

1212
include_guard()
1313

14-
configure_file(${CMAKE_CURRENT_LIST_DIR}/rootcling_wrapper.sh.in
15-
${CMAKE_BINARY_DIR}/rootcling_wrapper.sh @ONLY)
14+
set(O2_RUN_ROOTCLING_SCRIPT ${CMAKE_CURRENT_LIST_DIR}/RunRootcling.cmake)
1615

1716
#
1817
# add_root_dictionary generates one dictionary to be added to a target.
@@ -132,25 +131,37 @@ function(add_root_dictionary target)
132131
set(includeDirs $<TARGET_PROPERTY:${target},INCLUDE_DIRECTORIES>)
133132
set(includeDirs $<REMOVE_DUPLICATES:${includeDirs}>)
134133

135-
list(LENGTH A_EXTRA_PATCH hasExtraPatch)
136-
# add a custom command to generate the dictionary using rootcling
134+
# the pcm dependencies (-m) are only meaningful where the modules are actually
135+
# loaded from disk, which is not the case on macOS
136+
set(pcmDeps $<REMOVE_DUPLICATES:$<TARGET_PROPERTY:${target},O2_PCM_DEPS>>)
137+
if(APPLE)
138+
set(pcmDeps)
139+
endif()
140+
141+
if(A_EXTRA_PATCH)
142+
set(extraPatch -DPATCH=${CMAKE_CURRENT_LIST_DIR}/${A_EXTRA_PATCH})
143+
else()
144+
set(extraPatch)
145+
endif()
146+
147+
# the arguments are joined with | so that they reach the script as a single
148+
# argument, see RunRootcling.cmake
137149
# cmake-format: off
150+
set(rootclingArgs
151+
-f|${dictionaryFile}|-inlineInputHeader|-noGlobalUsingStd|-rmf|${rootmapFile}|-rml|$<TARGET_FILE_NAME:${target}>|-I$<JOIN:${includeDirs},|-I>$<$<BOOL:${prop}>:|-D$<JOIN:${prop},|-D>>$<$<BOOL:${pcmDeps}>:|-m|$<JOIN:${pcmDeps},|-m|>>|$<JOIN:${headers},|>)
152+
153+
# add a custom command to generate the dictionary using rootcling
138154
add_custom_command(
139155
OUTPUT ${dictionaryFile} ${pcmFile} ${rootmapFile}
140156
VERBATIM
141157
COMMAND
142-
${CMAKE_BINARY_DIR}/rootcling_wrapper.sh
143-
--rootmap_file ${rootmapFile}
144-
--dictionary_file ${dictionaryFile}
145-
--ld_library_path ${LD_LIBRARY_PATH}
146-
--rootmap_library_name $<TARGET_FILE_NAME:${target}>
147-
--include_dirs -I$<JOIN:${includeDirs},$<SEMICOLON>-I>
148-
$<$<BOOL:${prop}>:--compile_defs>
149-
$<$<BOOL:${prop}>:-D$<JOIN:${prop},$<SEMICOLON>-D>>
150-
$<$<BOOL:${hasExtraPatch}>:--extra-patch>
151-
$<$<BOOL:${hasExtraPatch}>:${CMAKE_CURRENT_LIST_DIR}/${A_EXTRA_PATCH}>
152-
--pcmdeps "$<REMOVE_DUPLICATES:$<TARGET_PROPERTY:${target},O2_PCM_DEPS>>"
153-
--headers "${headers}"
158+
${CMAKE_COMMAND} -E env LD_LIBRARY_PATH=${LD_LIBRARY_PATH}
159+
${CMAKE_COMMAND}
160+
-DROOTCLING=${ROOT_rootcling_CMD}
161+
-DDICTIONARY=${dictionaryFile}
162+
${extraPatch}
163+
"-DARGS=${rootclingArgs}"
164+
-P ${O2_RUN_ROOTCLING_SCRIPT}
154165
COMMAND
155166
${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_BINARY_DIR}/${pcmBase} ${pcmFile}
156167
DEPENDS ${headers} "$<REMOVE_DUPLICATES:$<TARGET_PROPERTY:${target},O2_PCM_DEPS>>" ${A_EXTRA_PATCH})

‎cmake/RunRootcling.cmake‎

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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+
# Runs rootcling, optionally appends PATCH to the generated dictionary, and
13+
# turns the "Unused class rule" warning into an error.
14+
#
15+
# rootcling only offers -failOnWarnings, which is all or nothing, so the
16+
# output still has to be inspected to single out that one warning.
17+
#
18+
# ARGS is separated by | rather than ; so that it survives as a single
19+
# argument through add_custom_command.
20+
21+
if(NOT ROOTCLING OR NOT ARGS OR NOT DICTIONARY)
22+
message(FATAL_ERROR "ROOTCLING, ARGS and DICTIONARY must all be given")
23+
endif()
24+
25+
string(REPLACE "|" ";" rootclingArgs "${ARGS}")
26+
27+
execute_process(COMMAND ${ROOTCLING} ${rootclingArgs}
28+
OUTPUT_VARIABLE output
29+
ERROR_VARIABLE output
30+
RESULT_VARIABLE status)
31+
32+
if(output)
33+
message("${output}")
34+
endif()
35+
36+
if(NOT status EQUAL 0)
37+
file(REMOVE ${DICTIONARY})
38+
message(FATAL_ERROR "rootcling failed for ${DICTIONARY} with error code ${status}")
39+
endif()
40+
41+
if(output MATCHES "Warning: Unused class rule")
42+
file(REMOVE ${DICTIONARY})
43+
message(FATAL_ERROR "please fix the warnings above about unused class rule")
44+
endif()
45+
46+
if(PATCH)
47+
file(READ ${PATCH} patchContent)
48+
file(APPEND ${DICTIONARY} "${patchContent}")
49+
endif()

‎cmake/rootcling_wrapper.sh.in‎

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

‎packaging/CMakeLists.txt‎

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,7 @@ install(EXPORT O2Targets
1717
FILE O2Targets.cmake)
1818

1919
install(FILES O2Config.cmake ../cmake/AddRootDictionary.cmake
20+
../cmake/RunRootcling.cmake
2021
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/O2)
2122

22-
install(FILES ../cmake/rootcling_wrapper.sh.in
23-
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/O2
24-
PERMISSIONS OWNER_READ
25-
OWNER_WRITE
26-
OWNER_EXECUTE
27-
GROUP_READ
28-
GROUP_EXECUTE
29-
WORLD_READ
30-
WORLD_EXECUTE)
31-
3223
install(DIRECTORY ../dependencies/ DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/O2)

0 commit comments

Comments
 (0)