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