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