forked from cepc/CEPCSW
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-k4.sh
executable file
·122 lines (99 loc) · 2.79 KB
/
build-k4.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
113
114
115
116
117
118
119
120
121
122
#!/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() {
# source /cvmfs/sw.hsf.org/key4hep/setup.sh
source /cvmfs/sw-nightlies.hsf.org/key4hep/setup.sh
# fix the order of compiler
local ccdir=$(dirname $CC)
export PATH=$ccdir:$PATH
}
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 "${k4_version}" ]; then
blddir=${blddir}.${k4_version}
fi
if [ -n "${k4_platform}" ]; then
blddir=${blddir}.${k4_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
# locate the pandorapfa
local pandorapfa=$(echo $CMAKE_PREFIX_PATH | tr ':' '\n' | grep pandorapfa | head -n1)
info: "Find PandoraPFA: $pandorapfa"
if [ -z "$pandorapfa" ]; then
error: "Failed to find the PandoraPFA"
return 1
fi
local pandorapfa_cmake_modules=${pandorapfa}/cmakemodules
info: "Find PandoraPFA cmake: ${pandorapfa_cmake_modules}"
if [ ! -d "${pandorapfa_cmake_modules}" ]; then
error: "Failed to find the cmake modules for PandoraPFA: ${pandorapfa_cmake_modules}"
return 1
fi
local cmake_modules=${pandorapfa_cmake_modules}
cmake .. -DHOST_BINARY_TAG=${k4_platform} ${bldgen} \
-DCMAKE_MODULE_PATH=${cmake_modules} || {
error: "Failed to cmake"
return 1
}
}
function run-make() {
cmake --build .
}
##############################################################################
# Parse the command line options
##############################################################################
# The current default platform
k4_platform=x86_64-linux-gcc11-opt
k4_version=master
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