2 set -o pipefail -o errtrace -o nounset -o errexit
4 # Experimental script, please consult with dmarion@me.com before
5 # submitting any changes
11 src_dir="$(dirname "$(readlink -f "$0")")"
21 VPP Build Configuration Script
27 --arch, -a Cross-compile for specified target architecture (aarch64, riscv64, i386, ...)
28 --build-dir, -b Build directory
29 --install-dir, -i Install directory
30 --build-type, -t Build type (release, debug, ...)
31 --native-only, -n Only compile for Native CPU (no multiarch)
32 --wipe, -w Wipe whole repo (except startup.* files)
33 --sanitize, -s Enable sanitizer (mem)
44 if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
48 echo "Error: Argument for $1 is missing" >&2
53 if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
57 echo "Error: Argument for $1 is missing" >&2
62 if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
66 echo "Error: Argument for $1 is missing" >&2
71 if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
75 echo "Error: Argument for $1 is missing" >&2
92 args+=("-DVPP_ENABLE_SANITIZE_ADDR=ON")
96 -*|--*=) # unsupported flags
97 echo "Error: Unsupported flag $1" >&2
100 *) # preserve positional arguments
107 if [ "${arch}" != "${host_arch}" ] ; then
108 args+=("-DCMAKE_SYSTEM_NAME=Linux")
109 args+=("-DCMAKE_SYSTEM_PROCESSOR=${arch}")
110 args+=("-DCMAKE_C_COMPILER=clang")
111 args+=("-DCMAKE_C_COMPILER_TARGET=${arch}-linux-gnu")
112 args+=("-DCMAKE_ASM_COMPILER_TARGET=${arch}-linux-gnu")
113 args+=("-DCMAKE_FIND_ROOT_PATH=/usr/${arch}-linux-gnu")
114 args+=("-DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER")
115 args+=("-DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=BOTH")
116 args+=("-DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=BOTH")
117 args+=("-DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ONLY")
120 args+=("-DCMAKE_PREFIX_PATH=/opt/vpp/external/${arch}")
121 args+=("-DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=ON")
122 args+=("-DCMAKE_INSTALL_PREFIX=${install_dir}")
123 args+=("-DCMAKE_BUILD_TYPE:STRING=${build_type}")
124 [ "${native_only}" == "yes" ] && args+=("-DVPP_BUILD_NATIVE_ONLY:BOOL=ON")
126 [ "${wipe}" == "yes" ] && git clean -fdx --exclude=startup.\*
128 cmake ${args[@]} -G Ninja -S ${src_dir}/src -B ${build_dir}
132 Useful build commands:
135 ninja set-build-type-* Change build type to <debug|release|gcov|...>
136 ninja config Start build configuration TUI
137 ninja run Runs VPP using startup.conf in the build directory
138 ninja debug Runs VPP inside GDB using startup.conf in the build directory
139 ninja pkg-deb Create .deb packages
140 ninja install Install VPP to $install_dir