Newer
Older
###############################################################################
# LINUX/MAC SCRIPT TO DRIVE THE JENKINS BUILDS OF MANTID.
#
# Notes:
#
# WORKSPACE, JOB_NAME & NODE_LABEL are environment variables that are set by
# Jenkins. The last one corresponds to any labels set on a slave.
# BUILD_THREADS & PARAVIEW_DIR should be set in the configuration of each slave.
###############################################################################
###############################################################################
# Print out the versions of things we are using
###############################################################################
cmake --version
###############################################################################
# OS X setup steps
###############################################################################
if [[ $(uname) == 'Darwin' ]]; then
if [[ ${JOB_NAME} == *clang* ]]; then
# Assuming we are using the clang compiler
echo "Using clang/llvm compiler."
clang --version
else
# Assuming we are using the Intel compiler
cd $WORKSPACE/Code
./fetch_Third_Party.sh
cd $WORKSPACE
# Setup environment variables
source /opt/intel/bin/iccvars.sh intel64
export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$WORKSPACE/Code/Third_Party/lib/mac64:/Library/Frameworks
# Make sure we pick up the Intel compiler
export CC=icc
export CXX=icpc
echo "Using Intel compiler."
icpc --version
fi
###############################################################################
# Check whether this is a clean build (must have 'clean' in the job name)
###############################################################################
if [[ ${JOB_NAME} == *clean* ]]; then
CLEANBUILD=true
# Removing the build directory entirely guarantees a completely clean build
rm -rf $WORKSPACE/build
# Set some variables relating to the linux packages created from clean builds
if [[ $(uname) != 'Darwin' ]]; then
# Use different suffix for linux builds
if [[ ${JOB_NAME} == *master* ]]; then
PACKAGINGVARS="-DENVVARS_ON_INSTALL=False -DCMAKE_INSTALL_PREFIX=/opt/mantidnightly -DCPACK_PACKAGE_SUFFIX=nightly -DCPACK_SET_DESTDIR=OFF -DPACKAGE_DOCS=ON"
elif [[ ${JOB_NAME} == *develop* ]]; then
PACKAGINGVARS="-DENVVARS_ON_INSTALL=False -DCMAKE_INSTALL_PREFIX=/opt/mantidunstable -DCPACK_PACKAGE_SUFFIX=unstable -DCPACK_SET_DESTDIR=OFF -DPACKAGE_DOCS=ON"
elif [[ ${JOB_NAME} == *release* ]]; then
PACKAGINGVARS="-DENVVARS_ON_INSTALL=True -DCPACK_SET_DESTDIR=ON -DPACKAGE_DOCS=ON"
else
# Mac packaging
PACKAGINGVARS="-DPACKAGE_DOCS=ON"
###############################################################################
# RHEL6 setup steps - nodes must have a "rhel6" label set (in lowercase)
###############################################################################
if [[ ${NODE_LABELS} == *rhel6* ]]; then
SCL_ON_RHEL6="scl enable mantidlibs"
ON_RHEL6=true
else
SCL_ON_RHEL6="eval"
fi
###############################################################################
# Create the build directory if it doesn't exist
###############################################################################
[ -d $WORKSPACE/build ] || mkdir $WORKSPACE/build
cd $WORKSPACE/build
###############################################################################
## Check the required build configuration
###############################################################################
if [[ ${JOB_NAME} == *debug* ]]; then
BUILD_CONFIG="Debug"
elif [[ ${JOB_NAME} == *relwithdbg* ]]; then
BUILD_CONFIG="RelWithDbg"
BUILD_CONFIG="Release"
###############################################################################
# CMake configuration
###############################################################################
$SCL_ON_RHEL6 "cmake -DCMAKE_BUILD_TYPE=${BUILD_CONFIG} -DENABLE_CPACK=ON -DMAKE_VATES=ON -DParaView_DIR=${PARAVIEW_DIR} -DDOCS_HTML=ON ${PACKAGINGVARS} ../Code/Mantid"
###############################################################################
# Build step
###############################################################################
Russell Taylor
committed
$SCL_ON_RHEL6 "make -j$BUILD_THREADS"
$SCL_ON_RHEL6 "make -j$BUILD_THREADS AllTests"
###############################################################################
# Run the tests
###############################################################################
# Remove any Mantid.user.properties file
rm -f ~/.mantid/Mantid.user.properties
Russell Taylor
committed
$SCL_ON_RHEL6 "ctest -j$BUILD_THREADS --schedule-random --output-on-failure -E MantidPlot"
# Run GUI tests serially
Russell Taylor
committed
$SCL_ON_RHEL6 "ctest --output-on-failure -R MantidPlot"
###############################################################################
# Documentation
# Build Qt help on all platforms for a clean build so that it can be packaged
###############################################################################
if [[ "$CLEANBUILD" == true ]]; then
# Workaround so that the target can find the properties file
# CMake doesn't easily allow environment variables on custom targets
if [[ $(uname) == 'Darwin' ]]; then
export MANTIDPATH=$PWD/bin
fi
$SCL_ON_RHEL6 "make docs-qthelp"
###############################################################################
# Create the install kit if this is a clean or non-Mac build
###############################################################################
rm -f *.dmg *.rpm *.deb *.tar.gz
# Always build a package on linux
if [[ $(uname) != 'Darwin' ]]; then
$SCL_ON_RHEL6 "cpack"
fi
if [[ "$CLEANBUILD" == true ]]; then
# On the Mac, only create a package for clean builds
if [[ $(uname) == 'Darwin' ]]; then
# We could build the source tarball anywhere, but we choose to do it on RHEL6
# We also parcel up the documentation into a tar file that is easier to move around
# and labelled by the commit id it was built with. This assumes the Jenkins git plugin
# has set the GIT_COMMIT environment variable
if [[ "$ON_RHEL6" == true ]]; then
$SCL_ON_RHEL6 "make docs-html"
tar -cjf mantiddocs-g${GIT_COMMIT:0:7}.tar.bz2 --exclude='*.buildinfo' --exclude="MantidProject.q*" docs/html
# The ..._PREFIX argument avoids opt/Mantid directories at the top of the tree
$SCL_ON_RHEL6 "cpack --config CPackSourceConfig.cmake -D CPACK_PACKAGING_INSTALL_PREFIX="
fi