3 #------------------------------------------------------------------
7 # Purpose: Build debug and prof flavors of larcv and larlite on Jenkins.
9 # Created: 4-Aug-2017 H. Greenlee
11 #------------------------------------------------------------------
13 echo "larcv ups version: $LARCV_VERSION"
14 echo "larcv git tag: $LARCV_TAG"
15 echo "larlite ups version: $LARLITE_VERSION"
16 echo "larlite git tag: $LARLITE_TAG"
17 echo "qualifier: $QUAL"
18 echo "build type: $BUILDTYPE"
19 echo "workspace: $WORKSPACE"
21 # Get number of cores to use.
23 if [ `uname` = Darwin ]; then
24 #ncores=`sysctl -n hw.ncpu`
25 #ncores=$(( $ncores / 4 ))
28 ncores=`cat /proc/cpuinfo 2>/dev/null | grep -c -e '^processor'`
30 if [ $ncores -lt 1 ]; then
33 echo "Building using $ncores cores."
35 # Environment setup, uses /grid/fermiapp or cvmfs.
37 if [ -f /grid/fermiapp/products/uboone/setup_uboone.sh ]; then
38 source /grid/fermiapp/products/uboone/setup_uboone.sh || exit 1
39 elif [ -f /cvmfs/uboone.opensciencegrid.org/products/setup_uboone.sh ]; then
40 if [ -x /cvmfs/grid.cern.ch/util/cvmfs-uptodate ]; then
41 /cvmfs/grid.cern.ch/util/cvmfs-uptodate /cvmfs/uboone.opensciencegrid.org/products
43 source /cvmfs/uboone.opensciencegrid.org/products/setup_uboone.sh || exit 1
45 echo "No setup file found."
49 # Use system git on macos.
51 if ! uname | grep -q Darwin; then
55 # Set up working area.
58 rm -rf $WORKSPACE/temp || exit 1
59 mkdir -p $WORKSPACE/temp || exit 1
60 mkdir -p $WORKSPACE/copyBack || exit 1
61 rm -f $WORKSPACE/copyBack/* || exit 1
62 cd $WORKSPACE/temp || exit 1
65 # Check for supported combination of base qualifier and OS.
66 if [[ `uname -s` == Darwin ]] && [[ $QUAL == e* ]]; then
67 echo "${QUAL} build not supported on `uname -s`"
68 echo "${QUAL} build not supported on `uname -s`" > $WORKSPACE/copyBack/skipping_build
74 # Make an installation directory with relocatable dbconfig file.
76 mkdir -p ${HOME_DIR}/install/.upsfiles
77 cat <<EOF > ${HOME_DIR}/install/.upsfiles/dbconfig
81 PROD_DIR_PREFIX = \${UPS_THIS_DB}
82 UPD_USERCODE_DIR = \${UPS_THIS_DB}/.updfiles
85 # Make source area and check out sources.
87 mkdir -p ${HOME_DIR}/srcs
92 git clone https://github.com/LArbys/LArCV
93 #git clone https://github.com/hgreenlee/LArCV
95 git checkout $LARCV_TAG
101 git clone https://github.com/larlight/larlite
102 #git clone https://github.com/hgreenlee/larlite
104 git checkout $LARLITE_TAG
108 # Set up the correct version of gcc.
110 gcc_version=`ups depend -M ${HOME_DIR}/srcs/LArCV/ups -m larcv.table -q ${QUAL}:${BUILDTYPE} larcv | sed -n 's/^.*__\(gcc .*\)$/\1/p'`
111 gcc_version2=`ups depend -M ${HOME_DIR}/srcs/larlite/ups -m larlite.table -q ${QUAL}:${BUILDTYPE} larlite | sed -n 's/^.*__\(gcc .*\)$/\1/p'`
112 if [ "$gcc_version" != "$gcc_version2" ]; then
113 echo "Gcc versions do not match."
120 # Set up the correct version of root.
122 root_version=`ups depend -M ${HOME_DIR}/srcs/LArCV/ups -m larcv.table -q ${QUAL}:${BUILDTYPE} larcv | sed -n 's/^.*__\(root .*\)$/\1/p'`
123 root_version2=`ups depend -M ${HOME_DIR}/srcs/larlite/ups -m larlite.table -q ${QUAL}:${BUILDTYPE} larlite | sed -n 's/^.*__\(root .*\)$/\1/p'`
124 if [ "$root_version" != "$root_version2" ]; then
125 echo "Root versions do not match."
132 # Build larlite first.
134 cd ${HOME_DIR}/srcs/larlite
135 source config/setup.sh || exit 1
136 export LARLITE_CXX=g++ # Use g++ instead of clang.
137 make -j$ncores || exit 1
139 # Assemble larlite ups product.
141 install_dir=${HOME_DIR}/install/larlite/$LARLITE_VERSION
142 subdir=`get-directory-name subdir ${QUAL}:${BUILDTYPE}`
143 flavor_dir=${install_dir}/$subdir
146 cp -r ups $install_dir
148 # Declare larlite ups product in temporary products area.
150 if uname | grep -q Darwin; then
151 flavor=`ups flavor -2`
153 flavor=`ups flavor -4`
155 ups declare -z ${HOME_DIR}/install -r larlite/$LARLITE_VERSION -m larlite.table -f $flavor -q ${QUAL}:${BUILDTYPE} -U ups larlite $LARLITE_VERSION
157 # Make distribution tarball
159 cd ${HOME_DIR}/install
160 dot_version=`echo $LARLITE_VERSION | sed -e 's/_/\./g' | sed -e 's/^v//'`
161 subdir=`echo $subdir | sed -e 's/\./-/g'`
162 #qual=`echo $CETPKG_QUAL | sed -e 's/:/-/g'`
163 tarballname=larlite-${dot_version}-${subdir}.tar.bz2
164 echo "Making ${tarballname}"
165 tar cjf ${HOME_DIR}/${tarballname} larlite
169 cd ${HOME_DIR}/srcs/LArCV
170 source configure.sh || exit 1
171 export LARCV_CXX=g++ # Use g++ instead of clang.
172 make -j$ncores || exit 1
174 # Assemble larcv ups product.
176 install_dir=${HOME_DIR}/install/larcv/$LARCV_VERSION
177 subdir=`get-directory-name subdir ${QUAL}:${BUILDTYPE}`
178 flavor_dir=${install_dir}/$subdir
181 cp -r ups $install_dir
183 # Declare larcv ups product in temporary products area.
185 if uname | grep -q Darwin; then
186 flavor=`ups flavor -2`
188 flavor=`ups flavor -4`
190 ups declare -z ${HOME_DIR}/install -r larcv/$LARCV_VERSION -m larcv.table -f $flavor -q ${QUAL}:${BUILDTYPE} -U ups larcv $LARCV_VERSION
192 # Make distribution tarball
194 cd ${HOME_DIR}/install
195 dot_version=`echo $LARCV_VERSION | sed -e 's/_/\./g' | sed -e 's/^v//'`
196 subdir=`echo $subdir | sed -e 's/\./-/g'`
197 #qual=`echo $CETPKG_QUAL | sed -e 's/:/-/g'`
198 tarballname=larcv-${dot_version}-${subdir}.tar.bz2
199 echo "Making ${tarballname}"
200 tar cjf ${HOME_DIR}/${tarballname} larcv
204 mv ${HOME_DIR}/*.bz2 $WORKSPACE/copyBack/ || exit 1
205 ls -l $WORKSPACE/copyBack/
206 cd $WORKSPACE || exit 1
207 #rm -rf $WORKSPACE/temp || exit 1