-
Notifications
You must be signed in to change notification settings - Fork 71
/
build.sh
executable file
·112 lines (89 loc) · 2.28 KB
/
build.sh
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
#!/bin/bash
##############################################################################
# Setup script for CEPCSW:
# - build the cepcsw
#
# Usage:
# $ bash build.sh
# or:
# $
#
# Author: Tao Lin <[email protected]>
##############################################################################
function info:() {
echo "INFO: $*" 1>&2
}
function error:() {
echo "ERROR: $*" 1>&2
}
function check-cepcsw-envvar() {
# CEPCSWEXTERNAL is defined in /cvmfs/cepcsw.ihep.ac.cn/prototype/releases/externals/
if [ -z "${CEPCSWEXTERNAL}" ]; then
error: "The CEPCSW is not setup. Please source setup.sh."
return 1
fi
}
function build-dir() {
local blddir=build
if [ -n "${bldtool}" ]; then
blddir=${blddir}.${bldtool}
fi
# If detect the extra env var, append it to the build dir
if [ -n "${lcg_version}" ]; then
blddir=${blddir}.${lcg_version}
fi
if [ -n "${lcg_platform}" ]; then
blddir=${blddir}.${lcg_platform}
fi
echo $blddir
}
function check-working-builddir() {
local blddir=$(build-dir)
if [ ! -d "$blddir" ]; then
mkdir $blddir || {
error: "Failed to create $blddir"
return 1
}
fi
}
function run-cmake() {
local blddir=$(build-dir)
if [ ! -d "$blddir" ]; then
error: "Failed to create $blddir"
return 1
fi
local bldgen
if [ -n "$bldtool" ] ; then
case $bldtool in
ninja)
bldgen="-G Ninja"
;;
*)
;;
esac
fi
cd $blddir
cmake .. -DHOST_BINARY_TAG=${lcg_platform} ${bldgen} || {
error: "Failed to cmake"
return 1
}
}
function run-make() {
local njobs=-j$(nproc)
cmake --build . $njobs
}
function run-install() {
cmake --install .
}
##############################################################################
# Parse the command line options
##############################################################################
# The current default platform
lcg_platform=x86_64-centos7-gcc11-opt
lcg_version=103.0.2
bldtool=${CEPCSW_BLDTOOL} # make, ninja # set in env var
check-cepcsw-envvar || exit -1
check-working-builddir || exit -1
run-cmake || exit -1
run-make || exit -1
run-install || exit -1