vlib: refactor trajectory trace debug feature
[vpp.git] / configure
1 #!/usr/bin/env bash
2
3 # Experimental script, please consult with dmarion@me.com before
4 # submitting any changes
5
6 # defaults
7 build_dir=.
8 install_dir=/usr/local
9 build_type=release
10 prefix_path=/opt/vpp/external/$(uname -m)/
11
12 help()
13 {
14   cat << __EOF__
15 VPP Build Configuration Script
16
17 USAGE: ${0} [options]
18
19 OPTIONS:
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
28 while (( "$#" )); 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
74 done
75
76 cmake \
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
88   ninja             Build VPP
89   ninja config      Start build configuration TUI
90   ninja compdb      Generate compile_commands.json
91   ninja run         Runs VPP using startup.conf in the build directory
92   ninja debug       Runs VPP inside GDB using startup.conf in the build directory
93   ninja pkg-deb     Create .deb packages
94   ninja install     Install VPP to $install_dir
95
96 __EOF__