[2] | 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
|
---|
[3] | 38 | $FLAIR_ROOT/flair-dev/scripts/cmake_codeblocks.sh > /dev/null
|
---|
[2] | 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 |
|
---|
[26] | 67 | function compile_libs() {
|
---|
[8] | 68 | for projects in FlairCore FlairSensorActuator FlairFilter FlairMeta FlairSimulator ; do
|
---|
[2] | 69 | configure $FLAIR_ROOT/flair-src/lib $projects
|
---|
[3] | 70 | compile $FLAIR_ROOT/flair-src/lib $projects
|
---|
[2] | 71 | cross_compile $FLAIR_ROOT/flair-src/lib $projects
|
---|
| 72 | done
|
---|
[26] | 73 |
|
---|
| 74 | if [ -d $FLAIR_ROOT/flair-hds ]; then
|
---|
| 75 | for projects in FlairArdrone2 VisionFilter; do
|
---|
| 76 | configure $FLAIR_ROOT/flair-hds/src/lib $projects
|
---|
| 77 | compile $FLAIR_ROOT/flair-hds/src/lib $projects
|
---|
| 78 | cross_compile $FLAIR_ROOT/flair-hds/src/lib $projects
|
---|
| 79 | done
|
---|
| 80 | fi
|
---|
[2] | 81 | }
|
---|
| 82 |
|
---|
[9] | 83 | function compile_tools() {
|
---|
[35] | 84 | for projects in FlairGCS Controller/DualShock3 Controller/Mavlink Dbt2csv; do
|
---|
[9] | 85 | configure $FLAIR_ROOT/flair-src/tools $projects
|
---|
| 86 | compile $FLAIR_ROOT/flair-src/tools $projects
|
---|
| 87 | cross_compile $FLAIR_ROOT/flair-src/tools $projects
|
---|
| 88 | done
|
---|
| 89 | }
|
---|
| 90 |
|
---|
[23] | 91 | function compile_uav_and_simulator_demo() {
|
---|
| 92 | for projects in simulator uav; do
|
---|
[26] | 93 | configure $1/$2 $projects
|
---|
| 94 | compile $1/$2 $projects
|
---|
| 95 | cross_compile $1/$2 $projects
|
---|
[23] | 96 | done
|
---|
| 97 | }
|
---|
| 98 |
|
---|
[9] | 99 | function compile_demos() {
|
---|
[12] | 100 | for projects in Sinus; do
|
---|
| 101 | configure $FLAIR_ROOT/flair-src/demos $projects
|
---|
| 102 | compile $FLAIR_ROOT/flair-src/demos $projects
|
---|
| 103 | cross_compile $FLAIR_ROOT/flair-src/demos $projects
|
---|
[2] | 104 | done
|
---|
[14] | 105 |
|
---|
[34] | 106 | for projects in CircleFollower SimpleFleet Gps; do
|
---|
[26] | 107 | compile_uav_and_simulator_demo $FLAIR_ROOT/flair-src/demos $projects
|
---|
[14] | 108 | done
|
---|
| 109 |
|
---|
[27] | 110 | for projects in CustomReferenceAngles CustomTorques; do
|
---|
| 111 | configure $FLAIR_ROOT/flair-src/demos/Skeletons $projects
|
---|
| 112 | compile $FLAIR_ROOT/flair-src/demos/Skeletons $projects
|
---|
| 113 | cross_compile $FLAIR_ROOT/flair-src/demos/Skeletons $projects
|
---|
| 114 | done
|
---|
| 115 |
|
---|
[26] | 116 | if [ -d $FLAIR_ROOT/flair-hds ]; then
|
---|
| 117 | for projects in OpticalFlow; do
|
---|
| 118 | compile_uav_and_simulator_demo $FLAIR_ROOT/flair-hds/src/demos $projects
|
---|
| 119 | done
|
---|
| 120 | fi
|
---|
| 121 |
|
---|
[12] | 122 | exit 0
|
---|
[26] | 123 |
|
---|
[2] | 124 |
|
---|
| 125 | for projects in uav; do
|
---|
| 126 | configure $FLAIR_ROOT/uav_ex/demo_ligne_framework $projects
|
---|
| 127 | compile $FLAIR_ROOT/uav_ex/demo_ligne_framework $projects
|
---|
| 128 | cross_compile $FLAIR_ROOT/uav_ex/demo_ligne_framework $projects
|
---|
| 129 | done
|
---|
| 130 |
|
---|
[27] | 131 |
|
---|
[2] | 132 | }
|
---|
| 133 |
|
---|
| 134 | sanity_check
|
---|
| 135 |
|
---|
| 136 | printf "Compile all from scratch [Y/n]?"
|
---|
| 137 | read answer
|
---|
| 138 |
|
---|
| 139 | if [ "$answer" = "" ] || [ "$answer" = "y" ] || [ "$answer" = "Y" ]; then
|
---|
| 140 | from_scratch=yes
|
---|
| 141 | fi
|
---|
| 142 |
|
---|
| 143 | printf "Compile Flair libs [Y/n]?"
|
---|
| 144 | read answer
|
---|
| 145 |
|
---|
| 146 | if [ "$answer" = "" ] || [ "$answer" = "y" ] || [ "$answer" = "Y" ]; then
|
---|
[26] | 147 | compile_libs
|
---|
[2] | 148 | fi
|
---|
[9] | 149 |
|
---|
[14] | 150 | printf "Compile Flair libs documentation [Y/n]?"
|
---|
| 151 | read answer
|
---|
| 152 |
|
---|
| 153 | if [ "$answer" = "" ] || [ "$answer" = "y" ] || [ "$answer" = "Y" ]; then
|
---|
[23] | 154 | $OECORE_HOST_NATIVE_SYSROOT/usr/bin/doxygen $FLAIR_ROOT/flair-src/lib/Doxyfile.in
|
---|
[14] | 155 | fi
|
---|
| 156 |
|
---|
[2] | 157 | printf "Compile Flair tools [Y/n]?"
|
---|
| 158 | read answer
|
---|
| 159 |
|
---|
| 160 | if [ "$answer" = "" ] || [ "$answer" = "y" ] || [ "$answer" = "Y" ]; then
|
---|
| 161 | compile_tools
|
---|
| 162 | fi
|
---|
[12] | 163 |
|
---|
| 164 | printf "Compile demos [Y/n]?"
|
---|
| 165 | read answer
|
---|
| 166 |
|
---|
| 167 | if [ "$answer" = "" ] || [ "$answer" = "y" ] || [ "$answer" = "Y" ]; then
|
---|
| 168 | compile_demos
|
---|
| 169 | fi
|
---|
| 170 |
|
---|
[9] | 171 | exit 0
|
---|
[2] | 172 |
|
---|
| 173 |
|
---|
| 174 |
|
---|
| 175 | exit 0
|
---|