-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoe.bash
282 lines (226 loc) · 6.31 KB
/
oe.bash
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
oe-source(){ echo $BASH_SOURCE ; }
oe-vi(){ vi $BASH_SOURCE ; }
oe-usage(){ cat <<EOU
OE : Opticks Environment Setup
==================================
::
oe-
When opticks is treated as an external to JUNO sim framework
the junoenv mechanism takes over the envvar setup.
This should not be used when using Opticks as
a JUNO external. In that case the JUNOTOP/bashrc
sets up the paths.
* by controlling the environment of the CMake custom command
used in okc independently from this enviroment : then
this script needs to know nothing of the source tree
* All python scripts used in testing will need to be installed,
already ?
* Most of the below functions are no longer in active use (?)
They where used to assist with development of $OPTICKS_PREFIX/bin/opticks-setup.sh
and its generation
EOU
}
oe-name(){ echo $(basename $(oe-home)) ; }
oe-local(){ echo ${LOCAL_BASE:-/usr/local} ; }
oe-fold(){ echo $(oe-local)/$(oe-name) ; }
oe-prefix(){ echo $(oe-fold) ; }
oe-home(){ echo $(dirname $BASH_SOURCE) ; }
oe-env()
{
olocal-;
opticks-;
#oe-export
local setup=$OPTICKS_PREFIX/bin/opticks-setup.sh
[ ! -f "$setup" ] && echo $FUNCNAME FATAL - NO setup at $setup - maybe you need to opticks-full
source $setup 1>&2
}
oe-export-mode(){ echo ${OE_EXPORT_MODE:-append} ; }
oe-export- ()
{
local msg="=== $FUNCNAME :";
local pfx;
local libdir;
local mode=$(oe-export-mode);
for pfx in $*;
do
oe-$mode CMAKE_PREFIX_PATH $pfx;
local libs="lib lib64";
for lib in $libs;
do
libdir=$pfx/$lib;
if [ -d "$libdir" ]; then
oe-$mode PKG_CONFIG_PATH $libdir/pkgconfig;
[ "$(uname)" == "Linux" ] && oe-$mode LD_LIBRARY_PATH $libdir;
[ "$(uname)" == "Darwin" ] && oe-$mode DYLD_LIBRARY_PATH $libdir;
fi;
done;
done;
export CMAKE_PREFIX_PATH;
export PKG_CONFIG_PATH;
[ "$(uname)" == "Linux" ] && export LD_LIBRARY_PATH;
[ "$(uname)" == "Darwin" ] && export DYLD_LIBRARY_PATH
}
oe-export-setup-artificial-env ()
{
: transient testing environment setup;
: in real usage the detector simulation framework should define the paths, especially : CMAKE_PREFIX_PATH PKG_CONFIG_PATH;
: warning : significant changes here almost certainly force a cleaninstall of opticks as this changes the externals
unset CMAKE_PREFIX_PATH;
unset PKG_CONFIG_PATH;
unset LD_LIBRARY_PATH;
unset DYLD_LIBRARY_PATH;
unset PYTHONPATH;
unset CPATH;
unset MANPATH;
if [ "$(uname)" == "Darwin" ]; then
echo -n
# OE_EXPORT_MODE=prepend oe-export- /usr/local/foreign;
else
if [ "$(uname)" == "Linux" ]; then
local sh=$JUNOTOP/bashrc.sh;
[ -f "$sh" ] && source $sh;
fi;
fi
}
oe-find()
{
local pkg=${1:-G4}
echo pkg_config.py $pkg
pkg_config.py $pkg
echo find_package.py $pkg --nocache
find_package.py $pkg --nocache
}
oe-export-geant4()
{
if [ -z "$G4ENSDFSTATEDATA" ]; then
local g4prefix=$(opticks-config --prefix geant4)
local g4sh=$g4prefix/bin/geant4.sh
if [ -f "$g4sh" ]; then
echo $msg g4prefix $g4prefix g4sh $g4sh
source $g4sh
else
echo $msg g4prefix $g4prefix g4sh $g4sh FAILED
fi
fi
}
oe-export-misc()
{
export TMP=/tmp/$USER/opticks
export OPTICKS_EVENT_BASE=$TMP
export PATH=$(oe-home)/bin:$PATH
export PATH=$(oe-home)/ana:$PATH
}
oe-export-cuda()
{
# system PATH is assumed to have nvcc in it prior to opticks
[ "$(which nvcc)" == "" ] && return
local prefix=$(dirname $(dirname $(which nvcc)))
case $(uname) in
Linux) oe-append LD_LIBRARY_PATH $prefix/lib64 $prefix/lib ;;
Darwin) oe-append DYLD_LIBRARY_PATH $prefix/lib64 $prefix/lib ;;
esac
}
oe-export()
{
: appends standard prefixes to CMAKE_PREFIX_PATH and pkgconfig paths to PKG_CONFIG_PATH and exports them;
oe-export-setup-artificial-env;
OE_EXPORT_MODE=append oe-export- $(oe-prefix) $(oe-prefix)/externals;
OE_EXPORT_MODE=append oe-export- $(oe-prefix)/externals/OptiX
oe-prepend PATH $(oe-prefix)/lib
oe-prepend PATH $(oe-prefix)/bin
oe-prepend PATH $(oe-home)/bin
oe-prepend PATH $(oe-home)/ana
# nasty source tree dirs in PATH
oe-export-geant4
oe-export-cuda
oe-export-misc
}
oe-export-notes ()
{
cat <<EON
append
less precedence to the dir
preprend
more precedence to the dir
previously opticks-export did the below ...
with PATHs from both installed and source trees
with source tree ana and bin taking precedence.
This seems unhealthy.
opticks-path-add $(opticks-prefix)/lib;
opticks-path-add $(opticks-prefix)/bin;
opticks-path-add $(opticks-home)/bin;
opticks-path-add $(opticks-home)/ana;
opticksdata-;
opticksdata-export
EON
}
oe-unset()
{
unset CMAKE_PREFIX_PATH;
unset PKG_CONFIG_PATH;
unset LD_LIBRARY_PATH;
unset DYLD_LIBRARY_PATH;
unset PYTHONPATH;
unset CPATH;
unset MANPATH;
}
oe-append()
{
local var=$1
shift
local dir
for dir in $* ; do
[ -d "$dir" ] && oe-append- $var $dir
done
}
oe-prepend()
{
local var=$1
shift
local dir
for dir in $* ; do
[ -d "$dir" ] && oe-prepend- $var $dir
done
}
oe-append-()
{
local var=${1:-PATH}
local dir=${2:-/tmp}
local l=:
if [ -z "${!var}" ]; then
eval $var=$dir;
else
[[ "$l${!var}$l" != *"$l${dir}$l"* ]] && eval $var=${!var}$l$dir;
fi
}
oe-prepend-()
{
local var=${1:-PATH};
local dir=${2:-/tmp};
local l=:
if [ -z "${!var}" ]; then
eval $var=$dir;
else
[[ "$l${!var}$l" != *"$l${dir}$l"* ]] && eval $var=$dir$l${!var};
fi
}
oe-info ()
{
echo CMAKE_PREFIX_PATH;
echo $CMAKE_PREFIX_PATH | tr ":" "\n";
echo PKG_CONFIG_PATH;
echo $PKG_CONFIG_PATH | tr ":" "\n";
if [ "$(uname)" == "Linux" ]; then
echo LD_LIBRARY_PATH;
echo $LD_LIBRARY_PATH | tr ":" "\n";
else
if [ "$(uname)" == "Darwin" ]; then
echo DYLD_LIBRARY_PATH;
echo $DYLD_LIBRARY_PATH | tr ":" "\n";
fi;
fi;
echo PYTHONPATH;
echo $PYTHONPATH | tr ":" "\n";
echo PATH;
echo $PATH | tr ":" "\n"
}