5 # EDEPSIMVERSION -- matches tag name in Clark McGrew's github
6 # VERSIONSUFFIX -- to append to the github tag to make our tag
7 # QUAL -- compiler, e.g. e17, e19, e20, c2, c7
8 # BUILDTYPE -- debug or prof
9 # GEANT4VERSION -- tag for setting up GEANT4
10 # ROOTVERSION -- tag for setting up ROOT
11 # WORKSPACE -- from Jenkins
12 # COMPILERQUAL_LIST -- list of all the compiler qualifiers (space separated)
13 # EXTRAROOTQUALIFIERS -- to fully specify ROOT. Needs a colon at the beginning so it can be
14 # added to an existing qualifier string. e.g. ":p383"
18 # designed to work on Jenkins
20 # for checking out from Clark McGrew's github repo
22 echo "edep-sim github version: $EDEPSIMVERSION"
24 echo "version suffix: $VERSIONSUFFIX"
26 echo "GEANT4 version: $GEANT4VERSION"
28 echo "ROOT version: $ROOTVERSION"
30 # -- the base qualifier is only the compiler version qualifier: e.g. "e15"
32 echo "base qualifiers (compiler): $QUAL"
34 echo "extra root qualifiers: $EXTRAROOTQUALFIERS"
35 echo "these need a colon before but not after"
37 # note -- this script knows about the correspondence between compiler qualifiers and compiler versions.
38 # there is another if-block later on with the same information (apologies for the duplication). If a new compiler
39 # version is added here, it must also be added where CV is set.
42 COMPILERCOMMAND=unknown
44 if [ $QUAL = e14 ]; then
45 COMPILERVERS="gcc v6_3_0"
48 elif [ $QUAL = e15 ]; then
49 COMPILERVERS="gcc v6_4_0"
52 elif [ $QUAL = e17 ]; then
53 COMPILERVERS="gcc v7_3_0"
56 elif [ $QUAL = c2 ]; then
57 COMPILERVERS="clang v5_0_1"
58 COMPILERCOMMAND=clang++
60 elif [ $QUAL = e19 ]; then
61 COMPILERVERS="gcc v8_2_0"
64 elif [ $QUAL = e20 ]; then
65 COMPILERVERS="gcc v9_3_0"
68 elif [ $QUAL = c7 ]; then
69 COMPILERVERS="clang v7_0_0"
70 COMPILERCOMMAND=clang++
74 echo "Compiler and version string: " $COMPILERVERS
75 echo "C++ Compiler command: " $COMPILERCOMMAND
76 echo "C Compiler command: " $CCOMPILER
78 echo "COMPILERQUAL_LIST: " $COMPILERQUAL_LIST
80 if [ "$COMPILERVERS" = unknown ]; then
81 echo "unknown compiler flag: $QUAL"
87 echo "build type: $BUILDTYPE"
88 echo "workspace: $WORKSPACE"
90 # Environment setup; look in CVMFS first
92 if [ -f /cvmfs/dune.opensciencegrid.org/products/dune/setup_dune.sh ]; then
93 source /cvmfs/dune.opensciencegrid.org/products/dune/setup_dune.sh || exit 1
94 elif [ -f /grid/fermiapp/products/dune/setup_dune_fermiapp.sh ]; then
95 source /grid/fermiapp/products/dune/setup_dune_fermiapp.sh || exit 1
97 echo "No setup file found."
101 setup -B cetbuildtools v7_15_01 || exit 1
102 setup -B root ${ROOTVERSION} -q ${QUAL}${EXTRAROOTQUALIFIERS}:${BUILDTYPE} || exit 1
103 setup -B geant4 ${GEANT4VERSION} -q ${QUAL}:${BUILDTYPE} || exit 1
105 # Use system git on macos, and the one in ups for linux
107 if ! uname | grep -q Darwin; then
111 rm -rf $WORKSPACE/temp || exit 1
112 mkdir -p $WORKSPACE/temp || exit 1
113 mkdir -p $WORKSPACE/copyBack || exit 1
114 rm -f $WORKSPACE/copyBack/* || exit 1
115 cd $WORKSPACE/temp || exit 1
118 # change all dots to underscores, and capital V's to little v's in the version string
119 # add our own suffix as the compiler version moves more rapidly than the product version
121 VERSION=v`echo ${EDEPSIMVERSION} | sed -e "s/\./_/g"`${VERSIONSUFFIX}
124 FLAVOR=`ups flavor -4`
125 if [ `uname` = Darwin ]; then
126 FLAVOR=`ups flavor -2`
130 touch ${PRODUCT_NAME} || exit 1
131 rm -rf ${PRODUCT_NAME} || exit 1
132 touch inputdir || exit 1
133 rm -rf inputdir || exit 1
134 mkdir -p ${PRODUCT_NAME}/${VERSION}/source || exit 1
135 mkdir ${PRODUCT_NAME}/${VERSION}/include || exit 1
136 mkdir ${PRODUCT_NAME}/${VERSION}/ups || exit 1
137 mkdir ${PRODUCT_NAME}/${VERSION}/share || exit 1
139 # in the table, add ROOT and GEANT4 required setups
141 TABLEFILENAME=${PRODUCT_NAME}/${VERSION}/ups/${PRODUCT_NAME}.table
142 touch ${TABLEFILENAME} || exit 1
143 rm -f ${TABLEFILENAME} || exit 1
144 cat > ${TABLEFILENAME} <<EOF
148 #*************************************************
149 # Starting Group definition
154 for CQ in $COMPILERQUAL_LIST; do
155 touch tablefrag.txt || exit 1
156 rm -f tablefrag.txt || exit 1
157 cat > tablefrag.txt <<'EOF'
160 Qualifiers=QUALIFIER_REPLACE_STRING:debug
163 envSet (EDEPSIM_FQ_DIR, ${UPS_PROD_DIR}/${UPS_PROD_FLAVOR}-QUALIFIER_REPLACE_STRING-debug)
166 setupRequired( COMPILERVERS_REPLACE_STRING )
167 setupRequired( geant4 GEANT4VERS_REPLACE_STRING -q QUALIFIER_REPLACE_STRING:debug )
168 setupRequired( root ROOTVERS_REPLACE_STRING -q QUALIFIER_REPLACE_STRINGROOTEXTRAQUALS_RS:debug )
171 Qualifiers=QUALIFIER_REPLACE_STRING:prof
174 envSet (EDEPSIM_FQ_DIR, ${UPS_PROD_DIR}/${UPS_PROD_FLAVOR}-QUALIFIER_REPLACE_STRING-prof)
177 setupRequired( COMPILERVERS_REPLACE_STRING )
178 setupRequired( geant4 GEANT4VERS_REPLACE_STRING -q QUALIFIER_REPLACE_STRING:prof )
179 setupRequired( root ROOTVERS_REPLACE_STRING -q QUALIFIER_REPLACE_STRINGROOTEXTRAQUALS_RS:prof )
184 if [ $CQ = e14 ]; then
186 elif [ $CQ = e15 ]; then
188 elif [ $CQ = e17 ]; then
190 elif [ $CQ = c2 ]; then
192 elif [ $CQ = e19 ]; then
194 elif [ $CQ = e20 ]; then
196 elif [ $CQ = c7 ]; then
199 if [ "$CV" = unknown ]; then
200 echo "unknown compiler flag in COMPILERQUAL_LIST : $CQ"
204 sed -e "s/QUALIFIER_REPLACE_STRING/${CQ}/g" < tablefrag.txt \
205 | sed -e "s/COMPILERVERS_REPLACE_STRING/${CV}/g" \
206 | sed -e "s/GEANT4VERS_REPLACE_STRING/${GEANT4VERSION}/g" \
207 | sed -e "s/ROOTVERS_REPLACE_STRING/${ROOTVERSION}/g" \
208 | sed -e "s/ROOTEXTRAQUALS_RS/${EXTRAROOTQUALIFIERS}/g" \
209 >> ${TABLEFILENAME} || exit 1
210 rm -f tablefrag.txt || exit 1
214 cat >> ${TABLEFILENAME} <<'EOF'
219 ExeActionRequired(DefineFQ)
220 envSet(EDEPSIM_DIR, ${UPS_PROD_DIR})
221 envSet(EDEPSIM_ROOT, ${UPS_PROD_DIR})
222 envSet(EDEPSIM_VERSION, ${UPS_PROD_VERSION})
223 envSet(EDEPSIM_INC, ${EDEPSIM_DIR}/include)
224 envSet(EDEPSIM_SHARE, ${EDEPSIM_DIR}/share)
225 envSet(EDEPSIM_LIB, ${EDEPSIM_FQ_DIR}/lib)
226 # add the lib directory to LD_LIBRARY_PATH
227 if ( test `uname` = "Darwin" )
228 envPrepend(DYLD_LIBRARY_PATH, ${EDEPSIM_FQ_DIR}/lib)
230 envPrepend(LD_LIBRARY_PATH, ${EDEPSIM_FQ_DIR}/lib)
231 endif ( test `uname` = "Darwin" )
232 # add the bin directory to the path if it exists
233 if ( sh -c 'for dd in bin;do [ -d ${EDEPSIM_FQ_DIR}/$dd ] && exit;done;exit 1' )
234 pathPrepend(PATH, ${EDEPSIM_FQ_DIR}/bin )
236 execute( true, NO_UPS_ENV )
237 endif ( sh -c 'for dd in bin;do [ -d ${EDEPSIM_FQ_DIR}/$dd ] && exit;done;exit 1' )
239 pathPrepend(ROOT_INCLUDE_PATH, ${EDEPSIM_DIR}/include/EDepSim )
240 # envPrepend(CMAKE_PREFIX_PATH, ${EDEPSIM_DIR} ) figure out what to do here
241 # envPrepend(PKG_CONFIG_PATH, ${EDEPSIM_DIR} )
243 exeActionRequired(ExtraSetup)
245 # End Group definition
246 #*************************************************
250 mkdir installdir || exit 1
251 mkdir builddir || exit 1
252 mkdir inputdir || exit 1
254 git clone https://github.com/DUNE/edep-sim.git || exit 1
255 cd edep-sim || exit 1
256 git checkout tags/${EDEPSIMVERSION} || exit 1
258 # copy all the source to the install directory
260 cp -R -L * ${CURDIR}/${PRODUCT_NAME}/${VERSION}/source || exit 1
262 DIRNAME=${CURDIR}/${PRODUCT_NAME}/${VERSION}/${FLAVOR}-${QUAL}-${BUILDTYPE}
263 mkdir -p ${DIRNAME} || exit 1
264 rm -rf ${DIRNAME}/* || exit 1
265 mkdir ${DIRNAME}/bin || exit 1
266 mkdir ${DIRNAME}/lib || exit 1
267 mkdir ${DIRNAME}/share || exit 1
268 mkdir ${DIRNAME}/include || exit 1
270 cd ${CURDIR}/builddir
273 if [ $BUILDTYPE = "debug" ]; then
276 echo "Compiler flags: " $CFLAGS
278 cmake -DCMAKE_C_COMPILER=${CCOMPILER} -DCMAKE_C_FLAGS=${CFLAGS} -DCMAKE_CXX_COMPILER=${COMPILERCOMMAND} -DCMAKE_CXX_FLAGS=${CFLAGS} -DCMAKE_INSTALL_PREFIX=${CURDIR}/installdir ${CURDIR}/inputdir/edep-sim
282 make install || exit 1
284 cd ${CURDIR} || exit 1
285 cp -r installdir/lib/* ${DIRNAME}/lib
286 cp -r installdir/bin/* ${DIRNAME}/bin
287 cp -r installdir/share/* ${DIRNAME}/../share
288 cp -r installdir/include/* ${DIRNAME}/../include
289 # duplicate in the flavored versions in case cmake files assume include is flavored.
290 cp -r installdir/share/* ${DIRNAME}/share
291 cp -r installdir/include/* ${DIRNAME}/include
293 # for testing the tarball, remove so we keep .upsfiles as is when
294 # unwinding into a real products area
296 mkdir .upsfiles || exit 1
297 cat <<EOF > .upsfiles/dbconfig
301 PROD_DIR_PREFIX = \${UPS_THIS_DB}
302 UPD_USERCODE_DIR = \${UPS_THIS_DB}/.updfiles
305 ups declare ${PRODUCT_NAME} ${VERSION} -f ${FLAVOR} -m ${PRODUCT_NAME}.table -z `pwd` -r ./${PRODUCT_NAME}/${VERSION} -q ${BUILDTYPE}:${QUAL}:${SIMDQUALIFIER} || exit 1
307 rm -rf .upsfiles || exit 1
310 rm -rf ${CURDIR}/inputdir || exit 1
312 cd ${CURDIR} || exit 1
316 VERSIONDOTS=`echo ${VERSION} | sed -e "s/_/./g"`
317 SUBDIR=`get-directory-name subdir | sed -e "s/\./-/g"`
319 # use SUBDIR instead of FLAVOR
321 FULLNAME=${PRODUCT_NAME}-${VERSIONDOTS}-${SUBDIR}-${QUAL}-${BUILDTYPE}
323 # strip off the first "v" in the version number
325 FULLNAMESTRIPPED=`echo $FULLNAME | sed -e "s/${PRODUCT_NAME}-v/${PRODUCT_NAME}-/"`
327 rm -rf installdir || exit 1
328 rm -rf builddir || exit 1
330 tar -cjf $WORKSPACE/copyBack/${FULLNAMESTRIPPED}.tar.bz2 . || exit 1
332 ls -l $WORKSPACE/copyBack/
333 cd $WORKSPACE || exit 1
334 rm -rf $WORKSPACE/temp || exit 1