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