-
Notifications
You must be signed in to change notification settings - Fork 0
/
om.bash
1373 lines (1022 loc) · 30.9 KB
/
om.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
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
##
## Copyright (c) 2019 Opticks Team. All Rights Reserved.
##
## This file is part of Opticks
## (see https://bitbucket.org/simoncblyth/opticks).
##
## Licensed under the Apache License, Version 2.0 (the "License");
## you may not use this file except in compliance with the License.
## You may obtain a copy of the License at
##
## http://www.apache.org/licenses/LICENSE-2.0
##
## Unless required by applicable law or agreed to in writing, software
## distributed under the License is distributed on an "AS IS" BASIS,
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
## See the License for the specific language governing permissions and
## limitations under the License.
##
om-source(){ echo $BASH_SOURCE ; }
om-vi(){ vi $(om-source) ; }
om-env(){ olocal- ; opticks- ;
local msg="=== $FUNCNAME :"
if [ "$1" == "quiet" -o "$1" == "q" -o -n "$OPTICKS_QUIET" ]; then
#echo $msg quiet running
oe- 2> /dev/null
else
echo $msg normal running
oe- ;
fi
}
om-usage(){ cat << EOU
OM : Opticks Minimal Approach to Configuring and Building
===========================================================
The below subproj functions configure, build, install or test
either one, all or a range of Opticks subprojects
in the appropriate dependency order.
The commands are sensitive to the invoking directory, performing
actions for all subprojects when invoked from top level
directories. Also an argument can be used to select a
starting subproject, eg "cudarap:" starts from there
or ":" starts from the subproject of the current directory.
When building for the first time it is necessary to
use "om-install" as later subprojects cannot be configured
until earlier ones have been installed.
Usage Examples
---------------
om-subs okconf:opticksgeo
list the subprojects in this inclusive range
om-subs :opticksgeo
same as the above, as first is implicit
om-test :opticksgeo
run the tests for all subprojects from the first okconf upto opticksgeo
Partial test running
----------------------
::
TESTARG="-R U4TreeCreate" om-test ## runs just the tests with that pattern
TESTARG="-E U4TreeTest" om-test ## exclude the regexp tests
The TESTARG is included on the ctest command line, see ctest --help
Real World Usage
------------------
::
ggeo # change directory to ggeo
okc # change directory to optickscore
vi OpticksSwitches.h
om # build just current dir project
om : # build current dir project and all subsequent
om + # build all subsequent proj (not including current)
## a bug preventing "om :" and "om +" from working has been fixed
om-subs : # list this project and all subsequent
om-subs + # list all subsequent projects
SUBPROJ FUNCTIONS
-----------------
om-subs
list subprojects in dependency order
om-conf
configures using cmake
om-make
build and install
om--
shorter name for om-make
om
even shorter function that does om-;om--
om-install
configures, builds and installs by doing both om-conf and om-make
om-cleaninstall
cleans, configures, builds and installs by doing om-clean, om-conf and om-make
om-prefix-clean
really deep clean that deletes the dirs within opticks-prefix : lib lib64 include build
after that it is necessary to om-install
om-test
runs ctests
om-visit
visits each subproj in turn
om-echo
echos the pwd of each subproj
OTHER FUNCTIONS
-----------------
om-cd
cd from a source tree directory to the corresponding
directory in the build tree or vice versa
FUNCTIONS INSENSITIVE TO INVOKING DIRECTORY
-------------------------------------------------
om-visit-all
om-conf-all
om-make-all
om-test-all
om-testlog
parse test logs from previous test runs and present summary totals
EOU
}
om-home-default(){ echo $(dirname $(om-source)) ; }
om-home(){ echo ${OPTICKS_HOME:-$(om-home-default)} ; }
#om-local(){ echo ${LOCAL_BASE:-/usr/local} ; }
#om-name(){ echo $(basename $(om-home)) ; }
#om-fold(){ echo $(om-local)/$(om-name) ; }
#om-prefix(){ echo $(om-fold) ; }
# this is the crucial prefix : need a more obvious way to set it : OPTICKS_PREFIX envvar ?
om-prefix(){ echo ${OPTICKS_PREFIX:-/usr/local/opticks} ; }
om-pkg-config-path-reversed(){ $FUNCNAME- | python ; }
om-pkg-config-path-reversed-(){ cat << EPY
import os
dirs=os.environ["PKG_CONFIG_PATH"].split(":")
print(":".join(reversed(dirs)))
EPY
}
om-pkg-config-path(){ $FUNCNAME- | python ; }
om-pkg-config-path-(){ cat << EPY
import os
dirs=[]
for pfx in os.environ["CMAKE_PREFIX_PATH"].split(":"):
for lib in ["lib","lib64"]:
libdir = os.path.join(pfx,lib)
if os.path.isdir(libdir): # judge on libdir not pkgconfig dir as need to create initially for some
dirs.append(os.path.join(libdir, "pkgconfig"))
break # second sub:lib64 ignored if there is a lib
pass
pass
print(":".join(dirs))
EPY
}
om-prefix-clean-dirs-(){ cat << EOD
lib
lib64
build
include
EOD
}
om-prefix-clean-notes(){ cat << EON
See notes/issues/CMake_dependency_include_dirs_issue_reported_by_Hans.rst
If users report CMake dependency issues, the cause might not be due to CMake
but rather due to failures to include stale headers. In order to find
these bad inclusions a deeper clean than om-cleaninstall is needed.
In that case use::
om-prefix-clean
EON
}
om-prefix-clean(){
local msg="=== $FUNCNAME :"
cd $(om-prefix)
pwd
local dirs=$(om-prefix-clean-dirs-)
echo $msg om-prefix : $(om-prefix)
echo $msg pwd : $(pwd)
echo $msg om-prefix-clean-dirs- : $dirs
local ans
read -p "$msg enter YES to proceed with deletion of prefix dirs : " ans
if [ "$ans" == "YES" ]; then
local cmd
for dir in $dirs ; do
cmd="rm -rf $dir"
echo $cmd
eval $cmd
done
else
echo $msg SKIPPED
fi
}
#om-cmake-generator(){ echo $(opticks-cmake-generator) ; }
om-cmake-generator(){ echo "Unix Makefiles" ; }
om-bdir-trim-tests()
{
local iwd=$(pwd)
local name=$(basename ${iwd/tests}) # trim tests to get name of subproj from tests folder or subproj folder
local bdir=$(om-bdir $name)
echo $bdir
}
om-bdir(){
: TODO separate bdir depending on Release/Debug so its faster to switch
local gen=$(om-cmake-generator)
case $gen in
"Unix Makefiles") echo $(om-prefix)/build/$1 ;;
"Xcode") echo $(om-prefix)/build_xcode/$1 ;;
esac
}
om-sdir(){
: TODO generalize current approach of just special casing pkg names, could use a naming convention jPMTSim
case $1 in
PMTSim) echo $HOME/j/$1 ;;
PMTFastSim) echo $HOME/j/$1 ;;
*) echo $(om-home)/$1 ;;
esac
}
om-bdir-real(){ echo $(realpath $(om-bdir)) ; }
om-sdir-real(){ echo $(realpath $(om-sdir)) ; }
om-url(){ echo http://bitbucket.org/simoncblyth/$(om-name)/src/$(om-rdir) ; }
om-open(){ open $(om-url) ; }
om-info(){ cat << EOI
om-home-default : $(om-home-default)
om-home : $(om-home) from OPTICKS_HOME envvar if defined
om-name : $(om-name)
om-local : $(om-local) from LOCAL_BASE envvar if defined
om-fold : $(om-fold)
om-prefix : $(om-prefix)
om-cmake-generator : $(om-cmake-generator)
om-bdir : $(om-bdir)
om-sdir : $(om-sdir)
CMAKE_PREFIX_PATH : $CMAKE_PREFIX_PATH
PKG_CONFIG_PATH : $PKG_CONFIG_PATH
EOI
}
om-subs--old(){ cat << EOS
#yoctoglrap
#assimprap
#openmeshrap
#opticksgeo
#cudarap
#thrustrap
#optixrap
#okop
#oglrap
#opticksgl
#ok
#cfg4
#okg4
#g4ok
#integration
EOS
}
om-subs--all(){ cat << EOS
# to update this list : opticks-deps --subdirs
# the names must be the case correct directory names
okconf
sysrap
#boostrap
#npy
#optickscore
#ggeo
#extg4
ana
analytic
bin
CSG
#CSG_GGeo
#GeoChain
qudarap
gdxml
u4
CSGOptiX
g4cx
EOS
}
om-subs-minimal-notes(){ cat << EON
om-subs-minimal
================
Minimimal package build of Opticks intended to facilitate
loading from separately created geocache and OptiX 7 rendering.
This is convenient for use on nodes which are difficult to work with.
HMM: it would not be too difficuly move some optickscore
functionality down to sysrap, which would allow
the following three pkgs to be skipped
boostrap
npy
optickscore
Started this in sysrap/SOpticks
Also could skip building most of the tests to speed up the build alot
EON
}
om-subs--minimal(){ cat << EOS
okconf
sysrap
boostrap
npy
optickscore
CSG
qudarap
CSGOptiX
EOS
}
om-subs-thoughts(){ cat << EOS
okconf # not enough functionality, TODO: merge into sysrap
sysrap
boostrap # REMOVE
npy # REMOVE
optickscore # REMOVE
ggeo # REMOVE
extg4 # REMOVE
ana
analytic
bin
CSG
CSG_GGeo # REMOVE
GeoChain # REMOVE
qudarap
gdxml
u4
CSGOptiX
g4cx
EOS
}
om-subs-alt-notes(){ cat << EON
TODO:
* need to generalize om/opticks-deps machinery to work with new OptiX7 chain of sub pkgs,
so far have been manually building them and relying on the old chain too using
new pkg shortcuts : c, cg, qu, cx
* subs are pkg directory names, some new pkgs dirs not using lowercase convention
* have been avoiding boostrap and npy dependency in new developments
moving instead to sysrap/NP and SPath but have been using optickscore and ggeo
* BUT, it will take considerable effort to migrate away from
boostrap and npy usage in ggeo and elsewhere, not worthwhile currently
* using an envvar OM_ALT to signal that the alt pkgs should be
appended to the usual list seems like a good approach ..
because of minimal disruption as needs no new base functions.
* actually could just add to standard pkgs all but CSGOptiX
which needs special handling for OptiX7 b7 building ?
* could make building of CSGOptiX dependent on OPTICKS_OPTIX7_PREFIX being defined ?
hmm : not quite so simple still building it with Six swap without 7
When working on the new pkgs only starting from CSG, build just those with::
c
om : # colon means build this pkg and subsequent
cx
./b7
EON
}
om-alt(){ om-subs--alt ; }
om-subs--alt(){ cat << EOS
CSG
CSG_GGeo
GeoChain
qudarap
CSGOptiX
EOS
}
om-subs--()
{
case ${OM_SUBS:-all} in
all) om-subs--all ;;
minimal) om-subs--minimal ;;
alt) om-subs--alt ;;
esac
}
om-subs-(){ om-subs-- | grep -v ^\# ; }
om-subs-notes(){ cat << EON
om-subs
--------
Default with no argument lists all subproject directory names
in build dependency order. Arguments can be used to select
ranges of names.
Shorthand forms ":" and "+" only work from within a subproj
which is taken as the first, all other forms work from anywhere.
:
subproj from current onwards
+
subproj from next onwards
:last
subprojects from the first "okconf" to the last specified inclusive,
eg ":ok" lists all up to and including "ok"
first:last
subprojects from the "first" to "last" inclusive
EON
}
om-subs(){
local arg=$1
[ -z "$arg" ] && om-subs- && return
## without argument just return the hardcoded list, with argument returns selection from the list
local iwd=$(pwd)
local name=$(basename $iwd)
local mode=":"
local first
local last
## expand shorthand argument into full
[ "$arg" == ":" ] && arg="${name}:" && mode=":"
[ "$arg" == "+" ] && arg="${name}:" && mode="+"
## form ":last" means from okconf (1st project)
[ "${arg:0:1}" == ":" ] && first="okconf" || first=${arg/:*}
last=${arg/*:}
#echo $FUNCNAME arg $arg name $name first $first last $last
local sel=0
local sub
om-subs- | while read sub ; do
[ "${sub}" == "$first" -a "${mode}" == ":" ] && sel=1
[ "${sub}" == "$first" -a "${mode}" == "+" ] && sel=2
[ "$sel" == "1" ] && echo $sub
[ "${sub}" == "$last" -a "${mode}" == ":" ] && sel=0
[ "$sel" == "2" ] && sel=1
done
}
om-subs0(){
local arg=$1
local iwd=$(pwd)
local name=$(basename $iwd)
if [ -z "$arg" ]; then
om-subs-
else
[ "$arg" == ":" ] && arg="${name}:"
[ "$arg" == "+" ] && arg="${name}+"
local sel=0
local sub
om-subs- | while read sub ; do
[ "${sub}:" == "$arg" ] && sel=1
[ "${sub}+" == "$arg" ] && sel=2
[ "$sel" == "1" ] && echo $sub
[ "$sel" == "2" ] && sel=1
done
fi
}
om-reldir()
{
local cwd=$(pwd)
local sdir=$(om-sdir)
local bdir=$(om-bdir)
case $cwd in
$sdir*) echo ${cwd/$sdir} ;;
$bdir*) echo ${cwd/$bdir} ;;
esac
}
om-bcd(){ cd $(om-bdir $(om-reldir)) ; pwd ; }
om-scd(){ cd $(om-sdir $(om-reldir)) ; pwd ; }
om-visit-all(){ om-all ${FUNCNAME/-all} $* ; return $? ; }
om-conf-all(){ om-all ${FUNCNAME/-all} $* ; return $? ; }
om-make-all(){ om-all ${FUNCNAME/-all} $* ; return $? ; }
om-install-all(){ om-all ${FUNCNAME/-all} $* ; return $? ; }
om-cleaninstall-all(){ om-all ${FUNCNAME/-all} $* ; return $? ; }
om-test-all(){ om-all ${FUNCNAME/-all} $* ; om-testlog ; return $? ; }
om-echo-all(){ om-all ${FUNCNAME/-all} $* ; return $? ; }
om-clean-all(){ om-all ${FUNCNAME/-all} $* ; return $? ; }
om-find-all(){ om-all ${FUNCNAME/-all} $* ; return $? ; }
om-testlog(){ CTestLog.py $(om-bdir) $* ; }
om-conf-xcode(){ OPTICKS_CMAKE_GENERATOR=Xcode om-conf ; }
om-conf(){ om-one-or-all conf $* ; return $? ; }
om-make(){ om-one-or-all make $* ; return $? ; }
om-install(){ om-one-or-all install $* ; return $? ; }
om-cleaninstall(){ om-one-or-all cleaninstall $* ; return $? ; }
om-visit(){ om-one-or-all visit $* ; return $? ; }
om-test-help(){ cat << EOH
om-test-help
-------------
NB : are now running each test via test runners such as::
STestRunner.sh
CSGTestRunner.sh
To rerun selected tests use CTESTARG to change the ctest commandline,
for example using the "-R" regexp option eg::
CTESTARG="-R U4TreeCreateTest" om-test
CTESTARG="-R U4TreeCreate" om-test
Or directly use ctest for more control::
st # cd ~/opticks/sysrap/tests
ct # cd ~/opticks/CSG/tests
qt # cd ~/opticks/qudarap/tests
u4t # cd ~/opticks/u4/tests
cxt # cd ~/opticks/CSGOptiX/tests
gxt # cd ~/opticks/g4cx/tests
om-cd # cd to build directory (eg /usr/local/opticks/build/CSG/tests)
ctest -N # list tests
ctest -R U4TreeCreateTest --output-on-failure # run tests matching a pattern
ctest --help # to see the possibilities
To rebuild a test and rerun it use::
TEST=SBndTest om-t # NB no environment setup : so only for very simple tests
To run a test with the debugger within the test runner environment,
pick the appropriate runner for the package of the test and use a command
such as::
CSGTestRunner.sh "gdb CSGFoundry_CreateFromSimTest"
NB this and ctest running uses the installed test runners, so
must install before changes to runners take effect.
EOH
}
om-test(){
local rc=0
#om-testenv-push
om-one-or-all test $*
rc=$?
#om-testenv-pop
#om-test-help # call this from opticks-t- to avoid repetition
return $rc
}
om-echo(){ om-one-or-all echo $* ; return $? ; }
om-clean(){ om-one-or-all clean $* ; return $? ; }
om-find(){ om-one-or-all find $* ; return $? ; }
om--(){ om-make $* ; } ## just this proj
om---(){ om-make-all : ; } ## all projs from this one onwards
om----(){ om-make-all + ; } ## all projs following this one
om-testenv-notes(){ cat << EON
om-testenv-notes
------------------
TRYING TO USE BASH RUNNERS INSTEAD OF THIS, AS THAT PLAYS
BETTER WITH CTEST INSTALLED TESTS
EON
}
om-testenv-vars(){ echo BASH_SOURCE FUNCNAME OM_KEEP_GEOM GEOM OPTICKS_T_GEOM ; }
om-testenv-dump(){
local pfx="$1"
if [ -z "$QUIET" ]; then
local fmt="$pfx %20s : %s \n"
local vars="$(om-testenv-vars)"
local var ; for var in $vars ; do printf "$fmt" "$var" "${!var}" ; done
fi
}
om-testenv-push()
{
om-testenv-dump "[push"
export OM_KEEP_GEOM=$GEOM
local geom_script=$HOME/.opticks/GEOM/GEOM.sh
if [ -s $geom_script ]; then
source $geom_script
# script is expected to always set GEOM
# and perhaps set OPTICKS_T_GEOM
fi
export GEOM=${OPTICKS_T_GEOM:-$GEOM}
om-testenv-dump "]push"
}
om-testenv-pop()
{
om-testenv-dump "[pop "
if [ -n "$OM_KEEP_GEOM" ] ; then
export GEOM=$OM_KEEP_GEOM
unset OM_KEEP_GEOM
else
unset GEOM
fi
om-testenv-dump "]pop "
}
om-check()
{
local msg="=== $FUNCNAME :"
local bdir=$(om-bdir)
local rc=0
if [ ! -d "$bdir" ]; then
echo $msg top level bdir $bdir does not exist : creating it
mkdir -p $bdir
fi
if [ ! -d "$bdir" ]; then
echo $msg top level bdir $bdir does not exist : create failed
rc=1
fi
return $rc
}
om-all-notes(){ cat << EON
om-all-notes
==============
om-all runs the func passed in the argument
in each of the sub-package bdir
EON
}
om-all()
{
local rc
local iwd=$(pwd)
local func=$1
local msg="=== $FUNCNAME $func :"
shift
om-check
rc=$?
[ "$rc" != "0" ] && echo $msg ERROR om-check failed && return $rc
local subs=$(om-subs $*) # need to accept the argument to handle :/+ for building from here onwards
local name
: switched to for loop is easier for error propagation than piping
for name in $subs
do
local sdir=$(om-sdir $name)
local bdir=$(om-bdir $name)
mkdir -p $bdir
local udir
: only om-find needs sdir the others need bdir
case $func in
om-find) udir=$sdir ;;
*) udir=$bdir ;;
esac
cd $udir
$func
rc=$?
[ "$rc" != "0" ] && echo $msg ERROR bdir $bdir : non-zero rc $rc && return $rc
done
cd $iwd
return $rc
}
om-one-or-all()
{
local rc=0
local func=$1
local arg=$2 # not normally used
local iwd=$(pwd)
local msg="=== $FUNCNAME $func :"
om-check
rc=$?
[ "$rc" != "0" ] && echo $msg ERROR om-check failed && om-info && return $rc
if [ "${iwd}/" == "$(om-sdir)" -o "${iwd}/" == "$(om-bdir)" -o "${arg/:}" != "$arg" -o "${arg/+}" != "$arg" ]; then
om-$func-all $arg
rc=$?
else
om-$func-one $arg
rc=$?
fi
if [ "$rc" != "0" ]; then
echo $msg non-zero rc $rc
fi
cd $iwd
return $rc
}
om-echo-one(){ echo $(pwd) ; }
om-install-one()
{
om-visit-one $*
om-conf-one $*
om-make-one $*
}
om-cleaninstall-one()
{
om-clean-one $*
om-visit-one $*
om-conf-one $*
om-make-one $*
}
om-visit-one()
{
local msg="=== $FUNCNAME :"
local iwd=$(pwd)
local name=$(basename $iwd)
local sdir=$(om-sdir $name)
local bdir=$(om-bdir $name)
if [ ! -d "$bdir" ]; then
echo $msg bdir $bdir does not exist : creating it
mkdir -p $bdir
fi
cd $bdir
printf "%s %-15s %-60s %-60s \n" "$msg" $name $sdir $bdir
}
om-conf-one()
{
local arg=$1
local iwd=$(pwd)
local name=$(basename ${iwd/tests}) # trim tests to get name of subproj from tests folder or subproj folder
local sdir=$(om-sdir $name)
local bdir=$(om-bdir $name) # TODO: different bdir for each build type
if [ "$arg" == "clean" ]; then
echo $msg removed bdir $bdir as directed by clean argument
rm -rf $bdir
fi
if [ ! -d "$bdir" ]; then
echo $msg bdir $bdir does not exist : creating it
mkdir -p $bdir
fi
cd $bdir
printf "%s %-15s %-60s %-60s \n" "$msg" $name $sdir $bdir
local rc=0
if [ "$name" == "okconf" ]; then
om-cmake-okconf $sdir
rc=$?
else
om-cmake $sdir
rc=$?
fi
return $rc
}
om-cmake-okconf()
{
local sdir=$1
local bdir=$PWD
[ "$sdir" == "$bdir" ] && echo ERROR sdir and bdir are the same $sdir && return 1000
local rc
cmake $sdir \
-G "$(om-cmake-generator)" \
-DCMAKE_BUILD_TYPE=$(opticks-buildtype) \
-DOPTICKS_PREFIX=$(om-prefix) \
-DCMAKE_INSTALL_PREFIX=$(om-prefix) \
-DCMAKE_MODULE_PATH=$(om-home)/cmake/Modules \
-DOptiX_INSTALL_DIR=$(opticks-optix-prefix) \
-DCOMPUTE_CAPABILITY=$(opticks-compute-capability)
# TODO: arrange for this and om-cmake to merge
# NB not pinning CMAKE_PREFIX_PATH so can find foreigners, see oe-
rc=$?
return $rc
}
om-cmake()
{
local sdir=$1
local bdir=$PWD
[ "$sdir" == "$bdir" ] && echo ERROR sdir and bdir are the same $sdir && return 1000
local rc
cmake $sdir \
-G "$(om-cmake-generator)" \
-DCMAKE_BUILD_TYPE=$(opticks-buildtype) \
-DOPTICKS_PREFIX=$(om-prefix) \
-DCMAKE_INSTALL_PREFIX=$(om-prefix) \
-DCMAKE_MODULE_PATH=$(om-home)/cmake/Modules
# -DCMAKE_FIND_DEBUG_MODE=1 \
# NB not pinning CMAKE_PREFIX_PATH so can find foreigners, see oe-
rc=$?
return $rc
}
om-cmake-dump(){ local sdir=${1:-sdir} ; cat << EOD
cmake $sdir \\
-G "$(om-cmake-generator)" \\
-DCMAKE_BUILD_TYPE=$(opticks-buildtype) \\
-DOPTICKS_PREFIX=$(om-prefix) \\
-DCMAKE_INSTALL_PREFIX=$(om-prefix) \\
-DCMAKE_MODULE_PATH=$(om-home)/cmake/Modules
om-cmake-generator : $(om-cmake-generator)
opticks-buildtype : $(opticks-buildtype)
om-prefix : $(om-prefix)
om-home : $(om-home)
EOD
}
om-cmake-info(){ cat << EOI
$FUNCNAME
===============
om-cmake-generator : $(om-cmake-generator)
opticks-buildtype : $(opticks-buildtype)
om-prefix : $(om-prefix)
OPTICKS_OPTIX5_PREFIX : $OPTICKS_OPTIX5_PREFIX
OPTICKS_OPTIX6_PREFIX : $OPTICKS_OPTIX6_PREFIX
OPTICKS_OPTIX7_PREFIX : $OPTICKS_OPTIX7_PREFIX
OPTICKS_OPTIX_PREFIX : $OPTICKS_OPTIX_PREFIX
opticks-optix-prefix : $(opticks-optix-prefix)
opticks-compute-capability : $(opticks-compute-capability)
OPTICKS_COMPUTE_CAPABILITY : $OPTICKS_COMPUTE_CAPABILITY
NODE_TAG : $NODE_TAG
EOI
}
om-nproc(){
case $(uname) in
Linux) echo ${OM_NPROC:-$(nproc)} ;;
Darwin) echo 2 ;;
esac
}
om-make-one()
{
local rc=0
local iwd=$(pwd)
local msg="=== $FUNCNAME :"
local name=$(basename ${iwd/tests}) # trim tests to get name of subproj from tests folder or subproj folder
local sdir=$(om-sdir $name)
local bdir=$(om-bdir $name)
printf "%s %-15s %-60s %-60s \n" "$msg" $name $sdir $bdir
if [ ! -d $bdir ]; then
echo $msg ERROR bdir $bdir does not exist : you need to om-install OR om-conf once before using om-make or the om-- shortcut
rc=1
return $rc
fi
if [ ! -f $bdir/Makefile ]; then
echo $msg ERROR bdir $bdir exists but does not contain a Makefile : you need to om-install OR om-conf once before using om-make or the om-- shortcut
rc=2
return $rc
fi
cd $bdir
local t0=$(date +"%s")
local pr=$(om-nproc)
if [ $pr -gt 1 ]; then
make all -j$pr
else
cmake --build . --target all
fi
rc=$?
local t1=$(date +"%s")