5 PRODUCT_NAME=dunepdsprce
7 # designed to work on Jenkins
9 # for checking out from JJ's github repo
11 echo "dunepdsprce JJ github: $JJVERSION"
13 # -- the base qualifier is only the compiler version qualifier: e.g. "e15"
15 echo "base qualifiers: $QUAL"
17 # note -- this script knows about the correspondence between compiler qualifiers and compiler versions.
18 # there is another if-block later on with the same information (apologies for the duplication). If a new compiler
19 # version is added here, it must also be added where CV is set.
22 COMPILERCOMMAND=unknown
23 if [ $QUAL = e14 ]; then
24 COMPILERVERS="gcc v6_3_0"
26 elif [ $QUAL = e15 ]; then
27 COMPILERVERS="gcc v6_4_0"
29 elif [ $QUAL = e17 ]; then
30 COMPILERVERS="gcc v7_3_0"
32 elif [ $QUAL = c2 ]; then
33 COMPILERVERS="clang v5_0_1"
34 COMPILERCOMMAND=clang++
35 elif [ $QUAL = e19 ]; then
36 COMPILERVERS="gcc v8_2_0"
38 elif [ $QUAL = e20 ]; then
39 COMPILERVERS="gcc v9_3_0"
41 elif [ $QUAL = c7 ]; then
42 COMPILERVERS="clang v7_0_0"
43 COMPILERCOMMAND=clang++
46 echo "Compiler and version string: " $COMPILERVERS
47 echo "Compiler command: " $COMPILERCOMMAND
49 echo "COMPILERQUAL_LIST: " $COMPILERQUAL_LIST
51 if [ "$COMPILERVERS" = unknown ]; then
52 echo "unknown compiler flag: $QUAL"
58 echo "build type: $BUILDTYPE"
60 # -- gen, avx, or avx2
62 echo "simd qualifier: $SIMDQUALIFIER"
64 echo "workspace: $WORKSPACE"
67 # Environment setup; look in CVMFS first
69 if [ -f /cvmfs/dune.opensciencegrid.org/products/dune/setup_dune.sh ]; then
70 source /cvmfs/dune.opensciencegrid.org/products/dune/setup_dune.sh || exit 1
71 elif [ -f /grid/fermiapp/products/dune/setup_dune_fermiapp.sh ]; then
72 source /grid/fermiapp/products/dune/setup_dune_fermiapp.sh || exit 1
74 echo "No setup file found."
80 # Use system git on macos, and the one in ups for linux
82 if ! uname | grep -q Darwin; then
85 setup gitflow || exit 1
87 rm -rf $WORKSPACE/temp || exit 1
88 mkdir -p $WORKSPACE/temp || exit 1
89 mkdir -p $WORKSPACE/copyBack || exit 1
90 rm -f $WORKSPACE/copyBack/* || exit 1
91 cd $WORKSPACE/temp || exit 1
94 # change all dots to underscores, and capital V's to little v's in the version string
95 # add our own suffix as the compiler version moves more rapidly than the product version
97 VERSION=`echo ${JJVERSION} | sed -e "s/V/v/g" | sed -e "s/\./_/g"`${VERSIONSUFFIX}
100 FLAVOR=`ups flavor -4`
101 if [ `uname` = Darwin ]; then
102 FLAVOR=`ups flavor -2`
106 touch ${PRODUCT_NAME} || exit 1
107 rm -rf ${PRODUCT_NAME} || exit 1
108 touch inputdir || exit 1
109 rm -rf inputdir || exit 1
110 mkdir -p ${PRODUCT_NAME}/${VERSION}/source || exit 1
111 mkdir ${PRODUCT_NAME}/${VERSION}/include || exit 1
112 mkdir ${PRODUCT_NAME}/${VERSION}/data || exit 1
113 mkdir ${PRODUCT_NAME}/${VERSION}/ups || exit 1
116 TABLEFILENAME=${PRODUCT_NAME}/${VERSION}/ups/${PRODUCT_NAME}.table
117 touch ${TABLEFILENAME} || exit 1
118 rm -rf ${TABLEFILENAME} || exit 1
119 cat > ${TABLEFILENAME} <<EOF
123 #*************************************************
124 # Starting Group definition
129 for CQ in $COMPILERQUAL_LIST; do
130 touch tablefrag.txt || exit 1
131 rm -rf tablefrag.txt || exit 1
132 cat > tablefrag.txt <<'EOF'
135 Qualifiers=QUALIFIER_REPLACE_STRING:gen:debug
138 envSet (DUNEPDSPRCE_FQ_DIR, ${UPS_PROD_DIR}/${UPS_PROD_FLAVOR}-QUALIFIER_REPLACE_STRING-gen-debug)
141 setupRequired( COMPILERVERS_REPLACE_STRING )
144 Qualifiers=QUALIFIER_REPLACE_STRING:avx:debug
147 envSet (DUNEPDSPRCE_FQ_DIR, ${UPS_PROD_DIR}/${UPS_PROD_FLAVOR}-QUALIFIER_REPLACE_STRING-avx-debug)
150 setupRequired( COMPILERVERS_REPLACE_STRING )
153 Qualifiers=QUALIFIER_REPLACE_STRING:avx2:debug
156 envSet (DUNEPDSPRCE_FQ_DIR, ${UPS_PROD_DIR}/${UPS_PROD_FLAVOR}-QUALIFIER_REPLACE_STRING-avx2-debug)
159 setupRequired( COMPILERVERS_REPLACE_STRING )
162 Qualifiers=QUALIFIER_REPLACE_STRING:gen:prof
165 envSet (DUNEPDSPRCE_FQ_DIR, ${UPS_PROD_DIR}/${UPS_PROD_FLAVOR}-QUALIFIER_REPLACE_STRING-gen-prof)
168 setupRequired( COMPILERVERS_REPLACE_STRING )
171 Qualifiers=QUALIFIER_REPLACE_STRING:avx:prof
174 envSet (DUNEPDSPRCE_FQ_DIR, ${UPS_PROD_DIR}/${UPS_PROD_FLAVOR}-QUALIFIER_REPLACE_STRING-avx-prof)
177 setupRequired( COMPILERVERS_REPLACE_STRING )
180 Qualifiers=QUALIFIER_REPLACE_STRING:avx2:prof
183 envSet (DUNEPDSPRCE_FQ_DIR, ${UPS_PROD_DIR}/${UPS_PROD_FLAVOR}-QUALIFIER_REPLACE_STRING-avx2-prof)
186 setupRequired( COMPILERVERS_REPLACE_STRING )
191 if [ $CQ = e14 ]; then
193 elif [ $CQ = e15 ]; then
195 elif [ $CQ = e17 ]; then
197 elif [ $CQ = c2 ]; then
199 elif [ $CQ = e19 ]; then
201 elif [ $CQ = e20 ]; then
203 elif [ $CQ = c7 ]; then
206 if [ "$CV" = unknown ]; then
207 echo "unknown compiler flag in COMPILERQUAL_LIST : $CQ"
211 sed -e "s/QUALIFIER_REPLACE_STRING/${CQ}/g" < tablefrag.txt | sed -e "s/COMPILERVERS_REPLACE_STRING/${CV}/g" >> ${TABLEFILENAME} || exit 1
212 rm -f tablefrag.txt || exit 1
216 cat >> ${TABLEFILENAME} <<'EOF'
221 ExeActionRequired(DefineFQ)
222 envSet(DUNEPDSPRCE_DIR, ${UPS_PROD_DIR})
223 envSet(DUNEPDSPRCE_VERSION, ${UPS_PROD_VERSION})
224 envSet(DUNEPDSPRCE_INC, ${DUNEPDSPRCE_DIR}/include)
225 envSet(DUNEPDSPRCE_LIB, ${DUNEPDSPRCE_FQ_DIR}/lib)
226 # add the lib directory to LD_LIBRARY_PATH
227 if ( test `uname` = "Darwin" )
228 envPrepend(DYLD_LIBRARY_PATH, ${DUNEPDSPRCE_FQ_DIR}/lib)
230 envPrepend(LD_LIBRARY_PATH, ${DUNEPDSPRCE_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 ${DUNEPDSPRCE_FQ_DIR}/$dd ] && exit;done;exit 1' )
234 pathPrepend(PATH, ${DUNEPDSPRCE_FQ_DIR}/bin )
236 execute( true, NO_UPS_ENV )
237 endif ( sh -c 'for dd in bin;do [ -d ${DUNEPDSPRCE_FQ_DIR}/$dd ] && exit;done;exit 1' )
239 # envPrepend(CMAKE_PREFIX_PATH, ${DUNEPDSPRCE_DIR} ) this package doesn't use cmake
240 # envPrepend(PKG_CONFIG_PATH, ${DUNEPDSPRCE_DIR} )
242 exeActionRequired(ExtraSetup)
244 # End Group definition
245 #*************************************************
249 mkdir inputdir || exit 1
251 git clone https://github.com/dune/dunepdsprce.git || exit 1
252 cd dunepdsprce || exit 1
253 git checkout tags/${JJVERSION} || exit 1
255 # copy all the files that do not need building. Copy the headers later when we're done as they are in the install directory
257 cp -R -L dam/source/* ${CURDIR}/${PRODUCT_NAME}/${VERSION}/source || exit 1
259 # skip the example data files
261 # cp -R -L data/* ${CURDIR}/${PRODUCT_NAME}/${VERSION}/data || exit 1
263 DIRNAME=${CURDIR}/${PRODUCT_NAME}/${VERSION}/${FLAVOR}-${QUAL}-${SIMDQUALIFIER}-${BUILDTYPE}
264 mkdir -p ${DIRNAME} || exit 1
265 rm -rf ${DIRNAME}/* || exit 1
266 mkdir ${DIRNAME}/bin || exit 1
267 mkdir ${DIRNAME}/lib || exit 1
269 cd ${CURDIR}/inputdir/dunepdsprce/dam/source/cc/make || exit 1
272 if [ $BUILDTYPE = prof ]; then
273 echo "Making optimized version"
274 make CC=${COMPILERCOMMAND} CXX=${COMPILERCOMMAND} LD=${COMPILERCOMMAND} PROD=1 target=x86_64-${SIMDQUALIFIER}-${LINDAR} || exit 1
276 echo "Making debug version"
277 make CC=${COMPILERCOMMAND} CXX=${COMPILERCOMMAND} LD=${COMPILERCOMMAND} target=x86_64-${SIMDQUALIFIER}-${LINDAR} || exit 1
280 cp -R -L ${CURDIR}/inputdir/dunepdsprce/install/x86_64-${SIMDQUALIFIER}-${LINDAR}/bin/* ${CURDIR}/${PRODUCT_NAME}/${VERSION}/${FLAVOR}-${QUAL}-${SIMDQUALIFIER}-${BUILDTYPE}/bin
282 # JJ builds a program called "reader" which probably shouldn't be in the user's PATH. Rename it if it exists
284 if [ -e ${CURDIR}/${PRODUCT_NAME}/${VERSION}/${FLAVOR}-${QUAL}-${SIMDQUALIFIER}-${BUILDTYPE}/bin/reader ]; then
285 mv ${CURDIR}/${PRODUCT_NAME}/${VERSION}/${FLAVOR}-${QUAL}-${SIMDQUALIFIER}-${BUILDTYPE}/bin/reader ${CURDIR}/${PRODUCT_NAME}/${VERSION}/${FLAVOR}-${QUAL}-${SIMDQUALIFIER}-${BUILDTYPE}/bin/${PRODUCT_NAME}_testreader
288 # in the case of the shared libraries, we want to only copy the libraries once, and make new symlinks with relative paths
290 cd ${CURDIR}/inputdir/dunepdsprce/dam/export/x86_64-${SIMDQUALIFIER}-${LINDAR}/lib
291 for LIBFILE in $( ls ); do
292 if [ -h ${LIBFILE} ]; then
293 TMPVAR=`readlink ${LIBFILE}`
294 ln -s `basename ${TMPVAR}` ${CURDIR}/${PRODUCT_NAME}/${VERSION}/${FLAVOR}-${QUAL}-${SIMDQUALIFIER}-${BUILDTYPE}/lib/${LIBFILE} || exit 1
296 cp ${LIBFILE} ${CURDIR}/${PRODUCT_NAME}/${VERSION}/${FLAVOR}-${QUAL}-${SIMDQUALIFIER}-${BUILDTYPE}/lib || exit 1
300 cp -R -L ${CURDIR}/inputdir/dunepdsprce/install/x86_64-${SIMDQUALIFIER}-${LINDAR}/include/* ${CURDIR}/${PRODUCT_NAME}/${VERSION}/include || exit 1
302 # assemble the UPS product and declare it
304 cd ${CURDIR} || exit 1
306 # for testing the tarball, remove so we keep .upsfiles as is when
307 # unwinding into a real products area
309 mkdir .upsfiles || exit 1
310 cat <<EOF > .upsfiles/dbconfig
314 PROD_DIR_PREFIX = \${UPS_THIS_DB}
315 UPD_USERCODE_DIR = \${UPS_THIS_DB}/.updfiles
318 ups declare ${PRODUCT_NAME} ${VERSION} -f ${FLAVOR} -m ${PRODUCT_NAME}.table -z `pwd` -r ./${PRODUCT_NAME}/${VERSION} -q ${BUILDTYPE}:${QUAL}:${SIMDQUALIFIER}
320 rm -rf .upsfiles || exit 1
323 rm -rf ${CURDIR}/inputdir || exit 1
325 cd ${CURDIR} || exit 1
329 VERSIONDOTS=`echo ${VERSION} | sed -e "s/_/./g"`
330 SUBDIR=`get-directory-name subdir | sed -e "s/\./-/g"`
332 # use SUBDIR instead of FLAVOR
334 FULLNAME=${PRODUCT_NAME}-${VERSIONDOTS}-${SUBDIR}-${QUAL}-${SIMDQUALIFIER}-${BUILDTYPE}
336 # strip off the first "v" in the version number
338 FULLNAMESTRIPPED=`echo $FULLNAME | sed -e "s/${PRODUCT_NAME}-v/${PRODUCT_NAME}-/"`
340 tar -cjf $WORKSPACE/copyBack/${FULLNAMESTRIPPED}.tar.bz2 .
342 ls -l $WORKSPACE/copyBack/
343 cd $WORKSPACE || exit 1
344 rm -rf $WORKSPACE/temp || exit 1