Damjan Marion | 88b2e36 | 2021-04-29 18:47:25 +0200 | [diff] [blame] | 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)/ |
Mohammed Hawari | 7d64631 | 2021-05-04 11:34:37 +0200 | [diff] [blame^] | 11 | src_dir="$(dirname "$(readlink -f "$0")")" |
Damjan Marion | 88b2e36 | 2021-04-29 18:47:25 +0200 | [diff] [blame] | 12 | |
| 13 | help() |
| 14 | { |
| 15 | cat << __EOF__ |
| 16 | VPP Build Configuration Script |
| 17 | |
| 18 | USAGE: ${0} [options] |
| 19 | |
| 20 | OPTIONS: |
| 21 | --help, -h This help |
| 22 | --build-dir, -b Build directory |
| 23 | --install-dir, -i Install directory |
| 24 | --type, -t Build type (release, debug, ... ) |
| 25 | --wipe, -w Wipe whole repo (except startup.* files) |
| 26 | __EOF__ |
| 27 | } |
| 28 | |
| 29 | while (( "$#" )); 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 |
| 75 | done |
| 76 | |
| 77 | cmake \ |
| 78 | -G Ninja \ |
Mohammed Hawari | 7d64631 | 2021-05-04 11:34:37 +0200 | [diff] [blame^] | 79 | -S ${src_dir}/src \ |
Damjan Marion | 88b2e36 | 2021-04-29 18:47:25 +0200 | [diff] [blame] | 80 | -B ${build_dir} \ |
| 81 | -DCMAKE_PREFIX_PATH=${prefix_path} \ |
| 82 | -DCMAKE_INSTALL_PREFIX=${install_dir} \ |
| 83 | -DCMAKE_BUILD_TYPE:STRING=${build_type} |
| 84 | |
| 85 | cat << __EOF__ |
| 86 | |
| 87 | Useful build commands: |
| 88 | |
Damjan Marion | 3a533cd | 2021-05-03 12:40:27 +0200 | [diff] [blame] | 89 | ninja Build VPP |
| 90 | ninja set-build-type-* Change build type to <debug|release|gcov|...> |
| 91 | ninja config Start build configuration TUI |
| 92 | ninja compdb Generate compile_commands.json |
| 93 | 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 Marion | 88b2e36 | 2021-04-29 18:47:25 +0200 | [diff] [blame] | 97 | |
| 98 | __EOF__ |