3 # pull source code in ${working_dir}/source
4 # build in ${working_dir}/build
5 # copyback directory is ${working_dir}/copyBack
10 Usage: $(basename ${0}) [-h]
11 env WORKSPACE=<workspace> LARVER=<larsoft version> QUAL=<qualifier> BUILDTYPE=<debug|prof> $(basename ${0})
21 for label in "${labels[@]}"; do
22 for wanted in "$@"; do
23 [[ "${label}" == "${wanted}" ]] && return 0
30 while getopts :h OPT; do
41 shift `expr $OPTIND - 1`
44 working_dir="${WORKSPACE:-$(pwd)}"
45 version="${1:-${LARVER}}"
46 qual_set="${2:-${QUAL}}"
47 oIFS=${IFS}; IFS=:; quals=(${qual_set//-/:}); IFS=$oIFS; unset oIFS
48 build_type="${3:-${BUILDTYPE}}"
51 for onequal in "${quals[@]}"; do
52 if [[ "${onequal}" =~ ^([ec])([0-9]+)$ ]]; then
54 elif [[ "${onequal}" =~ ^(s)([1-9][0-9]+)$ ]]; then
61 echo "basequal ${basequal} squal ${squal} labels ${labels}"
71 # create copyBack so artifact copy does not fail on early exit
72 rm -rf "${working_dir}/copyBack"
73 mkdir -p "${working_dir}/copyBack" || exit 1
75 # Find platform flavor.
77 if [ "${OS}" = "Linux" ]
80 if [ "${id}" = "Ubuntu" ]
82 flvr=u`lsb_release -r | sed -e 's/[[:space:]]//g' | cut -f2 -d":" | cut -f1 -d"."`
84 flvr=slf`lsb_release -r | sed -e 's/[[:space:]]//g' | cut -f2 -d":" | cut -f1 -d"."`
86 elif [ "${OS}" = "Darwin" ]
88 flvr=d`uname -r | cut -f1 -d"."`
98 echo "ERROR: unrecognized operating system ${OS}"
102 # Check supported builds.
103 if [[ `uname -s` == Darwin ]]; then
104 OSnum=`uname -r | cut -f1 -d"."`
105 xver=`xcodebuild -version | grep Xcode | cut -f2 -d" " | cut -f1 -d"."`
106 xcver=`xcodebuild -version | grep Xcode`
107 if { [[ ${basequal} =~ ^e(9$|[1-9][0-9]) ]] && \
108 [[ ${xver} < 7 ]] && \
109 [[ ${OSnum} > 13 ]]; }; then
110 # XCode too old on this platform.
111 echo "${basequal} build not supported on `uname -s`${OSnum} with ${xcver}"
112 echo "${basequal} build not supported on `uname -s`${OSnum} with ${xcver}" > \
113 "${working_dir}/copyBack/skipping_build"
115 elif { [[ "$basequal" == e* ]] || \
116 { [[ "$basequal" == c* ]] && (( $OSnum < 15 )); }; }; then
117 if want_unsupported; then
118 echo "Building unsupported ${basequal} on `uname -s`${OSnum} due to \$CET_BUILD_UNSUPPORTED=${CET_BUILD_UNSUPPORTED}"
120 # Don't normally support GCC builds on MacOS.
121 msg="${basequal} build not supported on `uname -s`${OSnum} -- export CET_BUILD_UNSUPPORTED=1 to override."
123 echo "$msg" > "${working_dir}/copyBack/skipping_build"
127 if have_label py2; then
128 msg="We are not building for Python2 on Darwin."
130 echo "${msg}" > "${working_dir}/copyBack/skipping_build"
133 elif [[ "${flvr}" == slf6 ]]; then
134 if have_label py2; then
135 echo "Building for supported Python2 on SLF6"
137 if [[ "$basequal" != e17 ]] && [[ "$basequal" != c2 ]]; then
138 msg="Python3 builds not supported on SLF6."
140 echo "${msg}" > "${working_dir}/copyBack/skipping_build"
146 dotver=`echo ${version} | sed -e 's/_/./g' | sed -e 's/^v//'`
148 echo "building the larsoft distribution for ${version} ${dotver} ${qual_set} ${build_type}"
149 echo "build flavor is ${flvr}"
152 qualdir=`echo ${qual_set} | sed -e 's%:%-%'`
156 blddir=${working_dir}/build
157 srcdir=${working_dir}/source
158 # start with clean directories
161 # now make the dfirectories
162 mkdir -p ${srcdir} || exit 1
163 mkdir -p ${blddir} || exit 1
165 buildFW="${working_dir}/artutilscripts/tools/buildFW"
167 cd ${blddir} || exit 1
169 if [ -z "${buildFW}" ]; then
170 curl --fail --silent --location --insecure -O http://scisoft.fnal.gov/scisoft/bundles/tools/buildFW || exit 1
172 buildFW="${blddir}/buildFW"
175 cd ${blddir} || exit 1
179 (( ${#labels[@]} > 0 )) && lopt=-l
180 ${buildFW} -t -b ${basequal} \
181 ${lopt} $(IFS=:; printf '%s' "${labels[*]}") \
182 ${blddir} ${build_type} lar_product_stack-${version} || \
183 { mv ${blddir}/*.log "${working_dir}/copyBack/"
186 ${buildFW} -t -b ${basequal} -s ${squal} \
187 ${lopt} $(IFS=:; printf '%s' "${labels[*]}") \
188 ${blddir} ${build_type} larbase-${version} || \
189 { mv ${blddir}/*.log "${working_dir}/copyBack/"
192 ${buildFW} -t -b ${basequal} -s ${squal} \
193 ${lopt} $(IFS=:; printf '%s' "${labels[*]}") \
194 ${blddir} ${build_type} larsoft-${version} || \
195 { mv ${blddir}/*.log "${working_dir}/copyBack/"
199 objver=`ls larsoftobj-cfg* | cut -f3 -d"-" | sed -e 's/\./_/g'`
200 ${buildFW} -t -b ${basequal} \
201 ${lopt} $(IFS=:; printf '%s' "${labels[*]}") \
202 ${blddir} ${build_type} larsoftobj-${objver} || \
203 { mv ${blddir}/*.log "${working_dir}/copyBack/"
207 wirever=`grep larwirecell larsoft-cfg-${dotver} | cut -f5 -d" "`
208 wiredotver=`echo ${wirever} | sed -e 's/_/./g' | sed -e 's/^v//'`
210 cfgfile=http://scisoft.fnal.gov/scisoft/bundles/larwire/${wirever}/buildcfg/larwire-cfg-${wiredotver}
211 echo "looking for ${cfgfile}"
212 curl --fail --silent --location --insecure -O ${cfgfile} || have_wirecfg="no"
213 echo "have_wirecfg is ${have_wirecfg}"
214 if [[ ${have_wirecfg} == "yes" ]]; then
215 echo "building larwire ${wirever}"
216 ${buildFW} -t -b ${basequal} -s ${squal} \
217 ${lopt} $(IFS=:; printf '%s' "${labels[*]}") \
218 ${blddir} ${build_type} larwire-${wirever} || \
219 { mv ${blddir}/*.log "${working_dir}/copyBack/"
223 echo "skipping larwire build"
229 # get these out of the way
230 mv ${blddir}/*source* ${srcdir}/
231 mv ${blddir}/g*noarch* ${srcdir}/
232 mv ${blddir}/larsoft_data*.bz2 ${srcdir}/
234 mv ${blddir}/*.bz2 "${working_dir}/copyBack/"
235 mv ${blddir}/*.txt "${working_dir}/copyBack/"