-
Notifications
You must be signed in to change notification settings - Fork 707
Expand file tree
/
Copy pathconfigure
More file actions
executable file
·256 lines (240 loc) · 6.53 KB
/
configure
File metadata and controls
executable file
·256 lines (240 loc) · 6.53 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
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
#!/usr/bin/env bash
set -o pipefail -o errtrace -o nounset -o errexit
# Experimental script, please consult with dmarion@me.com before
# submitting any changes
# defaults
platform=default
build_dir=.
install_dir=/usr/local
build_type=release
src_dir="$(dirname "$(readlink -f "$0")")"
host_arch=$(uname -m)
arch=${host_arch}
native_only=false
prefix_path="/opt/vpp/external/${arch}"
wipe=false
verbose=false
args=()
help()
{
cat << __EOF__
VPP Build Configuration Script
USAGE: ${0} [options]
OPTIONS:
--arch, -a Cross-compile for specified target architecture (aarch64, riscv64, i386, ...)
--build-dir, -b Build directory
--build-type, -t Build type (release, debug, ...)
--crypto-engines, -E Specify list of crypto engines to be built
--drivers, -D Specify list of drivers to be built
--help, -h This help
--install-dir, -i Install directory
--minimal, -m Minimal build (no plugins, tools, tests, crypto_engines)
--native-only, -n Only compile for Native CPU (no multiarch)
--option, -o Enable specific VPP options (fib8, fib16)
--platform, -p Specify target platform
--plugins, -P Specify list of plugins to be built
--prefix, -r Specify prefix path (default: $prefix_path)
--sanitize, -s Enable sanitizer (mem)
--tests, -S Specify list of tests to be built
--tools, -T Specify list of tools to be built
--verbose, -v Verbose output of this script
--wipe, -w Wipe whole repo (except startup.* files)
__EOF__
}
while (( "$#" )); do
case "$1" in
-h|--help)
help
exit 1
;;
-b|--build-dir)
if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
build_dir=$2
shift 2
else
echo "Error: Argument for $1 is missing" >&2
exit 1
fi
;;
-a|--arch)
if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
arch=$2
shift 2
else
echo "Error: Argument for $1 is missing" >&2
exit 1
fi
;;
-i|--install-dir)
if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
install_dir=$2
shift 2
else
echo "Error: Argument for $1 is missing" >&2
exit 1
fi
;;
-t|--build-type)
if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
build_type=$2
shift 2
else
echo "Error: Argument for $1 is missing" >&2
exit 1
fi
;;
-p|--platform)
if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
platform=$2
shift 2
else
echo "Error: Argument for $1 is missing" >&2
exit 1
fi
;;
-P|--plugins)
if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
plugins=$2
shift 2
else
echo "Error: Argument for $1 is missing" >&2
exit 1
fi
;;
-D|--drivers)
if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
drivers=$2
shift 2
else
echo "Error: Argument for $1 is missing" >&2
exit 1
fi
;;
-T|--tools)
if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
tools=$2
shift 2
else
echo "Error: Argument for $1 is missing" >&2
exit 1
fi
;;
-S|--tests)
if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
tests=$2
shift 2
else
echo "Error: Argument for $1 is missing" >&2
exit 1
fi
;;
-E|--crypto-engines)
if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
crypto_engines=$2
shift 2
else
echo "Error: Argument for $1 is missing" >&2
exit 1
fi
;;
-r|--prefix)
if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
prefix_path=$2
shift 2
else
echo "Error: Argument for $1 is missing" >&2
exit 1
fi
;;
-m|--minimal)
plugins=${plugins:-none}
tools=${tools:-none}
tests=${tests:-none}
crypto_engines=${crypto_engines:-none}
args+=("-DVPP_BUILD_PYTHON_API=OFF")
args+=("-DVPP_API_TEST_BUILTIN=OFF")
args+=("-DVPP_BUILD_VCL=OFF")
shift 1
;;
-n|--native-only)
native_only=true
shift 1
;;
-v|--verbose)
verbose=true
shift 1
;;
-w|--wipe)
wipe=true
shift 1
;;
-s|--sanitize)
shift 1
case "$1" in
mem)
shift 1
args+=("-DVPP_ENABLE_SANITIZE_ADDR=ON")
;;
esac
;;
-o|--option)
shift 1
case "$1" in
fib8)
shift 1
args+=("-DVPP_IP_FIB_MTRIE_16=OFF")
;;
fib16)
shift 1
args+=("-DVPP_IP_FIB_MTRIE_16=ON")
;;
esac
;;
-*|--*=) # unsupported flags
echo "Error: Unsupported flag $1" >&2
exit 1
;;
*) # preserve positional arguments
PARAMS="$PARAMS $1"
shift
;;
esac
done
if [ "${arch}" != "${host_arch}" ] ; then
args+=("-DCMAKE_SYSTEM_NAME=Linux")
args+=("-DCMAKE_SYSTEM_PROCESSOR=${arch}")
args+=("-DCMAKE_C_COMPILER=clang")
args+=("-DCMAKE_C_COMPILER_TARGET=${arch}-linux-gnu")
args+=("-DCMAKE_ASM_COMPILER_TARGET=${arch}-linux-gnu")
args+=("-DCMAKE_FIND_ROOT_PATH=/usr/${arch}-linux-gnu")
args+=("-DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER")
args+=("-DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=BOTH")
args+=("-DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=BOTH")
args+=("-DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ONLY")
fi
args+=("-DCMAKE_PREFIX_PATH=${prefix_path}")
args+=("-DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=ON")
args+=("-DCMAKE_INSTALL_PREFIX=${install_dir}")
args+=("-DCMAKE_BUILD_TYPE:STRING=${build_type}")
args+=("-DVPP_PLATFORM=${platform}")
$native_only && args+=("-DVPP_BUILD_NATIVE_ONLY:BOOL=ON")
$wipe && git clean -fdx --exclude=startup.\*
[[ -v plugins ]] && args+=("-DVPP_PLUGINS=${plugins}")
[[ -v drivers ]] && args+=("-DVPP_DRIVERS=${drivers}")
[[ -v tools ]] && args+=("-DVPP_TOOLS=${tools}")
[[ -v tests ]] && args+=("-DVPP_TESTS=${tests}")
[[ -v crypto_engines ]] && args+=("-DVPP_CRYPTO_ENGINES=${crypto_engines}")
(
$verbose && set -o xtrace
cmake ${args[@]} -G Ninja -S ${src_dir}/src -B ${build_dir}
)
cat << __EOF__
Useful build commands:
ninja Build VPP
ninja set-build-type-* Change build type to <debug|release|gcov|...>
ninja config Start build configuration TUI
ninja run Runs VPP using startup.conf in the build directory
ninja debug Runs VPP inside GDB using startup.conf in the build directory
ninja pkg-deb Create .deb packages
ninja install Install VPP to $install_dir
__EOF__