3 #------------------------------------------------------------------
5 # Name: build_larlite.sh
7 # Purpose: Build debug and prof flavors of larlite on Jenkins.
9 # Created: 4-Aug-2017 H. Greenlee
11 #------------------------------------------------------------------
13 echo "larlite ups version: $UPS_VERSION"
14 echo "larlite git tag: $GIT_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
61 export LARLITE_HOME_DIR=`pwd`
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
72 # Make source area and check out sources.
76 git clone https://github.com/larlight/larlite
77 #git clone https://github.com/hgreenlee/larlite
82 # Set up the correct version of compiler.
84 if [[ $QUAL =~ ^c ]]; then
85 compiler_version=`ups depend -M ups -m larlite.table -q ${QUAL}:${BUILDTYPE} larlite | sed -n 's/^.*__\(clang .*\)$/\1/p'`
87 compiler_version=`ups depend -M ups -m larlite.table -q ${QUAL}:${BUILDTYPE} larlite | sed -n 's/^.*__\(gcc .*\)$/\1/p'`
89 setup $compiler_version
91 # Set up the correct dependent root version.
93 root_version=`ups depend -M ups -m larlite.table -q ${QUAL}:${BUILDTYPE} larlite | sed -n 's/^.*__\(root .*\)$/\1/p'`
96 # Do post-checkout initialization.
98 source config/setup.sh || exit 1
99 if [[ $QUAL =~ ^c ]]; then
100 export LARLITE_CXX=clang++
102 export LARLITE_CXX=g++
107 make -j$ncores || exit 1
109 # Assemble ups product.
111 install_dir=${LARLITE_HOME_DIR}/install/larlite/$UPS_VERSION
112 subdir=`get-directory-name subdir ${QUAL}:${BUILDTYPE}`
113 flavor_dir=${install_dir}/$subdir
116 cp -r ups $install_dir
118 # Make a dbconfig file.
120 mkdir ${LARLITE_HOME_DIR}/install/.upsfiles
121 cat <<EOF > ${LARLITE_HOME_DIR}/install/.upsfiles/dbconfig
125 PROD_DIR_PREFIX = \${UPS_THIS_DB}
126 UPD_USERCODE_DIR = \${UPS_THIS_DB}/.updfiles
129 # Declare ups product in temporary products area.
131 if uname | grep -q Darwin; then
132 flavor=`ups flavor -2`
134 flavor=`ups flavor -4`
136 ups declare -z ${LARLITE_HOME_DIR}/install -r larlite/$UPS_VERSION -m larlite.table -f $flavor -q ${QUAL}:${BUILDTYPE} -U ups larlite $UPS_VERSION
138 # Make distribution tarball
140 cd ${LARLITE_HOME_DIR}/install
141 dot_version=`echo $UPS_VERSION | sed -e 's/_/\./g' | sed -e 's/^v//'`
142 subdir=`echo $subdir | sed -e 's/\./-/g'`
143 #qual=`echo $CETPKG_QUAL | sed -e 's/:/-/g'`
144 tarballname=larlite-${dot_version}-${subdir}.tar.bz2
145 echo "Making ${tarballname}"
146 tar cjf ${LARLITE_HOME_DIR}/${tarballname} larlite
150 mv ${LARLITE_HOME_DIR}/${tarballname} $WORKSPACE/copyBack/ || exit 1
151 ls -l $WORKSPACE/copyBack/
152 cd $WORKSPACE || exit 1
153 #rm -rf $WORKSPACE/temp || exit 1