1 | #!/bin/bash
|
---|
2 | ARCH_DIR=build_$(uname -m)
|
---|
3 | NB_THREADS=$(nproc)
|
---|
4 | from_scratch=no
|
---|
5 |
|
---|
6 | function green_echo () {
|
---|
7 | echo -e "\033[32m$1\033[0m"
|
---|
8 | }
|
---|
9 |
|
---|
10 | function red_echo () {
|
---|
11 | echo -e "\033[31m$1\033[0m"
|
---|
12 | }
|
---|
13 |
|
---|
14 | function check_error () {
|
---|
15 | if [ "$?" != "0" ]; then
|
---|
16 | red_echo "Error, exiting"
|
---|
17 | exit 1
|
---|
18 | fi
|
---|
19 | }
|
---|
20 |
|
---|
21 | function sanity_check () {
|
---|
22 | if [ -z $FLAIR_ROOT ]; then
|
---|
23 | red_echo "You must set the FLAIR_ROOT environement variable"
|
---|
24 | exit 1
|
---|
25 | fi
|
---|
26 | }
|
---|
27 |
|
---|
28 | function configure () {
|
---|
29 | if [ "$from_scratch" = "yes" ]; then
|
---|
30 | green_echo "Configuring $1/$2"
|
---|
31 | cd $1/$2
|
---|
32 |
|
---|
33 | if [ -f cmake_codeblocks.sh ]; then
|
---|
34 | green_echo "only configuring it for $(uname -m)"
|
---|
35 | ./cmake_codeblocks.sh > /dev/null
|
---|
36 | else
|
---|
37 | rm -f build_arm/CMakeCache.txt
|
---|
38 | $FLAIR_ROOT/flair-dev/scripts/cmake_codeblocks.sh > /dev/null
|
---|
39 | fi
|
---|
40 |
|
---|
41 | check_error
|
---|
42 | else
|
---|
43 | green_echo "Not configuring $1/$2"
|
---|
44 | fi
|
---|
45 | }
|
---|
46 |
|
---|
47 | function cross_compile () {
|
---|
48 | if ! [ -f $1/$2/cmake_codeblocks.sh ]; then
|
---|
49 | green_echo "Cross compiling and installing $2"
|
---|
50 | cd $1/$2/build_arm
|
---|
51 | if [ "$from_scratch" = "yes" ]; then make clean > /dev/null; fi
|
---|
52 | make -j$NB_THREADS > /dev/null
|
---|
53 | check_error
|
---|
54 | make install
|
---|
55 | fi
|
---|
56 | }
|
---|
57 |
|
---|
58 | function compile () {
|
---|
59 | green_echo "Compiling and installing $2"
|
---|
60 | cd $1/$2/$ARCH_DIR
|
---|
61 | if [ "$from_scratch" = "yes" ]; then make clean > /dev/null; fi
|
---|
62 | make -j$NB_THREADS > /dev/null
|
---|
63 | check_error
|
---|
64 | make install
|
---|
65 | }
|
---|
66 |
|
---|
67 | function compile_flair() {
|
---|
68 | for projects in FlairCore FlairSensorActuator; do
|
---|
69 | # for projects in FlairCore FlairSensorActuator FlairFilter FlairMeta FlairSimulator ; do
|
---|
70 | configure $FLAIR_ROOT/flair-src/lib $projects
|
---|
71 | compile $FLAIR_ROOT/flair-src/lib $projects
|
---|
72 | cross_compile $FLAIR_ROOT/flair-src/lib $projects
|
---|
73 | done
|
---|
74 | }
|
---|
75 |
|
---|
76 | function compile_examples() {
|
---|
77 | for projects in ex_framework ex_kalman_framework; do
|
---|
78 | configure $FLAIR_ROOT/uav_ex $projects
|
---|
79 | compile $FLAIR_ROOT/uav_ex $projects
|
---|
80 | cross_compile $FLAIR_ROOT/uav_ex $projects
|
---|
81 | done
|
---|
82 |
|
---|
83 | for projects in ex_opencv; do
|
---|
84 | configure $FLAIR_ROOT/uav_ex $projects
|
---|
85 | compile $FLAIR_ROOT/uav_ex $projects
|
---|
86 | cross_compile $FLAIR_ROOT/uav_ex $projects
|
---|
87 | done
|
---|
88 |
|
---|
89 | for projects in control simulator; do
|
---|
90 | configure $FLAIR_ROOT/uav_ex/ex_simulator_framework $projects
|
---|
91 | compile $FLAIR_ROOT/uav_ex/ex_simulator_framework $projects
|
---|
92 | cross_compile $FLAIR_ROOT/uav_ex/ex_simulator_framework $projects
|
---|
93 | done
|
---|
94 |
|
---|
95 | for projects in simulator uav; do
|
---|
96 | configure $FLAIR_ROOT/uav_ex/demo_optitrack_framework $projects
|
---|
97 | compile $FLAIR_ROOT/uav_ex/demo_optitrack_framework $projects
|
---|
98 | cross_compile $FLAIR_ROOT/uav_ex/demo_optitrack_framework $projects
|
---|
99 | done
|
---|
100 |
|
---|
101 | for projects in simulator uav; do
|
---|
102 | configure $FLAIR_ROOT/uav_ex/demo_fo_framework $projects
|
---|
103 | compile $FLAIR_ROOT/uav_ex/demo_fo_framework $projects
|
---|
104 | cross_compile $FLAIR_ROOT/uav_ex/demo_fo_framework $projects
|
---|
105 | done
|
---|
106 |
|
---|
107 | for projects in simulator uav; do
|
---|
108 | configure $FLAIR_ROOT/uav_ex/demo_flotte_framework $projects
|
---|
109 | compile $FLAIR_ROOT/uav_ex/demo_flotte_framework $projects
|
---|
110 | cross_compile $FLAIR_ROOT/uav_ex/demo_flotte_framework $projects
|
---|
111 | done
|
---|
112 |
|
---|
113 | for projects in uav; do
|
---|
114 | configure $FLAIR_ROOT/uav_ex/demo_ligne_framework $projects
|
---|
115 | compile $FLAIR_ROOT/uav_ex/demo_ligne_framework $projects
|
---|
116 | cross_compile $FLAIR_ROOT/uav_ex/demo_ligne_framework $projects
|
---|
117 | done
|
---|
118 |
|
---|
119 | for projects in CustomReferenceAngles CustomTorques; do
|
---|
120 | configure $FLAIR_ROOT/uav_ex/skeletons_framework $projects
|
---|
121 | compile $FLAIR_ROOT/uav_ex/skeletons_framework $projects
|
---|
122 | cross_compile $FLAIR_ROOT/uav_ex/skeletons_framework $projects
|
---|
123 | done
|
---|
124 | }
|
---|
125 |
|
---|
126 | sanity_check
|
---|
127 |
|
---|
128 | printf "Compile all from scratch [Y/n]?"
|
---|
129 | read answer
|
---|
130 |
|
---|
131 | if [ "$answer" = "" ] || [ "$answer" = "y" ] || [ "$answer" = "Y" ]; then
|
---|
132 | from_scratch=yes
|
---|
133 | fi
|
---|
134 |
|
---|
135 | printf "Compile Flair libs [Y/n]?"
|
---|
136 | read answer
|
---|
137 |
|
---|
138 | if [ "$answer" = "" ] || [ "$answer" = "y" ] || [ "$answer" = "Y" ]; then
|
---|
139 | compile_flair
|
---|
140 | fi
|
---|
141 | exit 0
|
---|
142 | printf "Compile Flair tools [Y/n]?"
|
---|
143 | read answer
|
---|
144 |
|
---|
145 | if [ "$answer" = "" ] || [ "$answer" = "y" ] || [ "$answer" = "Y" ]; then
|
---|
146 | compile_tools
|
---|
147 | fi
|
---|
148 |
|
---|
149 | printf "Compile Flair documentation [Y/n]?"
|
---|
150 | read answer
|
---|
151 |
|
---|
152 | if [ "$answer" = "" ] || [ "$answer" = "y" ] || [ "$answer" = "Y" ]; then
|
---|
153 | cd $FLAIR_ROOT/flair-src/lib
|
---|
154 | doxygen Doxyfile.in
|
---|
155 | fi
|
---|
156 |
|
---|
157 | printf "Compile examples [Y/n]?"
|
---|
158 | read answer
|
---|
159 |
|
---|
160 | if [ "$answer" = "" ] || [ "$answer" = "y" ] || [ "$answer" = "Y" ]; then
|
---|
161 | compile_examples
|
---|
162 | fi
|
---|
163 |
|
---|
164 | exit 0
|
---|