This repository has been archived by the owner on May 25, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27
/
build.sh
executable file
·88 lines (78 loc) · 2.39 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/bin/bash
#
# Script for building the WARG computer-vision project
#
# Notes: the -c and -t parameters should not be removed
# since they are used by the jenkins server when buiding
#
# This file is part of WARG's computer-vision
#
# Copyright (c) 2015-2016, Waterloo Aerial Robotics Group (WARG)
# All rights reserved.
#
# This software is licensed under a modified version of the BSD 3 clause license
# that should have been included with this software in a file called COPYING.txt
# Otherwise it is available at:
# https://raw.githubusercontent.com/UWARG/computer-vision/master/COPYING.txt
#
WORKSPACE_DIR=
THREADS=1
CLEAN=false
TEST=false
INSTALL=false
BUILD_TYPE="Debug"
while getopts "c,t,h,i,d:,j:,r" opt; do
case $opt in
d)
WORKSPACE_DIR=$OPTARG
;;
c)
CLEAN=true
;;
t)
TEST=true
;;
i)
INSTALL=true
;;
j)
THREADS=$OPTARG
;;
r)
BUILD_TYPE="Release"
;;
h|\?)
printf "%s\n" "Usage: $0 [OPTIONS]" \
"Script to build the WARG computer-vision project"\
" Should either be run in the root of computer-vision or with the --dir option"\
" specifying the project root"\
" -c - removes previous build files before building" \
" -d [directory] - builds with the given dir as the project root" \
" -h - outputs this message" \
" -t - runs tests after building if build is successful"\
" -j [threads] - builds using the given number of threads"\
" default is 1 and is recommended for debugging"\
" -r - Sets the build type to release"
exit 1
;;
esac
done
if [ -z $WORKSPACE_DIR ]; then
WORKSPACE_DIR=`pwd`
fi
if [[ $CLEAN == true ]]; then
echo "Cleaning old build environment"
rm -rf $WORKSPACE_DIR/build
mkdir $WORKSPACE_DIR/build
fi
mkdir -p $WORKSPACE_DIR/build
cd $WORKSPACE_DIR/build
cmake .. -DCMAKE_BUILD_TYPE=$BUILD_TYPE && make -j$THREADS
RESULT=$?
if [[ $RESULT -eq 0 ]] && [[ $TEST == true ]] ; then
make test
fi
if [[ $RESULT -eq 0 ]] && [[ $INSTALL == true ]] ; then
sudo make install
fi
exit $RESULT