1 | #!/bin/bash
|
---|
2 | NB_THREADS=$(nproc)
|
---|
3 | from_scratch=no
|
---|
4 | IDE_SCRIPT=cmake_codelite.sh
|
---|
5 | toolchains=($OECORE_CMAKE_TOOLCHAINS)
|
---|
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 | $FLAIR_ROOT/flair-dev/scripts/$IDE_SCRIPT > /dev/null
|
---|
35 |
|
---|
36 | check_error
|
---|
37 | else
|
---|
38 | green_echo "Not configuring $1/$2"
|
---|
39 | fi
|
---|
40 | }
|
---|
41 |
|
---|
42 | function compile () {
|
---|
43 | #iterate over available toolchains
|
---|
44 | for arch in ${toolchains[@]}; do
|
---|
45 | green_echo "Compiling and installing $2 for $arch"
|
---|
46 | cd $1/$2/build_$arch
|
---|
47 | if [ "$from_scratch" = "yes" ]; then make clean > /dev/null; fi
|
---|
48 | make -j$NB_THREADS > /dev/null
|
---|
49 | check_error
|
---|
50 | make install
|
---|
51 | done
|
---|
52 | }
|
---|
53 |
|
---|
54 | function compile_libs() {
|
---|
55 | for projects in FlairCore FlairSensorActuator FlairFilter FlairVisionFilter FlairMeta FlairSimulator ; do
|
---|
56 | configure $FLAIR_ROOT/flair-src/lib $projects
|
---|
57 | compile $FLAIR_ROOT/flair-src/lib $projects
|
---|
58 | done
|
---|
59 |
|
---|
60 | if [ -d $FLAIR_ROOT/flair-hds ]; then
|
---|
61 | for projects in FlairBebop FlairArdrone2 FlairMinidrones FlairMamboEdu VisionFilter; do
|
---|
62 | configure $FLAIR_ROOT/flair-hds/src/lib $projects
|
---|
63 | compile $FLAIR_ROOT/flair-hds/src/lib $projects
|
---|
64 | done
|
---|
65 | fi
|
---|
66 | }
|
---|
67 |
|
---|
68 | function compile_tools() {
|
---|
69 | for projects in FlairGCS Controller/DualShock3 Controller/Mavlink Dbt2csv VrpnBridge; do
|
---|
70 | configure $FLAIR_ROOT/flair-src/tools $projects
|
---|
71 | compile $FLAIR_ROOT/flair-src/tools $projects
|
---|
72 | done
|
---|
73 | }
|
---|
74 |
|
---|
75 | function compile_uav_and_simulator_demo() {
|
---|
76 | for projects in simulator uav; do
|
---|
77 | configure $1/$2 $projects
|
---|
78 | compile $1/$2 $projects
|
---|
79 | done
|
---|
80 | }
|
---|
81 |
|
---|
82 | function compile_demos() {
|
---|
83 | for projects in Sinus; do
|
---|
84 | configure $FLAIR_ROOT/flair-src/demos $projects
|
---|
85 | compile $FLAIR_ROOT/flair-src/demos $projects
|
---|
86 | done
|
---|
87 |
|
---|
88 | for projects in OpticalFlow CircleFollower SimpleFleet Gps PidStandalone; do
|
---|
89 | compile_uav_and_simulator_demo $FLAIR_ROOT/flair-src/demos $projects
|
---|
90 | done
|
---|
91 |
|
---|
92 | for projects in CustomReferenceAngles CustomTorques; do
|
---|
93 | configure $FLAIR_ROOT/flair-src/demos/Skeletons $projects
|
---|
94 | compile $FLAIR_ROOT/flair-src/demos/Skeletons $projects
|
---|
95 | done
|
---|
96 |
|
---|
97 | if [ -d $FLAIR_ROOT/flair-hds ]; then
|
---|
98 | for projects in ApriltagFollower LineFollower; do
|
---|
99 | compile_uav_and_simulator_demo $FLAIR_ROOT/flair-hds/src/demos $projects
|
---|
100 | done
|
---|
101 | fi
|
---|
102 |
|
---|
103 | }
|
---|
104 |
|
---|
105 | sanity_check
|
---|
106 |
|
---|
107 | if [ -d $FLAIR_ROOT/flair-hds ]; then
|
---|
108 | printf "Found flair-hds repository\n"
|
---|
109 | fi
|
---|
110 |
|
---|
111 | printf "Compile all from scratch [Y/n]?"
|
---|
112 | read answer
|
---|
113 |
|
---|
114 | if [ "$answer" = "" ] || [ "$answer" = "y" ] || [ "$answer" = "Y" ]; then
|
---|
115 | from_scratch=yes
|
---|
116 | fi
|
---|
117 |
|
---|
118 | printf "Compile Flair libs [Y/n]?"
|
---|
119 | read answer
|
---|
120 |
|
---|
121 | if [ "$answer" = "" ] || [ "$answer" = "y" ] || [ "$answer" = "Y" ]; then
|
---|
122 | compile_libs
|
---|
123 | fi
|
---|
124 |
|
---|
125 | printf "Compile Flair libs documentation [Y/n]?"
|
---|
126 | read answer
|
---|
127 |
|
---|
128 | if [ "$answer" = "" ] || [ "$answer" = "y" ] || [ "$answer" = "Y" ]; then
|
---|
129 | $OECORE_HOST_NATIVE_SYSROOT/usr/bin/doxygen $FLAIR_ROOT/flair-src/lib/Doxyfile.in
|
---|
130 | fi
|
---|
131 |
|
---|
132 | printf "Compile Flair tools [Y/n]?"
|
---|
133 | read answer
|
---|
134 |
|
---|
135 | if [ "$answer" = "" ] || [ "$answer" = "y" ] || [ "$answer" = "Y" ]; then
|
---|
136 | compile_tools
|
---|
137 | fi
|
---|
138 |
|
---|
139 | printf "Compile demos [Y/n]?"
|
---|
140 | read answer
|
---|
141 |
|
---|
142 | if [ "$answer" = "" ] || [ "$answer" = "y" ] || [ "$answer" = "Y" ]; then
|
---|
143 | compile_demos
|
---|
144 | fi
|
---|
145 |
|
---|
146 | exit 0
|
---|
147 |
|
---|
148 |
|
---|
149 |
|
---|
150 | exit 0
|
---|