Skip to content

Commit

Permalink
DAs: improve single/collective RPM generation
Browse files Browse the repository at this point in the history
RPMs are not created automatically with `make`, one must manually invoke `make
<da><algo>da.rpm` to trigger the build. This saves some time as RPM generation
is expensive.

* Created individual targets for `<da><algo>da.rpm`
* Created meta target `daqDA-all-rpm` that creates all RPMs (note: it has to be
  invoked in single-core mode to avoid `rpmbuild` problems)
* Only generated RPMs will be copied to `<install_prefix>/darpms`
  • Loading branch information
dberzano committed Jul 19, 2016
1 parent 10e7a14 commit 758815f
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 8 deletions.
11 changes: 10 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,9 @@ else()
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
set(CMAKE_NO_SYSTEM_FROM_IMPORTED TRUE)

# List of modules for which PARfiles are enabled -- use the cache as global scope and clean it
# Use CMake cache as pseudo-"global" scope for those variables (list of PARfiles, list of DA RPMs)
set(ALIPARFILES "" CACHE INTERNAL "ALIPARFILES" FORCE)
set(ALIDARPMS "" CACHE INTERNAL "ALIDARPMS" FORCE)

# AliRoot base modules
add_subdirectory(STEER)
Expand Down Expand Up @@ -406,6 +407,14 @@ else()
string(REPLACE ";" " " ALIPARFILES_FLAT "${ALIPARFILES}")
message(STATUS "PARfile target enabled for the following modules: ${ALIPARFILES_FLAT}")

# List enabled DAs
if (NOT "${ALIDARPMS}" STREQUAL "" AND DARPM)
string(REPLACE ";" " " ALIDARPMS_FLAT "${ALIDARPMS}")
message(STATUS "The following DA RPMs can be created individually with 'make <name>da.rpm' or altogether with 'make daqDA-all-rpm': ${ALIDARPMS_FLAT}")
add_custom_target("daqDA-all-rpm" COMMENT "Creating all RPMs")
add_dependencies("daqDA-all-rpm" ${ALIDARPMS})
endif()

# Install Find macros for common packages to be further used by AliPhysics
install(FILES
cmake/CMakeALICE.cmake
Expand Down
33 changes: 26 additions & 7 deletions cmake/CMakeALICE.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,10 @@ macro(generateDA DETECTOR ALGORITHM STATIC_DEPENDENCIES)
# Installation
install(TARGETS ${DETECTOR}${ALGORITHM}da.exe RUNTIME DESTINATION bin)

# Append to the list of DA RPMs to generate in one go
list(APPEND ALIDARPMS "${DETECTOR}${ALGORITHM}da.rpm")
set(ALIDARPMS ${ALIDARPMS} CACHE INTERNAL "ALIDARPMS")

if(DARPM)
createDArpm("${DETECTOR}" "${ALGORITHM}")
endif(DARPM)
Expand All @@ -232,13 +236,25 @@ macro(createDArpm DETECTOR ALGORITHM)

configure_file("${AliRoot_SOURCE_DIR}/cmake/da.spec.in" "${DETECTOR}${_ALGORITHM}-da.spec" @ONLY)

add_custom_command(TARGET ${DETECTOR}${ALGORITHM}da.exe POST_BUILD
COMMAND mkdir ARGS -p da-${DETECTOR}${_ALGORITHM}-rpm/root/${DA_PREFIX}/ ${CMAKE_CURRENT_BINARY_DIR}/rpmbuild.tmp
COMMAND cp ARGS ${DETECTOR}${ALGORITHM}da.exe da-${DETECTOR}${_ALGORITHM}-rpm/root/${DA_PREFIX}/
COMMAND env ARGS TMPDIR=${CMAKE_CURRENT_BINARY_DIR}/rpmbuild.tmp rpmbuild --verbose --define "_topdir ${CMAKE_CURRENT_BINARY_DIR}/da-${DETECTOR}${_ALGORITHM}-rpm" --define "%buildroot ${CMAKE_CURRENT_BINARY_DIR}/da-${DETECTOR}${_ALGORITHM}-rpm/root" -bb ${DETECTOR}${_ALGORITHM}-da.spec
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} VERBATIM
COMMENT "RPM creation for ${DETECTOR}-${_ALGORITHM}"
add_custom_target("${DETECTOR}${ALGORITHM}da.rpm"

COMMAND mkdir -p
da-${DETECTOR}${_ALGORITHM}-rpm/root/${DA_PREFIX}/
${CMAKE_CURRENT_BINARY_DIR}/rpmbuild.tmp

COMMAND cp ${DETECTOR}${ALGORITHM}da.exe
da-${DETECTOR}${_ALGORITHM}-rpm/root/${DA_PREFIX}/
COMMAND env
TMPDIR=${CMAKE_CURRENT_BINARY_DIR}/rpmbuild.tmp
rpmbuild --verbose
--define "_topdir ${CMAKE_CURRENT_BINARY_DIR}/da-${DETECTOR}${_ALGORITHM}-rpm"
--define "%buildroot ${CMAKE_CURRENT_BINARY_DIR}/da-${DETECTOR}${_ALGORITHM}-rpm/root"
-bb ${DETECTOR}${_ALGORITHM}-da.spec

WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Creating RPM for DA ${DETECTOR}${ALGORITHM}da.exe"
)
add_dependencies("${DETECTOR}${ALGORITHM}da.rpm" "${DETECTOR}${ALGORITHM}da.exe")

# make clean will remove also the rpm folder
# Retrive the current list of file to be deleted - set_directory_property is overwriting, not adding to the list
Expand All @@ -247,7 +263,10 @@ macro(createDArpm DETECTOR ALGORITHM)
set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${_clean_files}")

# install RPM into $CMAKE_INSTALL_PREFIX/darpms
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/da-${DETECTOR}${_ALGORITHM}-rpm/RPMS/ DESTINATION darpms PATTERN "\\.rpm")
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/da-${DETECTOR}${_ALGORITHM}-rpm/RPMS/
DESTINATION darpms
OPTIONAL
PATTERN "\\.rpm")
endmacro()


Expand Down

0 comments on commit 758815f

Please sign in to comment.