All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
build-larsoft-dbg-prof.sh
Go to the documentation of this file.
1 #!/bin/bash
2 
3 # pull source code in ${working_dir}/source
4 # build in ${working_dir}/build
5 # copyback directory is ${working_dir}/copyBack
6 
8 {
9  cat 1>&2 <<EOF
10 Usage: $(basename ${0}) [-h]
11  env WORKSPACE=<workspace> LARVER=<larsoft version> QUAL=<qualifier> $(basename ${0})
12 
13 Options:
14 
15  -h This help.
16 
17 EOF
18 }
19 
21  for label in "${labels[@]}"; do
22  for wanted in "$@"; do
23  [[ "${label}" == "${wanted}" ]] && return 0
24  done
25  done
26  return 1
27 }
28 
29 
30 while getopts :h OPT; do
31  case ${OPT} in
32  h)
33  usage
34  exit 1
35  ;;
36  *)
37  usage
38  exit 1
39  esac
40 done
41 shift `expr $OPTIND - 1`
43 
44 working_dir="${WORKSPACE:-$(pwd)}"
45 version="${1:-${LARVER}}"
46 #objver=${LAROBJ}
47 qual_set="${2:-${QUAL}}"
48 oIFS=${IFS}; IFS=:; quals=(${qual_set//-/:}); IFS=$oIFS; unset oIFS
49 #build_type="${3:-${BUILDTYPE}}"
50 
51 labels=()
52 for onequal in "${quals[@]}"; do
53  if [[ "${onequal}" =~ ^([ec])([0-9]+)$ ]]; then
54  basequal=${onequal}
55  elif [[ "${onequal}" =~ ^(s)([1-9][0-9]+)$ ]]; then
56  squal=${onequal}
57  else
58  labels+=${onequal}
59  fi
60 done
61 
62 # create copyBack so artifact copy does not fail on early exit
63 rm -rf "${working_dir}/copyBack"
64 mkdir -p "${working_dir}/copyBack" || exit 1
65 
66 # Find platform flavor.
67 OS=`uname`
68 if [ "${OS}" = "Linux" ]
69 then
70  id=`lsb_release -is`
71  if [ "${id}" = "Ubuntu" ]
72  then
73  flvr=u`lsb_release -r | sed -e 's/[[:space:]]//g' | cut -f2 -d":" | cut -f1 -d"."`
74  else
75  flvr=slf`lsb_release -r | sed -e 's/[[:space:]]//g' | cut -f2 -d":" | cut -f1 -d"."`
76  fi
77 elif [ "${OS}" = "Darwin" ]
78 then
79  flvr=d`uname -r | cut -f1 -d"."`
80  # set locale
81  echo
82  locale
83  echo
84  export LANG=C
85  export LC_ALL=$LANG
86  locale
87  echo
88 else
89  echo "ERROR: unrecognized operating system ${OS}"
90  exit 1
91 fi
92 
93 # Check supported builds.
94 if [[ `uname -s` == Darwin ]]; then
95  OSnum=`uname -r | cut -f1 -d"."`
96  xver=`xcodebuild -version | grep Xcode | cut -f2 -d" " | cut -f1 -d"."`
97  xcver=`xcodebuild -version | grep Xcode`
98  if { [[ ${basequal} =~ ^e(9$|[1-9][0-9]) ]] && \
99  [[ ${xver} < 7 ]] && \
100  [[ ${OSnum} > 13 ]]; }; then
101  # XCode too old on this platform.
102  echo "${basequal} build not supported on `uname -s`${OSnum} with ${xcver}"
103  echo "${basequal} build not supported on `uname -s`${OSnum} with ${xcver}" > \
104  "${working_dir}/copyBack/skipping_build"
105  exit 0
106  elif { [[ "$basequal" == e* ]] || \
107  { [[ "$basequal" == c* ]] && (( $OSnum < 15 )); }; }; then
108  if want_unsupported; then
109  echo "Building unsupported ${basequal} on `uname -s`${OSnum} due to \$CET_BUILD_UNSUPPORTED=${CET_BUILD_UNSUPPORTED}"
110  else
111  # Don't normally support GCC builds on MacOS.
112  msg="${basequal} build not supported on `uname -s`${OSnum} -- export CET_BUILD_UNSUPPORTED=1 to override."
113  echo "$msg"
114  echo "$msg" > "${working_dir}/copyBack/skipping_build"
115  exit 0
116  fi
117  fi
118  if have_label py2; then
119  msg="We are not building for Python2 on Darwin."
120  echo "${msg}"
121  echo "${msg}" > "${working_dir}/copyBack/skipping_build"
122  exit 0
123  fi
124 elif [[ "${flvr}" == slf6 ]]; then
125  if have_label py2; then
126  echo "Building for supported Python2 on SLF6"
127  else
128  msg="Python3 builds not supported on SLF6."
129  echo "${msg}"
130  echo "${msg}" > "${working_dir}/copyBack/skipping_build"
131  exit 0
132  fi
133 fi
134 
135 dotver=`echo ${version} | sed -e 's/_/./g' | sed -e 's/^v//'`
136 
137 echo "building the larsoft distribution for ${version} ${dotver} ${qual_set}"
138 echo "build flavor is ${flvr}"
139 echo ""
140 
141 qualdir=`echo ${qual_set} | sed -e 's%:%-%'`
142 
143 set -x
144 
145 blddir=${working_dir}/build
146 srcdir=${working_dir}/source
147 # start with clean directories
148 rm -rf ${blddir}
149 rm -rf ${srcdir}
150 # now make the dfirectories
151 mkdir -p ${srcdir} || exit 1
152 mkdir -p ${blddir} || exit 1
153 
154 cd ${blddir} || exit 1
155 curl --fail --silent --location --insecure -O http://scisoft.fnal.gov/scisoft/bundles/tools/buildFW || exit 1
156 chmod +x buildFW
157 
158 cd ${blddir} || exit 1
159 echo
160 echo "begin build"
161 echo
162 for build_type in prof debug
163 do
164 (( ${#labels[@]} > 0 )) && lopt=-l
165 ./buildFW -t -b ${basequal} \
166  ${lopt} $(IFS=:; printf '%s' "${labels[*]}") \
167  ${blddir} ${build_type} lar_product_stack-${version} || \
168  { mv ${blddir}/*.log "${working_dir}/copyBack/"
169  exit 1
170  }
171 ./buildFW -t -b ${basequal} -s ${squal} \
172  ${lopt} $(IFS=:; printf '%s' "${labels[*]}") \
173  ${blddir} ${build_type} larbase-${version} || \
174  { mv ${blddir}/*.log "${working_dir}/copyBack/"
175  exit 1
176  }
177 ./buildFW -t -b ${basequal} -s ${squal} \
178  ${lopt} $(IFS=:; printf '%s' "${labels[*]}") \
179  ${blddir} ${build_type} larsoft-${version} || \
180  { mv ${blddir}/*.log "${working_dir}/copyBack/"
181  exit 1
182  }
183 objver=`ls larsoftobj-cfg* | cut -f3 -d"-" | sed -e 's/\./_/g'`
184 ./buildFW -t -b ${basequal} \
185  ${lopt} $(IFS=:; printf '%s' "${labels[*]}") \
186  ${blddir} ${build_type} larsoftobj-${objver} || \
187  { mv ${blddir}/*.log "${working_dir}/copyBack/"
188  exit 1
189  }
190 done
191 
192 echo
193 echo "move files"
194 echo
195 # get these out of the way
196 mv ${blddir}/*source* ${srcdir}/
197 mv ${blddir}/g*noarch* ${srcdir}/
198 mv ${blddir}/larsoft_data*.bz2 ${srcdir}/
199 #
200 mv ${blddir}/*.bz2 "${working_dir}/copyBack/"
201 mv ${blddir}/*.txt "${working_dir}/copyBack/"
202 rm -rf ${srcdir}
203 rm -rf ${blddir}
204 
205 exit 0
* labels
*usage exit esac done shift expr $OPTIND OPTIND
process_name opflash particleana ie x
then cvmfs grid cern ch util cvmfs uptodate cvmfs uboone opensciencegrid org products fi source cvmfs uboone opensciencegrid org products setup_uboone sh exit else echo No setup file found exit fi if!uname grep q Darwin
Definition: build_larcv.sh:51
do source
pdgs p
Definition: selectors.fcl:22
then source cvmfs dune opensciencegrid org products dune setup_dune sh exit elif[-f/grid/fermiapp/products/dune/setup_dune_fermiapp.sh]
have_label()
shift
Definition: fcl_checks.sh:26
usage
Definition: doGit.sh:21
then flvr
Definition: buildSBND.sh:128
while getopts
while getopts h
then OS
then shift fi
do cd
then basequal
Definition: buildUboone2.sh:26
do case in h help echo Usage
Definition: file_to_url.sh:42
then QUAL
if &&[-z"$BASH_VERSION"] then echo Attempting to switch to bash bash shellSwitch exit fi &&["$1"= 'shellSwitch'] shift declare a IncludeDirectives for Dir in
then echo File list $list not found else cat $list while read file do echo $file sed s
Definition: file_to_url.sh:60
do i e
s7[0-9] s8[0-9] s9[0-9] squal
esac echo uname r