Skip to content
Snippets Groups Projects
Commit e074a14b authored by Attila Krasznahorkay's avatar Attila Krasznahorkay
Browse files

Merge branch 'build-infrastructure-improvements' into 'master'

Build infrastructure improvements

This merge improves the robustness and the utility of the Athena build scripts.

For the `build_externals.sh` script if an install of AthenaExternals and Gaudi is found then the script will exit, unless `-f` is specified. This allows the script to be called multiple times safely, e.g., by the continuous integration system. Specifically the check is done against installs of AthenaExternals and Gaudi, so failed builds should not cause the script to think that there is a valid installation. There were minor improvements to use absolute paths internally that make debugging easier.

In the main `build.sh` script, I factorised out the environment setup piece to `build_env.sh`, allowing it to be easily sourced when someone wants to manage the build themselves or invoke the build commands in special ways.

There is also now support for options in the main build script to control which pieces of the build are done (cmake, make, install, cpack) allowing more detailed control (e.g., the continuous integration system certainly doesn't care about making RPMs - @cgumpert will like that).

Finally, there is a small change to the main `CMakeLists.txt` file to remove the zero compression option from RPM generation (which only saves a small amount of time, but inflates the RPM size greatly).

See merge request !177

Former-commit-id: 2e50c8578bf057a110a5f97eb8af01e4e65cefa6
parents 14c0acf9 763e6c17
No related merge requests found
......@@ -77,10 +77,5 @@ configure_file( ${CMAKE_SOURCE_DIR}/PostConfig.cmake.in
install( FILES ${CMAKE_BINARY_DIR}/PostConfig.cmake
DESTINATION ${CMAKE_INSTALL_CMAKEDIR} )
# Turn off the compression of the created RPM. This makes the RPM a lot
# bigger, but should push the RPM creation time down by a lot.
set( CPACK_RPM_SPEC_MORE_DEFINE
"%define _source_payload w0.gzdio\n%define _binary_payload w0.gzdio" )
# Package up the release using CPack:
atlas_cpack_setup()
......@@ -6,13 +6,24 @@
# Function printing the usage information for the script
usage() {
echo "Usage: build.sh [-t build type] [-b build dir]"
echo "Usage: build.sh [-t build type] [-b build dir] [-c] [-m] [-i] [-p]"
echo " -c: Execute CMake step"
echo " -m: Execute make step"
echo " -i: Execute install step"
echo " -p: Execute CPack step"
echo "If none of the c, m, i or p options are set then the script will do"
echo "*all* steps. Otherwise only the enabled steps are run - it's your"
echo "reponsibility to ensure that precusors are in good shape"
}
# Parse the command line arguments:
BUILDDIR=""
BUILDTYPE="RelWithDebInfo"
while getopts ":t:s:b:h" opt; do
EXE_CMAKE=""
EXE_MAKE=""
EXE_INSTALL=""
EXE_CPACK=""
while getopts ":t:b:hcmip" opt; do
case $opt in
t)
BUILDTYPE=$OPTARG
......@@ -20,6 +31,22 @@ while getopts ":t:s:b:h" opt; do
b)
BUILDDIR=$OPTARG
;;
c)
EXE_CMAKE="1"
;;
m)
EXE_MAKE="1"
;;
i)
EXE_INSTALL="1"
;;
p)
EXE_CPACK="1"
;;
h)
usage
exit 0
;;
:)
echo "Argument -$OPTARG requires a parameter!"
usage
......@@ -33,68 +60,50 @@ while getopts ":t:s:b:h" opt; do
esac
done
if [ -z "$EXE_CMAKE" -a -z "$EXE_MAKE" -a -z "$EXE_INSTALL" -a -z "$EXE_CPACK" ]; then
EXE_CMAKE="1"
EXE_MAKE="1"
EXE_INSTALL="1"
EXE_CPACK="1"
fi
# Stop on errors from here on out:
set -e
# We are in BASH, get the path of this script in a simple way:
# Source in our environment
AthenaSrcDir=$(dirname ${BASH_SOURCE[0]})
AthenaSrcDir=$(cd ${AthenaSrcDir};pwd)
# The directory holding the helper scripts:
scriptsdir=${AthenaSrcDir}/../../Build/AtlasBuildScripts
# Go to the main directory of the repository:
cd ${AthenaSrcDir}/../..
# Check if the user specified any source/build directories:
if [ "$BUILDDIR" = "" ]; then
if [ -z "$BUILDDIR" ]; then
BUILDDIR=${AthenaSrcDir}/../../../build
fi
# Set up the environment for the build:
export NICOS_PROJECT_VERSION=`cat ${AthenaSrcDir}/version.txt`
export NICOS_ATLAS_RELEASE=${NICOS_PROJECT_VERSION}
export NICOS_PROJECT_RELNAME=${NICOS_PROJECT_VERSION}
export NICOS_PROJECT_HOME=$(cd ${BUILDDIR}/install;pwd)/Athena
# Set up the environment variables for finding LCG and the TDAQ externals:
source ${scriptsdir}/LCG_RELEASE_BASE.sh
source ${scriptsdir}/TDAQ_RELEASE_BASE.sh
# Set up the AthenaExternals project:
extDir=${BUILDDIR}/install/AthenaExternals/${NICOS_PROJECT_VERSION}/InstallArea
if [ ! -d ${extDir} ]; then
echo "Didn't find the AthenaExternals project under ${extDir}"
exit 1
mkdir -p ${BUILDDIR}
BUILDDIR=$(cd ${BUILDDIR} && pwd)
source $AthenaSrcDir/build_env.sh -b $BUILDDIR
# CMake:
if [ -n "$EXE_CMAKE" ]; then
mkdir -p ${BUILDDIR}/build/Athena
cd ${BUILDDIR}/build/Athena
time cmake -DCMAKE_BUILD_TYPE:STRING=${BUILDTYPE} \
-DCTEST_USE_LAUNCHERS:BOOL=TRUE \
${AthenaSrcDir} 2>&1 | tee cmake_config.log
fi
echo "Setting up AthenaExternals from: ${extDir}"
source ${extDir}/*/setup.sh
# Get the "platform name" from the directory created by the AthenaExternals
# build:
platform=$(cd ${extDir};ls)
# Point to Gaudi:
export GAUDI_ROOT=${BUILDDIR}/install/GAUDI/${NICOS_PROJECT_VERSION}/InstallArea/${platform}
echo "Taking Gaudi from: ${GAUDI_ROOT}"
# Configure the build:
mkdir -p ${BUILDDIR}/build/Athena
cd ${BUILDDIR}/build/Athena
time cmake -DCMAKE_BUILD_TYPE:STRING=${BUILDTYPE} \
-DCTEST_USE_LAUNCHERS:BOOL=TRUE \
${AthenaSrcDir} 2>&1 | tee cmake_config.log
# At this point stop worrying about errors:
set +e
# Execute the build:
time make -k
# make:
if [ -n "$EXE_MAKE" ]; then
time make -k
fi
# Install the results:
time make install/fast \
DESTDIR=${BUILDDIR}/install/Athena/${NICOS_PROJECT_VERSION}
if [ -n "$EXE_INSTALL" ]; then
time make install/fast \
DESTDIR=${BUILDDIR}/install/Athena/${NICOS_PROJECT_VERSION}
fi
# Build an RPM for the release:
time cpack
cp Athena*.rpm ${BUILDDIR}/
if [ -n "$EXE_CPACK" ]; then
time cpack
cp Athena*.rpm ${BUILDDIR}/
fi
# This script sets up the build enironment for an Athena
# build, on top of a built set of externals (including Gaudi)
#
# This script is kept separate from the build.sh
# wrapper so it can be sourced separately from it when
# clients want to manage their own build and just want
# to setup the build environment
env_usage() {
echo "Usage: build_env.sh [-b build dir]"
}
# This function actually sets up the environment for us
# (factorise it here in case it needs skipped)
env_setup() {
startdir=$(pwd)
# As this script can be sourced we need to support zsh and
# possibly other Bourne shells
if [ "x${BASH_SOURCE[0]}" = "x" ]; then
# This trick should do the right thing under ZSH:
thisdir=$(dirname `print -P %x`)
if [ $? != 0 ]; then
echo "ERROR: This script must be sourced from BASH or ZSH"
return 1
fi
else
# The BASH solution is a bit more straight forward:
thisdir=$(dirname ${BASH_SOURCE[0]})
fi
AthenaSrcDir=$(cd ${thisdir};pwd)
# The directory holding the helper scripts:
scriptsdir=${AthenaSrcDir}/../../Build/AtlasBuildScripts
# Go to the main directory of the repository:
cd ${AthenaSrcDir}/../..
# Check if the user specified any source/build directories:
if [ "$BUILDDIR" = "" ]; then
BUILDDIR=${AthenaSrcDir}/../../../build
fi
# Set up the environment for the build:
export NICOS_PROJECT_VERSION=`cat ${AthenaSrcDir}/version.txt`
export NICOS_ATLAS_RELEASE=${NICOS_PROJECT_VERSION}
export NICOS_PROJECT_RELNAME=${NICOS_PROJECT_VERSION}
export NICOS_PROJECT_HOME=$(cd ${BUILDDIR}/install;pwd)/Athena
# Set up the environment variables for finding LCG and the TDAQ externals:
source ${scriptsdir}/LCG_RELEASE_BASE.sh
source ${scriptsdir}/TDAQ_RELEASE_BASE.sh
# Set up the AthenaExternals project:
extDir=${BUILDDIR}/install/AthenaExternals/${NICOS_PROJECT_VERSION}/InstallArea
if [ ! -d ${extDir} ]; then
echo "Didn't find the AthenaExternals project under ${extDir}"
fi
echo "Setting up AthenaExternals from: ${extDir}"
source ${extDir}/*/setup.sh
# Get the "platform name" from the directory created by the AthenaExternals
# build:
platform=$(cd ${extDir};ls)
# Point to Gaudi:
export GAUDI_ROOT=${BUILDDIR}/install/GAUDI/${NICOS_PROJECT_VERSION}/InstallArea/${platform}
echo "Taking Gaudi from: ${GAUDI_ROOT}"
cd $startdir
}
# Parse the command line arguments:
BUILDDIR=""
while getopts "b:h" opt; do
case $opt in
b)
BUILDDIR=$OPTARG
;;
h)
env_usage
ABORT=1
;;
:)
echo "Argument -$OPTARG requires a parameter!"
env_usage
ABORT=1
;;
?)
echo "Unknown argument: -$OPTARG"
env_usage
ABORT=1
;;
esac
done
# Put a big wrapper around bad argument case, because
# a sourced script should not call "exit". This is quite
# annoying...
if [ -z "$ABORT" ]; then
env_setup
fi
......@@ -5,13 +5,18 @@
# Function printing the usage information for the script
usage() {
echo "Usage: build_externals.sh [-t build type] [-b build dir]"
echo "Usage: build_externals.sh [-t build_type] [-b build_dir] [-f]"
echo " -f: Force rebuild of externals, otherwise if script"
echo " finds an external build present it will simply exit"
echo "If a build_dir is not given the default is '../build'"
echo "relative to the athena checkout"
}
# Parse the command line arguments:
BUILDDIR=""
BUILDTYPE="RelWithDebInfo"
while getopts ":t:s:b:h" opt; do
FORCE=""
while getopts ":t:b:fh" opt; do
case $opt in
t)
BUILDTYPE=$OPTARG
......@@ -19,6 +24,13 @@ while getopts ":t:s:b:h" opt; do
b)
BUILDDIR=$OPTARG
;;
f)
FORCE=1
;;
h)
usage
exit 0
;;
:)
echo "Argument -$OPTARG requires a parameter!"
usage
......@@ -65,6 +77,18 @@ cd ${thisdir}/../..
if [ "$BUILDDIR" = "" ]; then
BUILDDIR=${thisdir}/../../../build
fi
BUILDDIR=$(cd $BUILDDIR; pwd)
if [ -n "$FORCE" ]; then
echo "Force deleting existing build area..."
rm -fr ${BUILDDIR}/install ${BUILDDIR}/src ${BUILDDIR}/build
fi
if [ -d ${BUILDDIR}/install/AthenaExternals -a -d ${BUILDDIR}/install/GAUDI ]; then
echo "Found install directories for AthenaExternals and Gaudi in ${BUILDDIR}/install"
echo "Use -f option to force a rebuild"
exit 0
fi
# Create some directories:
mkdir -p ${BUILDDIR}/install
......@@ -76,6 +100,7 @@ export NICOS_PROJECT_RELNAME=${NICOS_PROJECT_VERSION}
# The directory holding the helper scripts:
scriptsdir=${thisdir}/../../Build/AtlasBuildScripts
scriptsdir=$(cd ${scriptsdir}; pwd)
# Set the environment variable for finding LCG releases:
source ${scriptsdir}/LCG_RELEASE_BASE.sh
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment