All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
build-dunepdsprce.sh
Go to the documentation of this file.
1 #!/bin/bash
2 
3 # build dunepdsprce
4 
5 PRODUCT_NAME=dunepdsprce
6 
7 # designed to work on Jenkins
8 
9 # for checking out from JJ's github repo
10 
11 echo "dunepdsprce JJ github: $JJVERSION"
12 
13 # -- the base qualifier is only the compiler version qualifier: e.g. "e15"
14 
15 echo "base qualifiers: $QUAL"
16 
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.
20 
22 COMPILERCOMMAND=unknown
23 if [ $QUAL = e14 ]; then
24  COMPILERVERS="gcc v6_3_0"
25  COMPILERCOMMAND=g++
26 elif [ $QUAL = e15 ]; then
27  COMPILERVERS="gcc v6_4_0"
28  COMPILERCOMMAND=g++
29 elif [ $QUAL = e17 ]; then
30  COMPILERVERS="gcc v7_3_0"
31  COMPILERCOMMAND=g++
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"
37  COMPILERCOMMAND=g++
38 elif [ $QUAL = c7 ]; then
39  COMPILERVERS="clang v7_0_0"
40  COMPILERCOMMAND=clang++
41 fi
42 
43 echo "Compiler and version string: " $COMPILERVERS
44 echo "Compiler command: " $COMPILERCOMMAND
45 
46 echo "COMPILERQUAL_LIST: " $COMPILERQUAL_LIST
47 
48 if [ "$COMPILERVERS" = unknown ]; then
49  echo "unknown compiler flag: $QUAL"
50  exit 1
51 fi
52 
53 # -- prof or debug
54 
55 echo "build type: $BUILDTYPE"
56 
57 # -- gen, avx, or avx2
58 
59 echo "simd qualifier: $SIMDQUALIFIER"
60 
61 echo "workspace: $WORKSPACE"
62 
63 
64 # Environment setup; look in CVMFS first
65 
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
70 else
71  echo "No setup file found."
72  exit 1
73 fi
74 
76 
77 # Use system git on macos, and the one in ups for linux
78 
79 if ! uname | grep -q Darwin; then
80  setup git || exit 1
81 fi
82 setup gitflow || exit 1
83 
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
89 CURDIR=`pwd`
90 
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
93 
94 VERSION=`echo ${JJVERSION} | sed -e "s/V/v/g" | sed -e "s/\./_/g"`${VERSIONSUFFIX}
95 
96 LINDAR=linux
97 FLAVOR=`ups flavor -4`
98 if [ `uname` = Darwin ]; then
99  FLAVOR=`ups flavor -2`
100  LINDAR=darwin
101 fi
102 
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
111 
112 
113 TABLEFILENAME=${PRODUCT_NAME}/${VERSION}/ups/${PRODUCT_NAME}.table
114 touch ${TABLEFILENAME} || exit 1
115 rm -rf ${TABLEFILENAME} || exit 1
116 cat > ${TABLEFILENAME} <<EOF
117 File=Table
118 Product=dunepdsprce
119 
120 #*************************************************
121 # Starting Group definition
122 Group:
123 
124 EOF
125 
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'
130 
131 Flavor=ANY
132 Qualifiers=QUALIFIER_REPLACE_STRING:gen:debug
133 
134  Action=DefineFQ
135  envSet (DUNEPDSPRCE_FQ_DIR, ${UPS_PROD_DIR}/${UPS_PROD_FLAVOR}-QUALIFIER_REPLACE_STRING-gen-debug)
136 
137  Action = ExtraSetup
138  setupRequired( COMPILERVERS_REPLACE_STRING )
139 
140 Flavor=ANY
141 Qualifiers=QUALIFIER_REPLACE_STRING:avx:debug
142 
143  Action=DefineFQ
144  envSet (DUNEPDSPRCE_FQ_DIR, ${UPS_PROD_DIR}/${UPS_PROD_FLAVOR}-QUALIFIER_REPLACE_STRING-avx-debug)
145 
146  Action = ExtraSetup
147  setupRequired( COMPILERVERS_REPLACE_STRING )
148 
149 Flavor=ANY
150 Qualifiers=QUALIFIER_REPLACE_STRING:avx2:debug
151 
152  Action=DefineFQ
153  envSet (DUNEPDSPRCE_FQ_DIR, ${UPS_PROD_DIR}/${UPS_PROD_FLAVOR}-QUALIFIER_REPLACE_STRING-avx2-debug)
154 
155  Action = ExtraSetup
156  setupRequired( COMPILERVERS_REPLACE_STRING )
157 
158 Flavor=ANY
159 Qualifiers=QUALIFIER_REPLACE_STRING:gen:prof
160 
161  Action=DefineFQ
162  envSet (DUNEPDSPRCE_FQ_DIR, ${UPS_PROD_DIR}/${UPS_PROD_FLAVOR}-QUALIFIER_REPLACE_STRING-gen-prof)
163 
164  Action = ExtraSetup
165  setupRequired( COMPILERVERS_REPLACE_STRING )
166 
167 Flavor=ANY
168 Qualifiers=QUALIFIER_REPLACE_STRING:avx:prof
169 
170  Action=DefineFQ
171  envSet (DUNEPDSPRCE_FQ_DIR, ${UPS_PROD_DIR}/${UPS_PROD_FLAVOR}-QUALIFIER_REPLACE_STRING-avx-prof)
172 
173  Action = ExtraSetup
174  setupRequired( COMPILERVERS_REPLACE_STRING )
175 
176 Flavor=ANY
177 Qualifiers=QUALIFIER_REPLACE_STRING:avx2:prof
178 
179  Action=DefineFQ
180  envSet (DUNEPDSPRCE_FQ_DIR, ${UPS_PROD_DIR}/${UPS_PROD_FLAVOR}-QUALIFIER_REPLACE_STRING-avx2-prof)
181 
182  Action = ExtraSetup
183  setupRequired( COMPILERVERS_REPLACE_STRING )
184 
185 EOF
186 
187 CV=unknown
188 if [ $CQ = e14 ]; then
189  CV="gcc v6_3_0"
190 elif [ $CQ = e15 ]; then
191  CV="gcc v6_4_0"
192 elif [ $CQ = e17 ]; then
193  CV="gcc v7_3_0"
194 elif [ $CQ = c2 ]; then
195  CV="clang v5_0_1"
196 elif [ $CQ = e19 ]; then
197  CV="gcc v8_2_0"
198 elif [ $CQ = c7 ]; then
199  CV="clang v7_0_0"
200 fi
201 if [ "$CV" = unknown ]; then
202  echo "unknown compiler flag in COMPILERQUAL_LIST : $CQ"
203  exit 1
204 fi
205 
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
208 
209 done
210 
211 cat >> ${TABLEFILENAME} <<'EOF'
212 Common:
213  Action=setup
214  setupenv()
215  proddir()
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)
224  else()
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 )
230  else ()
231  execute( true, NO_UPS_ENV )
232  endif ( sh -c 'for dd in bin;do [ -d ${DUNEPDSPRCE_FQ_DIR}/$dd ] && exit;done;exit 1' )
233  # useful variables
234 # envPrepend(CMAKE_PREFIX_PATH, ${DUNEPDSPRCE_DIR} ) this package doesn't use cmake
235 # envPrepend(PKG_CONFIG_PATH, ${DUNEPDSPRCE_DIR} )
236  # requirements
237  exeActionRequired(ExtraSetup)
238 End:
239 # End Group definition
240 #*************************************************
241 
242 EOF
243 
244 mkdir inputdir || exit 1
245 cd inputdir
246 git clone https://github.com/dune/dunepdsprce.git || exit 1
247 cd dunepdsprce || exit 1
248 git checkout tags/${JJVERSION} || exit 1
249 
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
251 
252 cp -R -L dam/source/* ${CURDIR}/${PRODUCT_NAME}/${VERSION}/source || exit 1
253 
254 # skip the example data files
255 
256 # cp -R -L data/* ${CURDIR}/${PRODUCT_NAME}/${VERSION}/data || exit 1
257 
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
263 
264 cd ${CURDIR}/inputdir/dunepdsprce/dam/source/cc/make || exit 1
265 make clean || exit 1
266 
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
270 else
271  echo "Making debug version"
272  make CC=${COMPILERCOMMAND} CXX=${COMPILERCOMMAND} LD=${COMPILERCOMMAND} target=x86_64-${SIMDQUALIFIER}-${LINDAR} || exit 1
273 fi
274 
275 cp -R -L ${CURDIR}/inputdir/dunepdsprce/install/x86_64-${SIMDQUALIFIER}-${LINDAR}/bin/* ${CURDIR}/${PRODUCT_NAME}/${VERSION}/${FLAVOR}-${QUAL}-${SIMDQUALIFIER}-${BUILDTYPE}/bin
276 
277 # JJ builds a program called "reader" which probably shouldn't be in the user's PATH. Rename it if it exists
278 
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
281 fi
282 
283 # in the case of the shared libraries, we want to only copy the libraries once, and make new symlinks with relative paths
284 
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
290  else
291  cp ${LIBFILE} ${CURDIR}/${PRODUCT_NAME}/${VERSION}/${FLAVOR}-${QUAL}-${SIMDQUALIFIER}-${BUILDTYPE}/lib || exit 1
292  fi
293 done
294 
295 cp -R -L ${CURDIR}/inputdir/dunepdsprce/install/x86_64-${SIMDQUALIFIER}-${LINDAR}/include/* ${CURDIR}/${PRODUCT_NAME}/${VERSION}/include || exit 1
296 
297 # assemble the UPS product and declare it
298 
299 cd ${CURDIR} || exit 1
300 
301 # for testing the tarball, remove so we keep .upsfiles as is when
302 # unwinding into a real products area
303 
304 mkdir .upsfiles || exit 1
305 cat <<EOF > .upsfiles/dbconfig
306 FILE = DBCONFIG
307 AUTHORIZED_NODES = *
308 VERSION_SUBDIR = 1
309 PROD_DIR_PREFIX = \${UPS_THIS_DB}
310 UPD_USERCODE_DIR = \${UPS_THIS_DB}/.updfiles
311 EOF
312 
313 ups declare ${PRODUCT_NAME} ${VERSION} -f ${FLAVOR} -m ${PRODUCT_NAME}.table -z `pwd` -r ./${PRODUCT_NAME}/${VERSION} -q ${BUILDTYPE}:${SIMDQUALIFIER}:${QUAL}
314 
315 rm -rf .upsfiles || exit 1
316 
317 # clean up
318 rm -rf ${CURDIR}/inputdir || exit 1
319 
320 cd ${CURDIR} || exit 1
321 
322 ls -la
323 
324 VERSIONDOTS=`echo ${VERSION} | sed -e "s/_/./g"`
325 SUBDIR=`get-directory-name subdir | sed -e "s/\./-/g"`
326 
327 # use SUBDIR instead of FLAVOR
328 
329 FULLNAME=${PRODUCT_NAME}-${VERSIONDOTS}-${SUBDIR}-${SIMDQUALIFIER}-${QUAL}-${BUILDTYPE}
330 
331 # strip off the first "v" in the version number
332 
333 FULLNAMESTRIPPED=`echo $FULLNAME | sed -e "s/${PRODUCT_NAME}-v/${PRODUCT_NAME}-/"`
334 
335 tar -cjf $WORKSPACE/copyBack/${FULLNAMESTRIPPED}.tar.bz2 .
336 
337 ls -l $WORKSPACE/copyBack/
338 cd $WORKSPACE || exit 1
339 rm -rf $WORKSPACE/temp || exit 1
340 
341 exit 0
then source grid fermiapp products dune setup_dune_fermiapp sh exit else echo No setup file found exit fi setup
then COMPILERVERS
then cvmfs grid cern ch util cvmfs uptodate cvmfs uboone opensciencegrid org products fi source cvmfs uboone opensciencegrid org products setup_uboone sh exit else echo No setup file found exit fi if!uname grep q Darwin
Definition: build_larcv.sh:51
do source
pdgs p
Definition: selectors.fcl:22
then source cvmfs dune opensciencegrid org products dune setup_dune sh exit elif[-f/grid/fermiapp/products/dune/setup_dune_fermiapp.sh]
BEGIN_PROLOG g
PRODUCT_NAME
process_name showerreco Particles Coinciding wih the Vertex services ScanOptions nu_mu unknown
then shift fi
g grid