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 = c7 ]; then
39 COMPILERVERS="clang v7_0_0"
40 COMPILERCOMMAND=clang++
43 echo "Compiler and version string: " $COMPILERVERS
44 echo "Compiler command: " $COMPILERCOMMAND
46 echo "COMPILERQUAL_LIST: " $COMPILERQUAL_LIST
48 if [ "$COMPILERVERS" = unknown ]; then
49 echo "unknown compiler flag: $QUAL"
55 echo "build type: $BUILDTYPE"
57 # -- gen, avx, or avx2
59 echo "simd qualifier: $SIMDQUALIFIER"
61 echo "workspace: $WORKSPACE"
64 # Environment setup; look in CVMFS first
66 if [ -f /cvmfs/dune.opensciencegrid.org/products/dune/setup_dune.sh ]; then
67 source /cvmfs/dune.opensciencegrid.org/products/dune/setup_dune.sh || exit 1
68 elif [ -f /grid/fermiapp/products/dune/setup_dune_fermiapp.sh ]; then
69 source /grid/fermiapp/products/dune/setup_dune_fermiapp.sh || exit 1
71 echo "No setup file found."
77 # Use system git on macos, and the one in ups for linux
79 if ! uname | grep -q Darwin; then
82 setup gitflow || exit 1
84 rm -rf $WORKSPACE/temp || exit 1
85 mkdir -p $WORKSPACE/temp || exit 1
86 mkdir -p $WORKSPACE/copyBack || exit 1
87 rm -f $WORKSPACE/copyBack/* || exit 1
88 cd $WORKSPACE/temp || exit 1
91 # change all dots to underscores, and capital V's to little v's in the version string
92 # add our own suffix as the compiler version moves more rapidly than the product version
94 VERSION=`echo ${JJVERSION} | sed -e "s/V/v/g" | sed -e "s/\./_/g"`${VERSIONSUFFIX}
97 FLAVOR=`ups flavor -4`
98 if [ `uname` = Darwin ]; then
99 FLAVOR=`ups flavor -2`
103 touch ${PRODUCT_NAME} || exit 1
104 rm -rf ${PRODUCT_NAME} || exit 1
105 touch inputdir || exit 1
106 rm -rf inputdir || exit 1
107 mkdir -p ${PRODUCT_NAME}/${VERSION}/source || exit 1
108 mkdir ${PRODUCT_NAME}/${VERSION}/include || exit 1
109 mkdir ${PRODUCT_NAME}/${VERSION}/data || exit 1
110 mkdir ${PRODUCT_NAME}/${VERSION}/ups || exit 1
113 TABLEFILENAME=${PRODUCT_NAME}/${VERSION}/ups/${PRODUCT_NAME}.table
114 touch ${TABLEFILENAME} || exit 1
115 rm -rf ${TABLEFILENAME} || exit 1
116 cat > ${TABLEFILENAME} <<EOF
120 #*************************************************
121 # Starting Group definition
126 for CQ in $COMPILERQUAL_LIST; do
127 touch tablefrag.txt || exit 1
128 rm -rf tablefrag.txt || exit 1
129 cat > tablefrag.txt <<'EOF'
132 Qualifiers=QUALIFIER_REPLACE_STRING:gen:debug
135 envSet (DUNEPDSPRCE_FQ_DIR, ${UPS_PROD_DIR}/${UPS_PROD_FLAVOR}-QUALIFIER_REPLACE_STRING-gen-debug)
138 setupRequired( COMPILERVERS_REPLACE_STRING )
141 Qualifiers=QUALIFIER_REPLACE_STRING:avx:debug
144 envSet (DUNEPDSPRCE_FQ_DIR, ${UPS_PROD_DIR}/${UPS_PROD_FLAVOR}-QUALIFIER_REPLACE_STRING-avx-debug)
147 setupRequired( COMPILERVERS_REPLACE_STRING )
150 Qualifiers=QUALIFIER_REPLACE_STRING:avx2:debug
153 envSet (DUNEPDSPRCE_FQ_DIR, ${UPS_PROD_DIR}/${UPS_PROD_FLAVOR}-QUALIFIER_REPLACE_STRING-avx2-debug)
156 setupRequired( COMPILERVERS_REPLACE_STRING )
159 Qualifiers=QUALIFIER_REPLACE_STRING:gen:prof
162 envSet (DUNEPDSPRCE_FQ_DIR, ${UPS_PROD_DIR}/${UPS_PROD_FLAVOR}-QUALIFIER_REPLACE_STRING-gen-prof)
165 setupRequired( COMPILERVERS_REPLACE_STRING )
168 Qualifiers=QUALIFIER_REPLACE_STRING:avx:prof
171 envSet (DUNEPDSPRCE_FQ_DIR, ${UPS_PROD_DIR}/${UPS_PROD_FLAVOR}-QUALIFIER_REPLACE_STRING-avx-prof)
174 setupRequired( COMPILERVERS_REPLACE_STRING )
177 Qualifiers=QUALIFIER_REPLACE_STRING:avx2:prof
180 envSet (DUNEPDSPRCE_FQ_DIR, ${UPS_PROD_DIR}/${UPS_PROD_FLAVOR}-QUALIFIER_REPLACE_STRING-avx2-prof)
183 setupRequired( COMPILERVERS_REPLACE_STRING )
188 if [ $CQ = e14 ]; then
190 elif [ $CQ = e15 ]; then
192 elif [ $CQ = e17 ]; then
194 elif [ $CQ = c2 ]; then
196 elif [ $CQ = e19 ]; then
198 elif [ $CQ = c7 ]; then
201 if [ "$CV" = unknown ]; then
202 echo "unknown compiler flag in COMPILERQUAL_LIST : $CQ"
206 sed -e "s/QUALIFIER_REPLACE_STRING/${CQ}/g" < tablefrag.txt | sed -e "s/COMPILERVERS_REPLACE_STRING/${CV}/g" >> ${TABLEFILENAME} || exit 1
207 rm -f tablefrag.txt || exit 1
211 cat >> ${TABLEFILENAME} <<'EOF'
216 ExeActionRequired(DefineFQ)
217 envSet(DUNEPDSPRCE_DIR, ${UPS_PROD_DIR})
218 envSet(DUNEPDSPRCE_VERSION, ${UPS_PROD_VERSION})
219 envSet(DUNEPDSPRCE_INC, ${DUNEPDSPRCE_DIR}/include)
220 envSet(DUNEPDSPRCE_LIB, ${DUNEPDSPRCE_FQ_DIR}/lib)
221 # add the lib directory to LD_LIBRARY_PATH
222 if ( test `uname` = "Darwin" )
223 envPrepend(DYLD_LIBRARY_PATH, ${DUNEPDSPRCE_FQ_DIR}/lib)
225 envPrepend(LD_LIBRARY_PATH, ${DUNEPDSPRCE_FQ_DIR}/lib)
226 endif ( test `uname` = "Darwin" )
227 # add the bin directory to the path if it exists
228 if ( sh -c 'for dd in bin;do [ -d ${DUNEPDSPRCE_FQ_DIR}/$dd ] && exit;done;exit 1' )
229 pathPrepend(PATH, ${DUNEPDSPRCE_FQ_DIR}/bin )
231 execute( true, NO_UPS_ENV )
232 endif ( sh -c 'for dd in bin;do [ -d ${DUNEPDSPRCE_FQ_DIR}/$dd ] && exit;done;exit 1' )
234 # envPrepend(CMAKE_PREFIX_PATH, ${DUNEPDSPRCE_DIR} ) this package doesn't use cmake
235 # envPrepend(PKG_CONFIG_PATH, ${DUNEPDSPRCE_DIR} )
237 exeActionRequired(ExtraSetup)
239 # End Group definition
240 #*************************************************
244 mkdir inputdir || exit 1
246 git clone https://github.com/dune/dunepdsprce.git || exit 1
247 cd dunepdsprce || exit 1
248 git checkout tags/${JJVERSION} || exit 1
250 # copy all the files that do not need building. Copy the headers later when we're done as they are in the install directory
252 cp -R -L dam/source/* ${CURDIR}/${PRODUCT_NAME}/${VERSION}/source || exit 1
254 # skip the example data files
256 # cp -R -L data/* ${CURDIR}/${PRODUCT_NAME}/${VERSION}/data || exit 1
258 DIRNAME=${CURDIR}/${PRODUCT_NAME}/${VERSION}/${FLAVOR}-${QUAL}-${SIMDQUALIFIER}-${BUILDTYPE}
259 mkdir -p ${DIRNAME} || exit 1
260 rm -rf ${DIRNAME}/* || exit 1
261 mkdir ${DIRNAME}/bin || exit 1
262 mkdir ${DIRNAME}/lib || exit 1
264 cd ${CURDIR}/inputdir/dunepdsprce/dam/source/cc/make || exit 1
267 if [ $BUILDTYPE = prof ]; then
268 echo "Making optimized version"
269 make CC=${COMPILERCOMMAND} CXX=${COMPILERCOMMAND} LD=${COMPILERCOMMAND} PROD=1 target=x86_64-${SIMDQUALIFIER}-${LINDAR} || exit 1
271 echo "Making debug version"
272 make CC=${COMPILERCOMMAND} CXX=${COMPILERCOMMAND} LD=${COMPILERCOMMAND} target=x86_64-${SIMDQUALIFIER}-${LINDAR} || exit 1
275 cp -R -L ${CURDIR}/inputdir/dunepdsprce/install/x86_64-${SIMDQUALIFIER}-${LINDAR}/bin/* ${CURDIR}/${PRODUCT_NAME}/${VERSION}/${FLAVOR}-${QUAL}-${SIMDQUALIFIER}-${BUILDTYPE}/bin
277 # JJ builds a program called "reader" which probably shouldn't be in the user's PATH. Rename it if it exists
279 if [ -e ${CURDIR}/${PRODUCT_NAME}/${VERSION}/${FLAVOR}-${QUAL}-${SIMDQUALIFIER}-${BUILDTYPE}/bin/reader ]; then
280 mv ${CURDIR}/${PRODUCT_NAME}/${VERSION}/${FLAVOR}-${QUAL}-${SIMDQUALIFIER}-${BUILDTYPE}/bin/reader ${CURDIR}/${PRODUCT_NAME}/${VERSION}/${FLAVOR}-${QUAL}-${SIMDQUALIFIER}-${BUILDTYPE}/bin/${PRODUCT_NAME}_testreader
283 # in the case of the shared libraries, we want to only copy the libraries once, and make new symlinks with relative paths
285 cd ${CURDIR}/inputdir/dunepdsprce/dam/export/x86_64-${SIMDQUALIFIER}-${LINDAR}/lib
286 for LIBFILE in $( ls ); do
287 if [ -h ${LIBFILE} ]; then
288 TMPVAR=`readlink ${LIBFILE}`
289 ln -s `basename ${TMPVAR}` ${CURDIR}/${PRODUCT_NAME}/${VERSION}/${FLAVOR}-${QUAL}-${SIMDQUALIFIER}-${BUILDTYPE}/lib/${LIBFILE} || exit 1
291 cp ${LIBFILE} ${CURDIR}/${PRODUCT_NAME}/${VERSION}/${FLAVOR}-${QUAL}-${SIMDQUALIFIER}-${BUILDTYPE}/lib || exit 1
295 cp -R -L ${CURDIR}/inputdir/dunepdsprce/install/x86_64-${SIMDQUALIFIER}-${LINDAR}/include/* ${CURDIR}/${PRODUCT_NAME}/${VERSION}/include || exit 1
297 # assemble the UPS product and declare it
299 cd ${CURDIR} || exit 1
301 # for testing the tarball, remove so we keep .upsfiles as is when
302 # unwinding into a real products area
304 mkdir .upsfiles || exit 1
305 cat <<EOF > .upsfiles/dbconfig
309 PROD_DIR_PREFIX = \${UPS_THIS_DB}
310 UPD_USERCODE_DIR = \${UPS_THIS_DB}/.updfiles
313 ups declare ${PRODUCT_NAME} ${VERSION} -f ${FLAVOR} -m ${PRODUCT_NAME}.table -z `pwd` -r ./${PRODUCT_NAME}/${VERSION} -q ${BUILDTYPE}:${SIMDQUALIFIER}:${QUAL}
315 rm -rf .upsfiles || exit 1
318 rm -rf ${CURDIR}/inputdir || exit 1
320 cd ${CURDIR} || exit 1
324 VERSIONDOTS=`echo ${VERSION} | sed -e "s/_/./g"`
325 SUBDIR=`get-directory-name subdir | sed -e "s/\./-/g"`
327 # use SUBDIR instead of FLAVOR
329 FULLNAME=${PRODUCT_NAME}-${VERSIONDOTS}-${SUBDIR}-${SIMDQUALIFIER}-${QUAL}-${BUILDTYPE}
331 # strip off the first "v" in the version number
333 FULLNAMESTRIPPED=`echo $FULLNAME | sed -e "s/${PRODUCT_NAME}-v/${PRODUCT_NAME}-/"`
335 tar -cjf $WORKSPACE/copyBack/${FULLNAMESTRIPPED}.tar.bz2 .
337 ls -l $WORKSPACE/copyBack/
338 cd $WORKSPACE || exit 1
339 rm -rf $WORKSPACE/temp || exit 1