3 #------------------------------------------------------------------
5 # Name: build_larcv_stand_alone.sh
7 # Purpose: Build debug and prof flavors of larcv without 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 "qualifier: $QUAL"
16 echo "build type: $BUILDTYPE"
17 echo "workspace: $WORKSPACE"
19 # Get number of cores to use.
21 if [ `uname` = Darwin ]; then
22 #ncores=`sysctl -n hw.ncpu`
23 #ncores=$(( $ncores / 4 ))
26 ncores=`cat /proc/cpuinfo 2>/dev/null | grep -c -e '^processor'`
28 if [ $ncores -lt 1 ]; then
31 echo "Building using $ncores cores."
33 # Environment setup, uses /grid/fermiapp or cvmfs.
35 if [ -f /grid/fermiapp/products/uboone/setup_uboone.sh ]; then
36 source /grid/fermiapp/products/uboone/setup_uboone.sh || exit 1
37 elif [ -f /cvmfs/uboone.opensciencegrid.org/products/setup_uboone.sh ]; then
38 if [ -x /cvmfs/grid.cern.ch/util/cvmfs-uptodate ]; then
39 /cvmfs/grid.cern.ch/util/cvmfs-uptodate /cvmfs/uboone.opensciencegrid.org/products
41 source /cvmfs/uboone.opensciencegrid.org/products/setup_uboone.sh || exit 1
43 echo "No setup file found."
47 # Use system git on macos.
49 if ! uname | grep -q Darwin; then
53 # Set up working area.
56 rm -rf $WORKSPACE/temp || exit 1
57 mkdir -p $WORKSPACE/temp || exit 1
58 mkdir -p $WORKSPACE/copyBack || exit 1
59 rm -f $WORKSPACE/copyBack/* || exit 1
60 cd $WORKSPACE/temp || exit 1
63 # Check for supported combination of base qualifier and OS.
64 if [[ `uname -s` == Darwin ]] && [[ $QUAL == e* ]]; then
65 echo "${QUAL} build not supported on `uname -s`"
66 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
99 # Set up the correct version of compiler.
101 if [[ $QUAL =~ ^c ]]; then
102 compiler_version=`ups depend -M ${HOME_DIR}/srcs/LArCV/ups -m larcv.table -q ${QUAL}:${BUILDTYPE} larcv | sed -n 's/^.*__\(clang .*\)$/\1/p'`
104 compiler_version=`ups depend -M ${HOME_DIR}/srcs/LArCV/ups -m larcv.table -q ${QUAL}:${BUILDTYPE} larcv | sed -n 's/^.*__\(gcc .*\)$/\1/p'`
106 echo "setup $compiler_version"
107 setup $compiler_version
109 # Set up the correct version of root.
111 root_version=`ups depend -M ${HOME_DIR}/srcs/LArCV/ups -m larcv.table -q ${QUAL}:${BUILDTYPE} larcv | sed -n 's/^.*__\(root .*\)$/\1/p'`
112 echo "setup $root_version"
117 cd ${HOME_DIR}/srcs/LArCV
118 source configure.sh || exit 1
119 if [[ $QUAL =~ ^c ]]; then
120 export LARCV_CXX=clang++
124 echo "LARCV_CXX=$LARCV_CXX"
125 make -j$ncores || exit 1
127 # Assemble larcv ups product.
129 install_dir=${HOME_DIR}/install/larcv/$LARCV_VERSION
130 subdir=`get-directory-name subdir ${QUAL}:${BUILDTYPE}`
131 flavor_dir=${install_dir}/$subdir
134 cp -r ups $install_dir
136 # Declare larcv ups product in temporary products area.
138 if uname | grep -q Darwin; then
139 flavor=`ups flavor -2`
141 flavor=`ups flavor -4`
143 ups declare -z ${HOME_DIR}/install -r larcv/$LARCV_VERSION -m larcv.table -f $flavor -q ${QUAL}:${BUILDTYPE} -U ups larcv $LARCV_VERSION
145 # Make distribution tarball
147 cd ${HOME_DIR}/install
148 dot_version=`echo $LARCV_VERSION | sed -e 's/_/\./g' | sed -e 's/^v//'`
149 subdir=`echo $subdir | sed -e 's/\./-/g'`
150 #qual=`echo $CETPKG_QUAL | sed -e 's/:/-/g'`
151 tarballname=larcv-${dot_version}-${subdir}.tar.bz2
152 echo "Making ${tarballname}"
153 tar cjf ${HOME_DIR}/${tarballname} larcv
157 mv ${HOME_DIR}/*.bz2 $WORKSPACE/copyBack/ || exit 1
158 ls -l $WORKSPACE/copyBack/
159 cd $WORKSPACE || exit 1
160 #rm -rf $WORKSPACE/temp || exit 1