sourceme-external-prefix.sh
Go to the documentation of this file.
1 #!/bin/bash
2 
3 # This defines some Bash functions which help simply development of
4 # WCT on the assumption that externals are installed in a Spack view
5 # (or equivalent) and that WCT itself is installed in some other
6 # directory (although the two may be degenerate)
7 
8 
9 # This file can be sourced with paths to externals and WCT
10 # installation prefix:
11 #
12 # source sourceme-external-prefix.sh /path/to/externals /path/to/prefix
13 #
14 # or define WCT_EXTERNALS and WCT_PREFIX to each path, respectively.
15 
16 export WCT_EXTERNALS=${WCT_EXTERNALS:-$1}
17 export WCT_PREFIX=${WCT_PREFIX:-$2}
18 
19 addpath ()
20 {
21  local pathvar=${2:-PATH}
22  local pathval="${!pathvar}"
23  pathval=${pathval//":$1"/}
24  pathval=${pathval//"$1:"/}
25  export $pathvar="$1:$pathval"
26 }
27 
28 wct-configure () {
29 
30  addpath "$WCT_EXTERNALS/lib/pkgconfig" PKG_CONFIG_PATH
31  addpath "$WCT_EXTERNALS/share/pkgconfig" PKG_CONFIG_PATH
32 
33  local mydir=$(dirname $(readlink -f $BASH_SOURCE))
34  cd $mydir
35 
36  ./wcb configure \
37  --prefix=$WCT_PREFIX \
38  --boost-includes=$WCT_EXTERNALS/include \
39  --boost-libs=$WCT_EXTERNALS/lib \
40  --boost-mt \
41  --with-eigen=$WCT_EXTERNALS \
42  --with-jsoncpp=$WCT_EXTERNALS \
43  --with-tbb=$WCT_EXTERNALS \
44  --with-root=$WCT_EXTERNALS \
45  --with-fftw=$WCT_EXTERNALS \
46  --with-jsonnet=$WCT_EXTERNALS \
47  "$@"
48 }
49 
50 wct-test () {
51  local name=$1 ; shift
52 
53  local mydir=$(dirname $(readlink -f $BASH_SOURCE))
54  local old_ld_library_path="$LD_LIBRARY_PATH"
55  addpath $WCT_EXTERNALS/lib LD_LIBRARY_PATH
56  for maybe in $mydir/build/* ;
57  do
58  maybe="$(readlink -f $maybe)"
59  if [ -d "$maybe" ] ; then
60  addpath $maybe LD_LIBRARY_PATH
61  fi
62  done
63  $mydir/build/*/test_$name $@
64  LD_LIBRARY_PATH=$old_ld_library_path
65 }
66 
67 wct-run () {
68  local mydir=$(dirname $(readlink -f $BASH_SOURCE))
69  local old_ld_library_path="$LD_LIBRARY_PATH"
70  local old_path="$PATH"
71  addpath $WCT_EXTERNALS/lib LD_LIBRARY_PATH
72  addpath $WCT_EXTERNALS/bin PATH
73  addpath $WCT_PREFIX/lib LD_LIBRARY_PATH
74  addpath $WCT_PREFIX/bin PATH
75 
76  # configuration and field/wire data files
77  addpath $WCT_PREFIX/share/wirecell/data WIRECELL_PATH
78  addpath $WCT_PREFIX/share/wirecell/config WIRECELL_PATH
79  addpath $WCT_PREFIX/data WIRECELL_PATH
80 
81  for maybe in $mydir/build/* ;
82  do
83  maybe="$(readlink -f $maybe)"
84  if [ -d "$maybe" ] ; then
85  addpath $maybe LD_LIBRARY_PATH
86  fi
87  done
88  $@
89  LD_LIBRARY_PATH=$old_ld_library_path
90  PATH=$old_path
91 }