blob: 384cfcf956e46af0a1b646edc7fc86114a993464 [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)/
11
12help()
13{
14 cat << __EOF__
15VPP Build Configuration Script
16
17USAGE: ${0} [options]
18
19OPTIONS:
20 --help, -h This help
21 --build-dir, -b Build directory
22 --install-dir, -i Install directory
23 --type, -t Build type (release, debug, ... )
24 --wipe, -w Wipe whole repo (except startup.* files)
25__EOF__
26}
27
28while (( "$#" )); do
29 case "$1" in
30 -h|--help)
31 help
32 exit 1
33 ;;
34 -b|--build-dir)
35 if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
36 build_dir=$2
37 shift 2
38 else
39 echo "Error: Argument for $1 is missing" >&2
40 exit 1
41 fi
42 ;;
43 -i|--install-dir)
44 if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
45 install_dir=$2
46 shift 2
47 else
48 echo "Error: Argument for $1 is missing" >&2
49 exit 1
50 fi
51 ;;
52 -t|--build-type)
53 if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
54 build_type=$2
55 shift 2
56 else
57 echo "Error: Argument for $1 is missing" >&2
58 exit 1
59 fi
60 ;;
61 -w|--wipe)
62 git clean -fdx --exclude=startup.\*
63 exit 1
64 ;;
65 -*|--*=) # unsupported flags
66 echo "Error: Unsupported flag $1" >&2
67 exit 1
68 ;;
69 *) # preserve positional arguments
70 PARAMS="$PARAMS $1"
71 shift
72 ;;
73 esac
74done
75
76cmake \
77 -G Ninja \
78 -S src \
79 -B ${build_dir} \
80 -DCMAKE_PREFIX_PATH=${prefix_path} \
81 -DCMAKE_INSTALL_PREFIX=${install_dir} \
82 -DCMAKE_BUILD_TYPE:STRING=${build_type}
83
84 cat << __EOF__
85
86 Useful build commands:
87
Damjan Marion3a533cd2021-05-03 12:40:27 +020088 ninja Build VPP
89 ninja set-build-type-* Change build type to <debug|release|gcov|...>
90 ninja config Start build configuration TUI
91 ninja compdb Generate compile_commands.json
92 ninja run Runs VPP using startup.conf in the build directory
93 ninja debug Runs VPP inside GDB using startup.conf in the build directory
94 ninja pkg-deb Create .deb packages
95 ninja install Install VPP to $install_dir
Damjan Marion88b2e362021-04-29 18:47:25 +020096
97__EOF__