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")")"
20 VPP Build Configuration Script
26 --arch, -a Cross-compile for specified target architecture (aarch64, riscv64, i386, ...)
27 --build-dir, -b Build directory
28 --install-dir, -i Install directory
29 --build-type, -t Build type (release, debug, ...)
30 --wipe, -w Wipe whole repo (except startup.* files)
41 if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
45 echo "Error: Argument for $1 is missing" >&2
50 if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
54 echo "Error: Argument for $1 is missing" >&2
59 if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
63 echo "Error: Argument for $1 is missing" >&2
68 if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
72 echo "Error: Argument for $1 is missing" >&2
80 -*|--*=) # unsupported flags
81 echo "Error: Unsupported flag $1" >&2
84 *) # preserve positional arguments
91 if [ "${arch}" != "${host_arch}" ] ; then
92 args+=("-DCMAKE_SYSTEM_NAME=Linux")
93 args+=("-DCMAKE_SYSTEM_PROCESSOR=${arch}")
94 args+=("-DCMAKE_C_COMPILER=clang")
95 args+=("-DCMAKE_C_COMPILER_TARGET=${arch}-linux-gnu")
96 args+=("-DCMAKE_ASM_COMPILER_TARGET=${arch}-linux-gnu")
97 args+=("-DCMAKE_FIND_ROOT_PATH=/usr/${arch}-linux-gnu")
98 args+=("-DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER")
99 args+=("-DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=BOTH")
100 args+=("-DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=BOTH")
101 args+=("-DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ONLY")
104 args+=("-DCMAKE_PREFIX_PATH=/opt/vpp/external/${arch}")
105 args+=("-DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=ON")
106 args+=("-DCMAKE_INSTALL_PREFIX=${install_dir}")
107 args+=("-DCMAKE_BUILD_TYPE:STRING=${build_type}")
109 [ "${wipe}" == "yes" ] && git clean -fdx --exclude=startup.\*
111 cmake ${args[@]} -G Ninja -S ${src_dir}/src -B ${build_dir}
115 Useful build commands:
118 ninja set-build-type-* Change build type to <debug|release|gcov|...>
119 ninja config Start build configuration TUI
120 ninja run Runs VPP using startup.conf in the build directory
121 ninja debug Runs VPP inside GDB using startup.conf in the build directory
122 ninja pkg-deb Create .deb packages
123 ninja install Install VPP to $install_dir