-
Notifications
You must be signed in to change notification settings - Fork 122
/
buildscript
executable file
·151 lines (136 loc) · 6.38 KB
/
buildscript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#!/bin/bash -ex
###############################################################################
# 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
echo "SHA1=${sha1}"
###############################################################################
# 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
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"
fi
else
# Mac packaging
PACKAGINGVARS="-DPACKAGE_DOCS=ON"
fi
fi
###############################################################################
# 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
## Use RelWithDbgInfo unless requested by the job name
###############################################################################
if [[ ${JOB_NAME} == *debug* ]]; then
BUILD_CONFIG="Debug"
elif [[ ${JOB_NAME} == *release* ]]; then
BUILD_CONFIG="Release"
else
BUILD_CONFIG="RelWithDebInfo"
fi
###############################################################################
# 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
###############################################################################
$SCL_ON_RHEL6 "cmake --build . -- -j$BUILD_THREADS"
$SCL_ON_RHEL6 "cmake --build . --target AllTests -- -j$BUILD_THREADS"
###############################################################################
# Run the tests
###############################################################################
# Remove any Mantid.user.properties file
rm -f ~/.mantid/Mantid.user.properties
$SCL_ON_RHEL6 "ctest -j$BUILD_THREADS --schedule-random --output-on-failure"
###############################################################################
# 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 "cmake --build . --target docs-qthelp"
fi
###############################################################################
# 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
$SCL_ON_RHEL6 "cpack"
fi
# 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 "cmake --build . --target 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
fi