2 set -o pipefail -o errtrace -o nounset -o errexit
4 # Experimental script, please consult with dmarion@me.com before
5 # submitting any changes
10 install_dir=/usr/local
12 src_dir="$(dirname "$(readlink -f "$0")")"
22 VPP Build Configuration Script
28 --arch, -a Cross-compile for specified target architecture (aarch64, riscv64, i386, ...)
29 --build-dir, -b Build directory
30 --install-dir, -i Install directory
31 --build-type, -t Build type (release, debug, ...)
32 --native-only, -n Only compile for Native CPU (no multiarch)
33 --wipe, -w Wipe whole repo (except startup.* files)
34 --sanitize, -s Enable sanitizer (mem)
35 --platform, -p Specify target platform
36 --option, -o Enable specific VPP options (fib8, fib16)
47 if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
51 echo "Error: Argument for $1 is missing" >&2
56 if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
60 echo "Error: Argument for $1 is missing" >&2
65 if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
69 echo "Error: Argument for $1 is missing" >&2
74 if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
78 echo "Error: Argument for $1 is missing" >&2
83 if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
87 echo "Error: Argument for $1 is missing" >&2
104 args+=("-DVPP_ENABLE_SANITIZE_ADDR=ON")
113 args+=("-DVPP_IP_FIB_MTRIE_16=OFF")
117 args+=("-DVPP_IP_FIB_MTRIE_16=ON")
121 -*|--*=) # unsupported flags
122 echo "Error: Unsupported flag $1" >&2
125 *) # preserve positional arguments
132 if [ "${arch}" != "${host_arch}" ] ; then
133 args+=("-DCMAKE_SYSTEM_NAME=Linux")
134 args+=("-DCMAKE_SYSTEM_PROCESSOR=${arch}")
135 args+=("-DCMAKE_C_COMPILER=clang")
136 args+=("-DCMAKE_C_COMPILER_TARGET=${arch}-linux-gnu")
137 args+=("-DCMAKE_ASM_COMPILER_TARGET=${arch}-linux-gnu")
138 args+=("-DCMAKE_FIND_ROOT_PATH=/usr/${arch}-linux-gnu")
139 args+=("-DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER")
140 args+=("-DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=BOTH")
141 args+=("-DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=BOTH")
142 args+=("-DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ONLY")
145 args+=("-DCMAKE_PREFIX_PATH=/opt/vpp/external/${arch}")
146 args+=("-DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=ON")
147 args+=("-DCMAKE_INSTALL_PREFIX=${install_dir}")
148 args+=("-DCMAKE_BUILD_TYPE:STRING=${build_type}")
149 args+=("-DVPP_PLATFORM=${platform}")
150 [ "${native_only}" == "yes" ] && args+=("-DVPP_BUILD_NATIVE_ONLY:BOOL=ON")
152 [ "${wipe}" == "yes" ] && git clean -fdx --exclude=startup.\*
154 cmake ${args[@]} -G Ninja -S ${src_dir}/src -B ${build_dir}
158 Useful build commands:
161 ninja set-build-type-* Change build type to <debug|release|gcov|...>
162 ninja config Start build configuration TUI
163 ninja run Runs VPP using startup.conf in the build directory
164 ninja debug Runs VPP inside GDB using startup.conf in the build directory
165 ninja pkg-deb Create .deb packages
166 ninja install Install VPP to $install_dir