forked from lnotspotl/tbai
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtbai.bash
executable file
·95 lines (80 loc) · 2.04 KB
/
tbai.bash
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
89
90
91
92
93
94
95
#!/usr/bin/env bash
function print_help() {
echo "Usage: ./tbai [--format|--lint|--build|--test|--docs|--rebuild_docs]"
}
function lint() {
folders=$(ls -d */| grep -v dependencies)
for folder in $folders; do
cpplint --recursive $folder
done
}
function format() {
folders=$(ls -d */| grep -v dependencies)
for folder in $folders; do
for file in $(find $folder -name "*.hpp" -o -name "*.cpp"); do
echo "[TBAI] Formatting $file"
clang-format -i -style=file $file
done
done
}
function build() {
folders=$(ls -d */| grep -v dependencies)
ros_packages=""
# in each folder check whether package.xml and CMakeLists.txt exist
for folder in $folders; do
if [[ -f $folder/CMakeLists.txt ]] && [[ -f $folder/package.xml ]]; then
package=$(basename $folder)
ros_packages+=" $package"
fi
done
echo "[TBAI] Building ROS packages: $ros_packages"
catkin build $ros_packages
}
function test() {
folders=$(ls -d */| grep -v dependencies)
ros_packages=""
# for each folder, check where test folder exists
for folder in $folders; do
if [[ -d $folder/test ]]; then
echo "[TBAI] Running tests in $folder"
package=$(basename $folder)
ros_packages+=" $package"
fi
done
echo "[TBAI] Running tests for ROS packages: $ros_packages"
catkin test $ros_packages
}
function open_docs() {
script_dir=$(dirname "$0")
docs_dir=${script_dir}/../../build/tbai_docs/output/doxygen/html/index.html
google-chrome $docs_dir
}
if [[ "$1" == "--help" || "$1" == "-h" || -z "$1" ]]; then
print_help
exit
fi
if [[ "$1" == "--lint" ]]; then
lint
exit
fi
if [[ "$1" == "--format" ]]; then
format
exit
fi
if [[ "$1" == "--build" ]]; then
build
exit
fi
if [[ "$1" == "--test" ]]; then
test
exit
fi
if [[ "$1" == "--docs" ]]; then
open_docs
exit
fi
if [[ "$1" == "--rebuild_docs" ]]; then
catkin clean tbai_docs
catkin build tbai_docs
fi
print_help