Skip to content

Commit 9fa638c

Browse files
committed
fix: clean up recently added build options
1 parent 3313b4a commit 9fa638c

File tree

2 files changed

+84
-41
lines changed

2 files changed

+84
-41
lines changed

.gitmodules

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
[submodule "etc/data/magfield"]
22
path = etc/data/magfield
3-
url = https://code.jlab.org/hallb/clas12/magfield
3+
url = https://code.jlab.org/hallb/clas12/magfield.git
44
[submodule "validation/advanced-tests/data"]
55
path = validation/advanced-tests/data
6-
url = https://code.jlab.org/hallb/clas12/coatjava/advanced-tests
6+
url = https://code.jlab.org/hallb/clas12/coatjava/advanced-tests.git
77
[submodule "etc/nnet"]
88
path = etc/data/nnet
9-
url = https://code.jlab.org/hallb/clas12/coatjava/networks
9+
url = https://code.jlab.org/hallb/clas12/coatjava/networks.git

build-coatjava.sh

Lines changed: 81 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ usage='''build-coatjava.sh [OPTIONS]... [MAVEN_OPTIONS]...
1414
--no-progress no download progress printouts
1515
--help show this message
1616
17-
OPTIONS FOR MAGNETIC FIELD MAPS
18-
--lfs use git-lfs for field maps and test data
19-
--cvmfs use cvmfs to download field maps
20-
--xrootd use xrootd to download field maps
17+
OPTIONS FOR MAGNETIC FIELD MAPS, NEURAL NETWORK MODELS, etc.
18+
--lfs use Git Large File Storage (requires `git-lfs`)
19+
--cvmfs use CernVM-FS (requires `/cvfms`)
20+
--xrootd use XRootD (requires `xrootd`)
2121
--nomaps do not download field maps
2222
2323
OPTIONS FOR TESTING
@@ -31,6 +31,10 @@ usage='''build-coatjava.sh [OPTIONS]... [MAVEN_OPTIONS]...
3131
-T4 will build with 4 parallel threads
3232
'''
3333

34+
################################################################################
35+
# parse arguments
36+
################################################################################
37+
3438
cleanBuild="no"
3539
anaDepends="no"
3640
runSpotBugs="no"
@@ -85,6 +89,10 @@ if ! [[ $(hostname) == *.jlab.org ]]; then
8589
useLfs=true
8690
fi
8791

92+
################################################################################
93+
# setup
94+
################################################################################
95+
8896
src_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd)"
8997
prefix_dir=$src_dir/coatjava
9098
clara_home=$src_dir/clara
@@ -97,26 +105,31 @@ wgetArgs+=(--timestamping --no-check-certificate) # `--timestamping` only redown
97105
mvn="mvn ${mvnArgs[@]:-}"
98106
wget="wget ${wgetArgs[@]:-}"
99107

108+
################################################################################
109+
# download field maps, NN models, etc.
110+
################################################################################
111+
100112
command_exists () {
101113
type "$1" &> /dev/null
102114
}
103-
download () {
115+
116+
download_lfs() {
117+
if command_exists git-lfs ; then
118+
cd $src_dir > /dev/null
119+
git lfs install
120+
git submodule update --init $1
121+
cd - > /dev/null
122+
else
123+
echo 'ERROR: `git-lfs` not found; please install it, or use a different option other than `--lfs`' >&2
124+
exit 1
125+
fi
126+
}
127+
128+
download_map () {
104129
ret=0
105130
if $useXrootd; then
106131
xrdcp $1 ./
107132
ret=$?
108-
elif $useLfs; then
109-
if command_exists git-lfs ; then
110-
cd $src_dir > /dev/null
111-
git lfs install
112-
git submodule update --init etc/data/magfield
113-
git submodule update --init etc/data/nnet
114-
if $downloadData; then git submodule update --init validation/advanced-tests/data; fi
115-
cd - > /dev/null
116-
else
117-
echo 'ERROR: `git-lfs` not found; please install it, or use a different option other than `--lfs`' >&2
118-
ret=1
119-
fi
120133
elif $useCvmfs; then
121134
cp -v $1 ./
122135
ret=$?
@@ -141,26 +154,46 @@ source libexec/env.sh --no-classpath
141154
magfield_dir=$src_dir/etc/data/magfield
142155
if [ $cleanBuild == "no" ] && [ $downloadMaps == "yes" ]; then
143156
echo 'Retrieving field maps ...'
144-
webDir=https://clasweb.jlab.org/clas12offline/magfield
145-
if $useLfs; then webDir=${magfield_dir##$src_dir}; fi
146-
if $useXrootd; then webDir=xroot://sci-xrootd.jlab.org//osgpool/hallb/clas12/coatjava/magfield; fi
147-
if $useCvmfs; then webDir=/cvmfs/oasis.opensciencegrid.org/jlab/hallb/clas12/sw/noarch/data/magfield; fi
148-
mkdir -p $magfield_dir
149-
cd $magfield_dir
150-
for map in $COAT_MAGFIELD_SOLENOIDMAP $COAT_MAGFIELD_TORUSMAP $COAT_MAGFIELD_TORUSSECONDARYMAP
151-
do
152-
download $webDir/$map
153-
if [ $? -ne 0 ]; then
154-
echo "ERROR::::::::::: Could not download field map:" >&2
155-
echo "$webDir/$map" >&2
156-
echo "One option is to download manually into etc/data/magfield and then run this build script with --nomaps" >&2
157-
exit 1
158-
fi
159-
$useLfs && break
160-
done
161-
cd -
157+
if $useLfs; then
158+
download_lfs etc/data/magfield
159+
else
160+
webDir=https://clasweb.jlab.org/clas12offline/magfield
161+
if $useXrootd; then webDir=xroot://sci-xrootd.jlab.org//osgpool/hallb/clas12/coatjava/magfield; fi
162+
if $useCvmfs; then webDir=/cvmfs/oasis.opensciencegrid.org/jlab/hallb/clas12/sw/noarch/data/magfield; fi
163+
mkdir -p $magfield_dir
164+
cd $magfield_dir
165+
for map in $COAT_MAGFIELD_SOLENOIDMAP $COAT_MAGFIELD_TORUSMAP $COAT_MAGFIELD_TORUSSECONDARYMAP
166+
do
167+
download_map $webDir/$map
168+
if [ $? -ne 0 ]; then
169+
echo "ERROR::::::::::: Could not download field map:" >&2
170+
echo "$webDir/$map" >&2
171+
echo "One option is to download manually into etc/data/magfield and then run this build script with --nomaps" >&2
172+
exit 1
173+
fi
174+
done
175+
cd -
176+
fi
177+
fi
178+
179+
# download neural networks
180+
if $useLfs; then
181+
download_lfs etc/data/nnet
182+
elif $useCvmfs; then
183+
cp -rv /cvmfs/oasis.opensciencegrid.org/jlab/hallb/clas12/sw/noarch/data/networks/* etc/data/nnet/
184+
else
185+
echo "WARNING: neural networks not downloaded" >&2
162186
fi
163187

188+
# download validation data
189+
if $downloadData; then
190+
download_lfs validation/advanced-tests/data
191+
fi
192+
193+
################################################################################
194+
# cleaning
195+
################################################################################
196+
164197
# always clean the installation prefix
165198
rm -rf $prefix_dir $clara_home
166199

@@ -171,13 +204,20 @@ if [ $cleanBuild == "yes" ]; then
171204
echo "WARNING: target directory '$target_dir' was not removed! JAR files within may be accidentally installed!" >&2
172205
done
173206
echo """DONE CLEANING.
174-
NOTE: if you want to remove locally downloaded magnetic field maps, run:
175-
rm $magfield_dir/*.dat
207+
NOTE:
208+
- to remove local magnetic field maps:
209+
rm $magfield_dir/*.dat
210+
- to clear all LFS git submodules:
211+
git submodule deinit --all
176212
177213
Now re-run without \`--clean\` to build."""
178214
exit
179215
fi
180216

217+
################################################################################
218+
# build
219+
################################################################################
220+
181221
# run dependency analysis and exit
182222
if [ $anaDepends == "yes" ]; then
183223
libexec/dependency-analysis.sh
@@ -215,7 +255,10 @@ if [ $runSpotBugs == "yes" ]; then
215255
if [ $? != 0 ] ; then echo "spotbugs failure" >&2 ; exit 1 ; fi
216256
fi
217257

218-
# installation
258+
################################################################################
259+
# install
260+
################################################################################
261+
219262
# NOTE: a maven plugin, such as `maven-assembly-plugin`, would be better, but it seems that they:
220263
# - require significantly more repetition of the module names and/or generation of additional XML file(s)
221264
# - seem to break thread safety of `mvn install`, i.e., we'd need to run `mvn package` first, then `mvn install`

0 commit comments

Comments
 (0)