blob: 978b71e5c61bcacf44486984c266d27733c53798 [file] [log] [blame]
Damjan Marion88b2e362021-04-29 18:47:25 +02001#!/usr/bin/env bash
Damjan Mariond63360c2021-05-28 17:32:58 +02002set -o pipefail -o errtrace -o nounset -o errexit
Damjan Marion88b2e362021-04-29 18:47:25 +02003
4# Experimental script, please consult with dmarion@me.com before
5# submitting any changes
6
7# defaults
8build_dir=.
9install_dir=/usr/local
10build_type=release
11prefix_path=/opt/vpp/external/$(uname -m)/
Mohammed Hawari7d646312021-05-04 11:34:37 +020012src_dir="$(dirname "$(readlink -f "$0")")"
Damjan Marion88b2e362021-04-29 18:47:25 +020013
14help()
15{
16 cat << __EOF__
17VPP Build Configuration Script
18
19USAGE: ${0} [options]
20
21OPTIONS:
22 --help, -h This help
23 --build-dir, -b Build directory
24 --install-dir, -i Install directory
Damjan Marion2e5544f2021-05-04 09:37:56 +020025 --build-type, -t Build type (release, debug, ...)
Damjan Marion88b2e362021-04-29 18:47:25 +020026 --wipe, -w Wipe whole repo (except startup.* files)
27__EOF__
28}
29
30while (( "$#" )); do
31 case "$1" in
32 -h|--help)
33 help
34 exit 1
35 ;;
36 -b|--build-dir)
37 if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
38 build_dir=$2
39 shift 2
40 else
41 echo "Error: Argument for $1 is missing" >&2
42 exit 1
43 fi
44 ;;
45 -i|--install-dir)
46 if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
47 install_dir=$2
48 shift 2
49 else
50 echo "Error: Argument for $1 is missing" >&2
51 exit 1
52 fi
53 ;;
54 -t|--build-type)
55 if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
56 build_type=$2
57 shift 2
58 else
59 echo "Error: Argument for $1 is missing" >&2
60 exit 1
61 fi
62 ;;
63 -w|--wipe)
64 git clean -fdx --exclude=startup.\*
65 exit 1
66 ;;
67 -*|--*=) # unsupported flags
68 echo "Error: Unsupported flag $1" >&2
69 exit 1
70 ;;
71 *) # preserve positional arguments
72 PARAMS="$PARAMS $1"
73 shift
74 ;;
75 esac
76done
77
78cmake \
79 -G Ninja \
Mohammed Hawari7d646312021-05-04 11:34:37 +020080 -S ${src_dir}/src \
Damjan Marion88b2e362021-04-29 18:47:25 +020081 -B ${build_dir} \
82 -DCMAKE_PREFIX_PATH=${prefix_path} \
83 -DCMAKE_INSTALL_PREFIX=${install_dir} \
Damjan Marion0d39cba2021-05-10 14:51:44 +020084 -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=ON \
Damjan Marion88b2e362021-04-29 18:47:25 +020085 -DCMAKE_BUILD_TYPE:STRING=${build_type}
86
87 cat << __EOF__
88
89 Useful build commands:
90
Damjan Marion3a533cd2021-05-03 12:40:27 +020091 ninja Build VPP
92 ninja set-build-type-* Change build type to <debug|release|gcov|...>
93 ninja config Start build configuration TUI
Damjan Marion3a533cd2021-05-03 12:40:27 +020094 ninja run Runs VPP using startup.conf in the build directory
95 ninja debug Runs VPP inside GDB using startup.conf in the build directory
96 ninja pkg-deb Create .deb packages
97 ninja install Install VPP to $install_dir
Damjan Marion88b2e362021-04-29 18:47:25 +020098
99__EOF__