-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenandbuild.sh
More file actions
executable file
·118 lines (89 loc) · 3.69 KB
/
genandbuild.sh
File metadata and controls
executable file
·118 lines (89 loc) · 3.69 KB
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
#!/bin/bash
help(){
cat <<EOF
Usage: genandbuid.sh DESTDIR
Generate code and copy it to DESTDIR (ROOT.jl top directory).
--force: force deletion of DESTDIR/src, DESTDIR/deps, and DESTDIR/Project.toml
--update: enable update mode
--rootfromenv: generate the code from the ROOT installation of the shell environment
instead of from ROOT_jll
--verbosity N: set wrapit verbosity level
--notest disable run of ROOT module tests
EOF
}
temp=`getopt -o h --long help,update,noclean,nobuild,notest,force,verbosity:,rootfromenv \
-n 'genandbuild.sh' -- "$@"`
if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
eval set -- "$temp"
unset gen_opts
unset updatemode
unset force
unset nobuild
unset rootfromenv
unset notest
while true ; do
case "$1" in
-h|--help) help; exit 0;;
--update) gen_opts="$gen_opts --update"; updatemode=y; shift;;
--noclean) gen_opts="$gen_opts --noclean"; shift;;
--force) force=y; shift;;
--nobuild) nobuild=y; shift;;
--notest) notest=y; shift;;
--rootfromenv) rootfromenv=y; shift;;
--verbosity) gen_opts="$gen_opts --verbosity $2"; shift 2;;
--) shift ; break ;; #end of options. It remains only the args.
*) echo "Internal error!" ; exit 1 ;;
esac
done
if [ $# != 1 ]; then
help
exit 1
fi
die(){
echo "$@" 1>&2
exit 1
}
rootjl="$1"
gendir="`pwd`"
if [ -z "$rootfromenv" ]; then
ROOTSYS="`julia --project="$gendir" -e 'import ROOT_jll; print(ROOT_jll.artifact_dir)'`"
[ $? != 0 -o -z "$ROOTSYS" ] && die "Failed to set ROOTSYS. Please check that ROOT_jll is in the Project.toml file of $rootjl project and that the project is instantiated."
[ -f "$ROOTSYS/bin/thisroot.sh" ] || die "File $ROOTSYS/bin/thisroot.sh. Failed to set ROOT environment."
source "$ROOTSYS/bin/thisroot.sh"
fi
root_version=`root-config --version`
if [ $? = 0 ]; then
echo "Code will be built for ROOT version $root_version"
else
die "root-config command not found. Make sure ROOT binary directory is included in the list defined by the environment variable PATH"
fi
[ -d "$rootjl" ] || mkdir "$rootjl" || die "Directory $rootjl not found. The passed argument must be a valid directory."
if [ "$force" = y ]; then
rm -r "$rootjl"/{src,deps,Project.toml}
else
dirs=""
for d in src deps Project.toml; do
[ -e "$rootjl/$d" ] && dirs="$dirs $d"
done
if [ -n "$dirs" ]; then
die "Directory $rootjl already contains $dirs. Please restart after removing this (these) file(s) or directory(ies). Alternatively the option --force can be used." 1>&2
fi
fi
[ "$updatemode" = y ] || rm -r build/
julia --project=. generate.jl $gen_opts || die "Failed to generate code"
cd "$rootjl" || die "Failed to enter directory $rootjl"
cp -a "$gendir/build/ROOT-$root_version/ROOT/"{src,deps,Project.toml} . || die "Failed to copy fails. Check input path in `basename "$myself"`"
[ -d misc ] || mkdir misc || die "Failed to create `pwd`/misc directory"
cp -a "$gendir/build/ROOT-$root_version/"{jlROOT-report.txt,jlROOT-veto.h,ROOT.wit} misc/
# src/ROOTdoc.jl needed to import ROOT
[ -f src/ROOTdoc.jl ] || touch src/ROOTdoc.jl
cmd='import Pkg; Pkg.resolve(); Pkg.instantiate(); import ROOTprefs; ROOTprefs.set_use_root_jll(false); ROOTprefs.set_ROOTSYS(nothing); import ROOT'
if [ "$notest" != y ]; then
cmd="$cmd; import Pkg; println(stderr, \"Run unit tests...\"); Pkg.test()"
fi
[ "$nobuild" = y ] || julia --project=. -e "$cmd"
cat <<EOF
**********************************************************************
Beware this script has modified the contents of '$rootjl' directory.
**********************************************************************
EOF