From c9f14dab75ab84234f63ae98842b939ed4efc6b2 Mon Sep 17 00:00:00 2001 From: Johannes Elmsheuser <johannes.elmsheuser@cern.ch> Date: Wed, 17 Aug 2016 13:13:11 +0200 Subject: [PATCH] Tagging AtlasCMake-00-01-68 (AtlasCMake-00-01-68) * scripts/acmake.py (show_clients): add check if directory exists * Tagging as AtlasCMake-00-01-68 2016-08-11 Attila Krasznahorkay <Attila.Krasznahorkay@cern.ch> * Fixed atlas_add_dictionary(...) to behave the same way with Navigables as the CMT pattern did. That for all types that need Navigable dictionaries, would get DataLink and ElementLink dictionaries automatically as well. * Tagging as AtlasCMake-00-01-67 2016-08-09 Attila Krasznahorkay <Attila.Krasznahorkay@cern.ch> * Made sure that FindGaudi.cmake would not pollute the user's environment with variables used by it internally. * Tested that Johannes's code seems to work as it should. * Tagging as AtlasCMake-00-01-66 2016-08-09 Johannes Elmsheuser <Johannes.Elmsheuser@cern.ch> * Added 4 and 5 digit cache support for Gaudi RPM - fixes ATLINFR-1217 * Tagging as AtlasCMake-00-01-65 ... (Long ChangeLog diff - truncated) --- Build/AtlasCMake/AtlasCMakeConfig.cmake | 9 +- .../modules/AtlasCompilerSettings.cmake | 2 +- .../modules/AtlasDictionaryFunctions.cmake | 12 +- Build/AtlasCMake/modules/AtlasFunctions.cmake | 7 +- Build/AtlasCMake/modules/FindGaudi.cmake | 22 ++- Build/AtlasCMake/scripts/acmake.py | 122 ++++++++++++++++- .../AtlasCMake/scripts/cmakeNightlyInstall.sh | 129 ++++++++++++++++++ .../AtlasCMake/scripts/cmakeReleaseInstall.sh | 122 +++++++++++++++++ 8 files changed, 408 insertions(+), 17 deletions(-) create mode 100755 Build/AtlasCMake/scripts/cmakeNightlyInstall.sh create mode 100755 Build/AtlasCMake/scripts/cmakeReleaseInstall.sh diff --git a/Build/AtlasCMake/AtlasCMakeConfig.cmake b/Build/AtlasCMake/AtlasCMakeConfig.cmake index 69aa398bffbb..a5762baff566 100644 --- a/Build/AtlasCMake/AtlasCMakeConfig.cmake +++ b/Build/AtlasCMake/AtlasCMakeConfig.cmake @@ -1,6 +1,6 @@ # Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -# $Id: AtlasCMakeConfig.cmake 746543 2016-05-12 11:31:22Z krasznaa $ +# $Id: AtlasCMakeConfig.cmake 756309 2016-06-20 15:39:40Z krasznaa $ # # This file is used to make it possible to pull in the code of this package into # a top level CMake file using: @@ -21,7 +21,7 @@ # Print a status message that the file was found: if( NOT AtlasCMake_FIND_QUIETLY ) - message( STATUS "AtlasCMake found with version: $Revision: 746543 $" ) + message( STATUS "AtlasCMake found with version: $Revision: 756309 $" ) endif() # Get the current directory: @@ -43,7 +43,10 @@ set( ATLAS_DONT_PREPEND_PROJECT_MODULES TRUE CACHE BOOL "Prevent built projects from prepending to CMAKE_MODULE_PATH" ) # Install the helper script(s) from the package: -install( PROGRAMS ${_thisdir}/scripts/acmake.py DESTINATION bin ) +install( PROGRAMS ${_thisdir}/scripts/acmake.py + ${_thisdir}/scripts/cmakeNightlyInstall.sh + ${_thisdir}/scripts/cmakeReleaseInstall.sh + DESTINATION bin ) install( DIRECTORY ${_thisdir}/cmt2cmake DESTINATION . USE_SOURCE_PERMISSIONS PATTERN ".*" EXCLUDE diff --git a/Build/AtlasCMake/modules/AtlasCompilerSettings.cmake b/Build/AtlasCMake/modules/AtlasCompilerSettings.cmake index a233ed30cc3f..8bdcc9675f3a 100644 --- a/Build/AtlasCMake/modules/AtlasCompilerSettings.cmake +++ b/Build/AtlasCMake/modules/AtlasCompilerSettings.cmake @@ -1,6 +1,6 @@ # Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -# $Id: AtlasCompilerSettings.cmake 754486 2016-06-13 13:31:01Z smh $ +# $Id: AtlasCompilerSettings.cmake 766879 2016-08-08 09:10:26Z krasznaa $ # # This file collects settings fine-tuning all the compiler and linker options # used in an ATLAS build in one place. It is included by default when using diff --git a/Build/AtlasCMake/modules/AtlasDictionaryFunctions.cmake b/Build/AtlasCMake/modules/AtlasDictionaryFunctions.cmake index 6e608adf1760..028abe25ac64 100644 --- a/Build/AtlasCMake/modules/AtlasDictionaryFunctions.cmake +++ b/Build/AtlasCMake/modules/AtlasDictionaryFunctions.cmake @@ -1,6 +1,6 @@ # Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -# $Id: AtlasDictionaryFunctions.cmake 744739 2016-05-04 08:23:56Z krasznaa $ +# $Id: AtlasDictionaryFunctions.cmake 767403 2016-08-11 07:16:59Z krasznaa $ # # This file collects the ATLAS CMake helper functions that set up the build and # installation of ROOT dictionaries in an offline or analysis build. @@ -93,8 +93,9 @@ function( atlas_add_dictionary libName libHeader libSelection ) mark_as_advanced( _mergeFilesCmd _mergeSelectionsCmd ) # If the user asked for additional DataLink<T> types to generate dictionaries - # for, set these up now: - foreach( type ${ARG_DATA_LINKS} ) + # for, set these up now. Note that types listed as navigables, are also used + # here. + foreach( type ${ARG_DATA_LINKS} ${ARG_NAVIGABLES} ) # Sanitise the type name: string( REPLACE ":" "_" typeSanitised ${type} ) string( REPLACE "<" "_" typeSanitised ${typeSanitised} ) @@ -115,8 +116,9 @@ function( atlas_add_dictionary libName libHeader libSelection ) endforeach() # If the user asked for additional ElementLink<T> types to generate - # dictionaries for, set these up now: - foreach( type ${ARG_ELEMENT_LINKS} ) + # dictionaries for, set these up now. Note that types listed as navigables, + # are also used here. + foreach( type ${ARG_ELEMENT_LINKS} ${ARG_NAVIGABLES} ) # Sanitise the type name: string( REPLACE ":" "_" typeSanitised ${type} ) string( REPLACE "<" "_" typeSanitised ${typeSanitised} ) diff --git a/Build/AtlasCMake/modules/AtlasFunctions.cmake b/Build/AtlasCMake/modules/AtlasFunctions.cmake index bfc2e4ca3a5a..5a53feee7eab 100644 --- a/Build/AtlasCMake/modules/AtlasFunctions.cmake +++ b/Build/AtlasCMake/modules/AtlasFunctions.cmake @@ -1,6 +1,6 @@ # Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -# $Id: AtlasFunctions.cmake 753396 2016-06-07 15:36:05Z krasznaa $ +# $Id: AtlasFunctions.cmake 760944 2016-07-11 09:03:46Z krasznaa $ # # This is the main file that needs to be included in order to get access to the # ATLAS CMake functions. @@ -90,6 +90,11 @@ function( atlas_project name version ) set( CMAKE_NO_SYSTEM_FROM_IMPORTED ON ) set( CMAKE_NO_SYSTEM_FROM_IMPORTED ON PARENT_SCOPE ) + # Do not consider header files that are outside of the project's source + # and binary directory in the dependency tree of the source files. + set( CMAKE_DEPENDS_IN_PROJECT_ONLY ON ) + set( CMAKE_DEPENDS_IN_PROJECT_ONLY ON PARENT_SCOPE ) + # Decide about the languages used in the project: set( _languages CXX C ) if( ARG_FORTRAN ) diff --git a/Build/AtlasCMake/modules/FindGaudi.cmake b/Build/AtlasCMake/modules/FindGaudi.cmake index 3996e5c9c25d..b93d5b988b42 100644 --- a/Build/AtlasCMake/modules/FindGaudi.cmake +++ b/Build/AtlasCMake/modules/FindGaudi.cmake @@ -1,6 +1,6 @@ # Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -# $Id: FindGaudi.cmake 755055 2016-06-15 15:07:02Z krasznaa $ +# $Id: FindGaudi.cmake 767061 2016-08-09 13:20:02Z krasznaa $ # # CMake script attempting to find a Gaudi installation that we can build # the offline code against. Without making any use of the CMake code @@ -44,8 +44,8 @@ set( GAUDI_PYTHON_PATH ${GAUDI_INSTALLAREA}/python ) # Additional environment settings: set( GAUDI_ENVIRONMENT SET GAUDI_ROOT ${GAUDI_ROOT} - APPEND JOBOPTSEARCHPATH ${GAUDI_INSTALLAREA}/jobOptions - APPEND DATAPATH ${GAUDI_INSTALLAREA}/share ) + PREPEND JOBOPTSEARCHPATH ${GAUDI_INSTALLAREA}/jobOptions + PREPEND DATAPATH ${GAUDI_INSTALLAREA}/share ) # Handle the usual parameters given to find_package(...) calls: include( FindPackageHandleStandardArgs ) @@ -131,7 +131,21 @@ elseif( NOT "$ENV{GAUDI_VERSION}" STREQUAL "" ) set( version $ENV{GAUDI_VERSION} ) elseif( PROJECT_VERSION ) # This should kick in when building a release with NICOS: - set( version ${PROJECT_VERSION} ) + string (REGEX MATCHALL "[0-9]+" _versionComponents "${PROJECT_VERSION}") + list (LENGTH _versionComponents _len) + if (${_len} GREATER 3) + if (${_len} GREATER 4) + LIST(REMOVE_AT _versionComponents 4) + endif() + LIST(REMOVE_AT _versionComponents 3) + string (REPLACE ";" "." _TMP_STR "${_versionComponents}") + set ( version "${_TMP_STR}" ) + unset( _TMP_STR ) + else() + set( version ${PROJECT_VERSION} ) + endif() + unset( _versionComponents ) + unset( _len ) else() set( version "${CMAKE_PROJECT_VERSION}" ) endif() diff --git a/Build/AtlasCMake/scripts/acmake.py b/Build/AtlasCMake/scripts/acmake.py index d23bad77c1ca..095c0f93e0e2 100755 --- a/Build/AtlasCMake/scripts/acmake.py +++ b/Build/AtlasCMake/scripts/acmake.py @@ -2,7 +2,7 @@ # Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration # -# $Id: acmake.py 725017 2016-02-19 11:13:55Z krasznaa $ +# $Id: acmake.py 768404 2016-08-17 13:12:02Z elmsheus $ # # Helper script for replacing the most useful features of cmt that we used # in the ATLAS software development. @@ -21,7 +21,7 @@ def main(): import optparse parser = optparse.OptionParser( description = "Lightweight replacement for " "the most used CMT features with CMake", - version = "$Revision: 725017 $", + version = "$Revision: 768404 $", usage = "%prog [command] [options]" ) parser.add_option( "-r", "--revision", type="string", dest="revision", action="store", default=None, @@ -42,11 +42,16 @@ def main(): return checkout( command[ 1 ], options.revision ) else: return checkout( command[ 1 ] ) - elif command[ 0 ] == "show_versions": + elif command[ 0 ] == "sv" or command[ 0 ] == "show_versions": if len( command ) != 2: parser.error( "You need to specify a package after 'show_versions'" ) return 1 return show_versions( command[ 1 ] ) + elif command[ 0 ] == "sc" or command[ 0 ] == "show_clients": + if len( command ) != 2: + parser.error( "You need to specify a package after 'show_clients'" ) + return 1 + return show_clients( command[ 1 ] ) else: parser.error( "Command '%s' not recognised" % command[ 0 ] ) return 1 @@ -178,6 +183,117 @@ def show_versions( package ): # Return gracefully: return 0 +## Function collecting the packages that are the clients of the one specified +# +# This is a replacement for the "cmt show clients ..." command. Listing the +# names of the packages that publicly or privately depend on the package +# that the user specified. +# +# @param package The name of the package. Not containing it full path. +# +def show_clients( package ): + + # Get the CMAKE_PREFIX_PATH environment variable. As we'll be searching + # in that. + ppath = os.getenv( "CMAKE_PREFIX_PATH" ) + if not ppath: + print( "ERROR: No release seems to be set up" ) + return 1 + + # Keep track of which directories were already visited: + releaseDirectories = [] + + # Target file finding regular expression: + target_re = re.compile( ".*-targets.cmake$" ) + + # Collect the names of all the files that the code will need to look at: + target_files = [] + for rdir in ppath.split( ":" ): + # Skip it if we already looked at this directory: + if rdir in releaseDirectories: + continue + # Look for a file called *-targets.cmake in its cmake/ subdirectory: + cmake_dir = os.path.join( rdir, "cmake" ) + if not (os.path.isdir(cmake_dir) or os.path.exists(cmake_dir)): + continue + tfiles = [ f for f in os.listdir( cmake_dir ) + if os.path.isfile( os.path.join( cmake_dir, f ) ) and + target_re.search( f ) ] + if len( tfiles ) != 1: + print( "WARNING: Multiple target files found in directory %s" % \ + cmake_dir ) + print( "WARNING: Found files: %s" % str( target_files ) ) + pass + # Add this to the overall list: + target_files += [ os.path.join( cmake_dir, f ) for f in tfiles ] + pass + + ## Sub-function collecting the clients of one given package + # + # @param package The name of the package to collect the clients of + # @param public Set to <code>True</code> to look for public dependencies, + # or to <code>False</code> to look for private ones + # @param recursive Set to <code>True</code> to look for (public) clients + # recursively + # @returns A set with the names of the requested clients + # + def collect_clients( package, public, recursive ): + # A small sanity check: + if not public and recursive: + print( "ERROR: It doesn't make sense to ask for private clients " + "recursicely!" ) + return set([]) + # Construct the regular expression to use: + client_re = "" + if public: + client_re = \ + "^set_target_properties\(\w+::(\w+)Pkg PROPERTIES[^\)]*" \ + "INTERFACE_LINK_LIBRARIES \"(?:[^\"]*[:;]+)?%sPkg[^\"]*\"" % \ + package + else: + client_re = \ + "^set_target_properties\(\w+::(\w+)PkgPrivate PROPERTIES[^\)]*" \ + "INTERFACE_LINK_LIBRARIES \"(?:[^\"]*[:;]+)?%sPkg[^\"]*\"" % \ + package + pass + # The result list: + result = set([]) + # Loop over the files: + for fname in target_files: + # Open the file: + target_file = open( fname, "r" ) + # Take the direct clients of this package: + clients = re.findall( client_re, target_file.read(), + re.MULTILINE ) + # If recursion is asked for, do that: + if recursive: + for client in clients: + for pkg in collect_clients( client, public, True ): + result.add( pkg ) + pass + pass + pass + # Finally, add the direct dependencies: + for client in clients: + result.add( client ) + pass + pass + # Return the resulting set: + return result + + # Collect and print the results: + print( "Clients for package %s:" % package ) + direct_private = collect_clients( package, False, False ) + print( " Direct private clients : %s" % str( list( direct_private ) ) ) + direct_public = collect_clients( package, True, False ) + print( " Direct public clients : %s" % str( list( direct_public ) ) ) + print( " Indirect public clients: %s" % \ + str( list( collect_clients( package, True, True ) - + direct_public - direct_private ) ) ) + + # Return gracefully: + return 0 + # Execute the main function: if __name__ == "__main__": import sys diff --git a/Build/AtlasCMake/scripts/cmakeNightlyInstall.sh b/Build/AtlasCMake/scripts/cmakeNightlyInstall.sh new file mode 100755 index 000000000000..dd7a3e974128 --- /dev/null +++ b/Build/AtlasCMake/scripts/cmakeNightlyInstall.sh @@ -0,0 +1,129 @@ +#!/bin/bash +# +# $Id: cmakeNightlyInstall.sh 756309 2016-06-20 15:39:40Z krasznaa $ +# +# Installtion script of ATLAS CMake nightly RPMs +# Author: Johannes Elmsheuser, Attila Krasznahorkay +# Date: April 2016 + +# Function showing the usage help +show_help() { + echo "Usage: cmakeRPMInstall.sh -r nightlyVer -d installDir -t dateString pkg1 pkg2..." + echo "Example: ./cmakeRPMInstall.sh -r 21.X.Y-VAL/rel_2 -d $HOME/opt -t 2016-06-20T1650 AtlasOffline*" +} + +# Stop on errors: +set -e + +# Parse the command line arguments: +OPTIND=1 +while getopts ":r:d:t:" opt; do + case "$opt" in + h|\?) + show_help + exit 0 + ;; + r) + NIGHTLYVER=$OPTARG + ;; + d) + INSTALLDIR=`readlink -f $OPTARG` + ;; + t) + DATEDIR=$OPTARG + ;; + esac +done +shift $((OPTIND-1)) +PROJECTS=$@ + +if [ ! -d "$TMPDIR" ]; then + if [ -d "/tmp/$USER" ]; then + export TMPDIR=/tmp/$USER + else + export TMPDIR=$HOME + fi +fi + +# ayum directory +AYUMDIR=$TMPDIR +# Directory name with the date +if [ -z "$DATEDIR" ]; then + DATEDIR=`date "+%FT%H%M"` +fi + +echo "#############################################" +echo "Installing project(s) $PROJECTS" +echo " from nightly : $NIGHTLYVER" +echo " into directory: $INSTALLDIR/$DATEDIR" +echo " AYUM directory: $AYUMDIR" +echo "#############################################" +echo + +# Check that everything was specified: +if [ -z "$NIGHTLYVER" ] || [ -z "$INSTALLDIR" ] || \ + [ -z "$PROJECTS" ]; then + show_help + exit 1 +fi + +# Create RPM directory: +if [ ! -d "$INSTALLDIR" ]; then + echo "Creating directory $INSTALLDIR" + mkdir -p $INSTALLDIR +fi + +# Set up ayum from scratch in the current directory: +CURDIR=$PWD +cd $AYUMDIR +rm -rf ayum/ +git clone https://gitlab.cern.ch/rhauser/ayum.git +cd ayum +./configure.ayum -i $INSTALLDIR -D > yum.conf + +# Remove the unnecessary line from the generated file: +sed 's/AYUM package location.*//' yum.conf > yum.conf.fixed +mv yum.conf.fixed yum.conf + +# Configure the ayum repositories: +cat - >./etc/yum.repos.d/lcg.repo <<EOF +[lcg-repo] +name=LCG Repository +baseurl=http://cern.ch/service-spi/external/rpms/lcg +prefix=${INSTALLDIR}/sw/lcg/releases +enabled=1 +EOF + +cat - >./etc/yum.repos.d/tdaq-nightly.repo <<EOF +[tdaq-nightly] +name=nightly snapshots of TDAQ releases +baseurl=http://cern.ch/atlas-tdaq-sw/yum/tdaq/nightly +enabled=1 +EOF + +cat - >./etc/yum.repos.d/atlas-offline-data.repo <<EOF +[atlas-offline-data] +name=ATLAS offline data packages +baseurl=http://cern.ch/atlas-software-dist/RPMs/data +enabled=1 +EOF + +cat - >./etc/yum.repos.d/atlas-offline-nightly.repo <<EOF +[atlas-offline-nightly] +name=ATLAS offline nightly releases +baseurl=http://cern.ch/atlas-software-dist/RPMs/nightlies/${NIGHTLYVER} +prefix=${INSTALLDIR}/${DATEDIR} +enabled=1 +EOF + +# Tell the user what happened: +echo "Configured AYUM" + +# Setup environment to run the ayum command: +shopt -s expand_aliases +source ./setup.sh +cd $CURDIR + +# First try to reinstall the project. Assuming that a previous version +# of it is already installed. If it's not, then simply install it. +ayum -y reinstall $PROJECTS || ayum -y install $PROJECTS diff --git a/Build/AtlasCMake/scripts/cmakeReleaseInstall.sh b/Build/AtlasCMake/scripts/cmakeReleaseInstall.sh new file mode 100755 index 000000000000..03561b470272 --- /dev/null +++ b/Build/AtlasCMake/scripts/cmakeReleaseInstall.sh @@ -0,0 +1,122 @@ +#!/bin/bash +# +# $Id: cmakeReleaseInstall.sh 756309 2016-06-20 15:39:40Z krasznaa $ +# +# Installtion script of ATLAS CMake release RPMs +# Author: Johannes Elmsheuser, Attila Krasznahorkay +# Date: May 2016 + +# Function showing the usage help +show_help() { + echo "Usage: cmakeRPMInstall.sh -d installDir -c yumCacheDir pkg1 pkg2..." + echo "Example: ./cmakeRPMInstall.sh -d /opt/releases -c /tmp/rpms AtlasOffline_21.0.0_x86_64-slc6-gcc49-opt" +} + +# Stop on errors: +set -e + +# Parse the command line arguments: +OPTIND=1 +while getopts ":d:c:" opt; do + case "$opt" in + h|\?) + show_help + exit 0 + ;; + d) + INSTALLDIR=`readlink -f $OPTARG` + ;; + c) + CACHEDIR=`readlink -f $OPTARG` + ;; + esac +done +shift $((OPTIND-1)) +PROJECTS=$@ + +# ayum directory +AYUMDIR=$TMPDIR +# Directory name with the date +DATEDIR=`date "+%FT%H%M"` + +echo "#############################################" +echo "Installing project(s) $PROJECTS" +echo " into directory : $INSTALLDIR" +echo " using cache dir: $CACHEDIR" +echo " AYUM directory : $AYUMDIR" +echo "#############################################" +echo + +# Check that everything was specified: +if [ -z "$INSTALLDIR" ] || [ -z "$PROJECTS" ]; then + show_help + exit 1 +fi + +# Create the installation directory: +if [ ! -d "$INSTALLDIR" ]; then + echo "Creating directory $INSTALLDIR" + mkdir -p $INSTALLDIR +fi + +# Set up ayum from scratch in the current directory: +CURDIR=$PWD +cd $AYUMDIR +rm -rf ayum/ +git clone https://gitlab.cern.ch/rhauser/ayum.git +cd ayum +if [ -z "$CACHEDIR" ]; then + ./configure.ayum -i $INSTALLDIR -D > yum.conf +else + ./configure.ayum -i $INSTALLDIR -c $CACHEDIR -D > yum.conf +fi + +# Remove the unnecessary line from the generated file: +sed 's/AYUM package location.*//' yum.conf > yum.conf.fixed +mv yum.conf.fixed yum.conf + +# Configure the ayum repositories: +cat - >./etc/yum.repos.d/lcg.repo <<EOF +[lcg-repo] +name=LCG Repository +baseurl=http://cern.ch/service-spi/external/rpms/lcg +prefix=${INSTALLDIR}/sw/lcg/releases +enabled=1 +EOF + +cat - >./etc/yum.repos.d/tdaq-nightly.repo <<EOF +[tdaq-nightly] +name=nightly snapshots of TDAQ releases +baseurl=http://cern.ch/atlas-tdaq-sw/yum/tdaq/nightly +enabled=1 +EOF + +cat - >./etc/yum.repos.d/atlas-offline-data.repo <<EOF +[atlas-offline-data] +name=ATLAS offline data packages +baseurl=http://cern.ch/atlas-software-dist/RPMs/data +enabled=1 +EOF + +cat - >./etc/yum.repos.d/atlas-offline-releases.repo <<EOF +[atlas-offline-releases-slc6] +name=ATLAS offline releases SLC6 +baseurl=http://cern.ch/atlas-software-dist/RPMs/releases/slc6 +enabled=1 + +[atlas-offline-releases-cc7] +name=ATLAS offline releases CC7 +baseurl=http://cern.ch/atlas-software-dist/RPMs/releases/cc7 +enabled=0 +EOF + +# Tell the user what happened: +echo "Configured AYUM" + +# Setup environment to run the ayum command: +shopt -s expand_aliases +source ./setup.sh +cd $CURDIR + +# Install the requested project(s): +ayum -y install $PROJECTS -- GitLab