-
Notifications
You must be signed in to change notification settings - Fork 0
/
opticks.bash.old
188 lines (141 loc) · 3.47 KB
/
opticks.bash.old
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
# huh : this imperfectly duplicates om-subs--all
opticks-all-projs-(){ cat << EOP
sysrap
brap
npy
okc
ggeo
asirap
openmeshrap
okg
oglrap
cudarap
thrap
oxrap
okop
okgl
ok
cfg4
okg4
EOP
}
opticks-cuda-projs-(){ cat << EOP
cudarap
thrap
oxrap
okop
okgl
EOP
}
opticks---(){
local arg=${1:-all}
local proj
opticks-${arg}-projs- | while read proj ; do
[ -z "$proj" ] && continue
$proj-
$proj--
done
}
opticks----(){
## proj--- touches the API header and then does $proj-- : this forcing recompilation of everything
local arg=${1:-all}
local proj
opticks-${arg}-projs- | while read proj ; do
[ -z "$proj" ] && continue
$proj-
echo proj $proj
$proj---
done
}
opticks-list()
{
local arg=${1:-all}
local proj
opticks-${arg}-projs- | while read proj ; do
[ -z "$proj" ] && continue
echo proj $proj
done
}
opticks-idfold(){ echo $(dirname $IDPATH) ; }
opticks-srcpath(){ echo $(opticks-idpath2srcpath $IDPATH) ; }
opticks-srcfold(){ echo $(dirname $(opticks-srcpath)) ; }
#opticks-srcextras(){ echo $(opticks-idfold)/extras ; } # layout 0
opticks-srcextras(){ echo $(opticks-srcfold)/extras ; } # layout 1
opticks-join(){ local ifs=$IFS ; IFS="$1"; shift; echo "$*" ; IFS=$ifs ; }
opticks-idpath-notes(){ cat << EON
$FUNCNAME
===============================
NB THIS IS THE DEPRECATED OLD WAY OF DOING THINGS
The srcpath if obtained from the IDPATH envvar using
opticks-idpath2srcpath which is the bash equivalant
of the C++ brap-/BPath and python base/bpath.py
IDPATH : $IDPATH
opticks-srcpath : $(opticks-srcpath)
opticks-srcfold : $(opticks-srcfold)
opticks-srcextras : $(opticks-srcextras)
opticks-tbool-path 0 : $(opticks-tbool-path 0)
opticks-nnt-path 0 : $(opticks-nnt-path 0)
EON
}
opticks-idpath2srcpath()
{
local idpath=$1
local ifs=$IFS
local elem
IFS="/"
declare -a elem=($idpath)
IFS=$ifs
local nelem=${#elem[@]}
local last=${elem[$nelem-1]} ## -ve indices requires bash 4.3+
#echo nelem $nelem last $last
IFS="."
declare -a bits=($last)
IFS=$ifs
local nbits=${#bits[@]}
local idfile
local srcdigest
local idname
local prefix
if [ "$nbits" == "3" ] ; then
idfile=$(opticks-join . ${bits[0]} ${bits[2]})
srcdigest=${bits[1]}
idname=${elem[$nelem-2]}
prefix=$(opticks-join / ${elem[@]:0:$nelem-4})
#echo triple idfile $idfile srcdigest $srcdigest idname $idname prefix $prefix
else
srcdigest=${elem[$nelem-2]}
idfile=${elem[$nelem-3]}
idname=${elem[$nelem-4]}
prefix=$(opticks-join / ${elem[@]:0:$nelem-5})
#echo not triple idfile $idfile srcdigest $srcdigest idname $idname prefix $prefix
fi
local srcpath=$(opticks-join / "" $prefix "opticksdata" "export" $idname $idfile)
IFS=$ifs
echo $srcpath
}
opticks-idpath2srcpath-test-one()
{
local v=$IDPATH
local s=$(opticks-idpath2srcpath $v)
printf "%40s %40s \n" $v $s
local s2=$(opticks-idpath2srcpath $v)
printf "%40s %40s \n" $v $s2
}
opticks-idpath2srcpath-test()
{
local ifs=$IFS
local line
local kv
env | grep IDPATH | while read line
do
IFS="="
declare -a kv=($line)
IFS=$ifs
if [ ${#kv[@]} == "2" ]; then
local k=${kv[0]}
local v=${kv[1]}
local s=$(opticks-idpath2srcpath $v)
printf "%10s %40s %40s \n" $k $v $s
fi
done
}