3 # build "third party" products
     8 Usage: $(basename ${0}) [-h]
     9        $(basename ${0}) <version> <qual_set> <build_type>
    10        env WORKSPACE=<workspace> LARVER=<larsoft version> QUAL=<qualifier> BUILDTYPE=<debug|prof> $(basename ${0})
    20   for label in "${labels[@]}"; do
    21     for wanted in "$@"; do
    22       [[ "${label}" == "${wanted}" ]] && return 0
    29 while getopts :h OPT; do
    40 shift `expr $OPTIND - 1`
    43 working_dir="${WORKSPACE:-$(pwd)}"
    44 version="${1:-${LARVER}}"
    45 qual_set="${2:-${QUAL}}"
    46 oIFS=${IFS}; IFS=:; quals=(${qual_set//-/:}); IFS=$oIFS; unset oIFS
    47 build_type="${3:-${BUILDTYPE}}"
    50 for onequal in "${quals[@]}"; do
    51   if [[ "${onequal}" =~ ^([ec])([0-9]+)$ ]]; then
    53   elif [[ "${onequal}" =~ ^(s)([1-9][0-9]+)$ ]]; then
    68 # create copyBack so artifact copy does not fail on early exit
    69 rm -rf "${working_dir}/copyBack"
    70 mkdir -p "${working_dir}/copyBack" || exit 1
    72 # Find platform flavor.
    74 if [ "${OS}" = "Linux" ]
    77   if [ "${id}" = "Ubuntu" ]
    79     flvr=u`lsb_release -r | sed -e 's/[[:space:]]//g' | cut -f2 -d":" | cut -f1 -d"."`
    81     flvr=slf`lsb_release -r | sed -e 's/[[:space:]]//g' | cut -f2 -d":" | cut -f1 -d"."`
    83 elif [ "${OS}" = "Darwin" ]
    85   flvr=d`uname -r | cut -f1 -d"."`
    95   echo "ERROR: unrecognized operating system ${OS}"
    99 # Check supported builds.
   100 if [[ `uname -s` == Darwin ]]; then
   101   OSnum=`uname -r | cut -f1 -d"."`
   102   xver=`xcodebuild -version | grep Xcode | cut -f2 -d" " | cut -f1 -d"."`
   103   xcver=`xcodebuild -version | grep Xcode`
   104   if { [[ ${basequal} =~ ^e(9$|[1-9][0-9]) ]] && \
   105     [[ ${xver} < 7 ]] && \
   106     [[ ${OSnum} > 13 ]]; }; then
   107     # XCode too old on this platform.
   108     echo "${basequal} build not supported on `uname -s`${OSnum} with ${xcver}"
   109     echo "${basequal} build not supported on `uname -s`${OSnum} with ${xcver}" > \
   110       "${working_dir}/copyBack/skipping_build"
   112   elif { [[ "$basequal" == e* ]] || \
   113     { [[ "$basequal" == c* ]] && (( $OSnum < 15 )); }; }; then
   114     if want_unsupported; then
   115       echo "Building unsupported ${basequal} on `uname -s`${OSnum} due to \$CET_BUILD_UNSUPPORTED=${CET_BUILD_UNSUPPORTED}"
   117       # Don't normally support GCC builds on MacOS.
   118       msg="${basequal} build not supported on `uname -s`${OSnum} -- export CET_BUILD_UNSUPPORTED=1 to override."
   120       echo "$msg" > "${working_dir}/copyBack/skipping_build"
   124   if have_label py2; then
   125     msg="We are not building for Python2 on Darwin."
   127     echo "${msg}" > "${working_dir}/copyBack/skipping_build"
   130 elif [[ "${flvr}" == slf6 ]]; then
   131   if have_label py2; then
   132     echo "Building for supported Python2 on SLF6"
   134     msg="Python3 builds not supported on SLF6."
   136     echo "${msg}" > "${working_dir}/copyBack/skipping_build"
   141 dotver=`echo ${version} | sed -e 's/_/./g' | sed -e 's/^v//'`
   143 echo "building the larsoft product stack for ${version} ${dotver} ${qual_set} ${build_type}"
   144 echo "build flavor is ${flvr}"
   147 qualdir=`echo ${qual_set} | sed -e 's%:%-%'`
   151 blddir=${working_dir}/build
   152 srcdir=${working_dir}/source
   153 # start with clean directories
   156 # now make the dfirectories
   157 mkdir -p ${srcdir} || exit 1
   158 mkdir -p ${blddir} || exit 1
   160 buildFW="${working_dir}/artutilscripts/tools/buildFW"
   162 cd ${blddir} || exit 1
   164 if [ -z "${buildFW}" ]; then
   165   curl --fail --silent --location --insecure -O http://scisoft.fnal.gov/scisoft/bundles/tools/buildFW || exit 1
   167   buildFW="${blddir}/buildFW"
   170 cd ${blddir} || exit 1
   174 (( ${#labels[@]} > 0 )) && lopt=-l
   175 ${buildFW} -t -b ${basequal} \
   176   ${lopt} $(IFS=:; printf '%s' "${labels[*]}") \
   177   ${blddir} ${build_type} lar_product_stack-${version} || \
   178  { mv ${blddir}/*.log  "${working_dir}/copyBack/"
   185 mv ${blddir}/*source* ${srcdir}/
   186 mv ${blddir}/g*noarch* ${srcdir}/
   187 mv ${blddir}/*.bz2  $WORKSPACE/copyBack/
   188 mv ${blddir}/*.txt  $WORKSPACE/copyBack/