| 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 | rm -f build_arm/CMakeCache.txt
|
---|
| 34 | $FLAIR_ROOT/flair-dev/scripts/cmake_codeblocks.sh > /dev/null
|
---|
| 35 |
|
---|
| 36 | check_error
|
---|
| 37 | else
|
---|
| 38 | green_echo "Not configuring $1/$2"
|
---|
| 39 | fi
|
---|
| 40 | }
|
---|
| 41 |
|
---|
| 42 | function cross_compile () {
|
---|
| 43 | green_echo "Cross compiling and installing $2"
|
---|
| 44 | cd $1/$2/build_arm
|
---|
| 45 | if [ "$from_scratch" = "yes" ]; then make clean > /dev/null; fi
|
---|
| 46 | make -j$NB_THREADS > /dev/null
|
---|
| 47 | check_error
|
---|
| 48 | make install
|
---|
| 49 | }
|
---|
| 50 |
|
---|
| 51 | function compile () {
|
---|
| 52 | green_echo "Compiling and installing $2"
|
---|
| 53 | cd $1/$2/$ARCH_DIR
|
---|
| 54 | if [ "$from_scratch" = "yes" ]; then make clean > /dev/null; fi
|
---|
| 55 | make -j$NB_THREADS > /dev/null
|
---|
| 56 | check_error
|
---|
| 57 | make install
|
---|
| 58 | }
|
---|
| 59 |
|
---|
| 60 | function compile_libs() {
|
---|
| 61 | for projects in FlairCore FlairSensorActuator FlairFilter FlairMeta FlairSimulator ; do
|
---|
| 62 | configure $FLAIR_ROOT/flair-src/lib $projects
|
---|
| 63 | compile $FLAIR_ROOT/flair-src/lib $projects
|
---|
| 64 | cross_compile $FLAIR_ROOT/flair-src/lib $projects
|
---|
| 65 | done
|
---|
| 66 |
|
---|
| 67 | if [ -d $FLAIR_ROOT/flair-hds ]; then
|
---|
| 68 | for projects in FlairArdrone2 VisionFilter; do
|
---|
| 69 | configure $FLAIR_ROOT/flair-hds/src/lib $projects
|
---|
| 70 | compile $FLAIR_ROOT/flair-hds/src/lib $projects
|
---|
| 71 | cross_compile $FLAIR_ROOT/flair-hds/src/lib $projects
|
---|
| 72 | done
|
---|
| 73 | fi
|
---|
| 74 | }
|
---|
| 75 |
|
---|
| 76 | function compile_tools() {
|
---|
| 77 | for projects in FlairGCS Controller/DualShock3 Controller/Mavlink Dbt2csv; do
|
---|
| 78 | configure $FLAIR_ROOT/flair-src/tools $projects
|
---|
| 79 | compile $FLAIR_ROOT/flair-src/tools $projects
|
---|
| 80 | cross_compile $FLAIR_ROOT/flair-src/tools $projects
|
---|
| 81 | done
|
---|
| 82 | }
|
---|
| 83 |
|
---|
| 84 | function compile_uav_and_simulator_demo() {
|
---|
| 85 | for projects in simulator uav; do
|
---|
| 86 | configure $1/$2 $projects
|
---|
| 87 | compile $1/$2 $projects
|
---|
| 88 | cross_compile $1/$2 $projects
|
---|
| 89 | done
|
---|
| 90 | }
|
---|
| 91 |
|
---|
| 92 | function compile_demos() {
|
---|
| 93 | for projects in Sinus; do
|
---|
| 94 | configure $FLAIR_ROOT/flair-src/demos $projects
|
---|
| 95 | compile $FLAIR_ROOT/flair-src/demos $projects
|
---|
| 96 | cross_compile $FLAIR_ROOT/flair-src/demos $projects
|
---|
| 97 | done
|
---|
| 98 |
|
---|
| 99 | for projects in CircleFollower SimpleFleet Gps; do
|
---|
| 100 | compile_uav_and_simulator_demo $FLAIR_ROOT/flair-src/demos $projects
|
---|
| 101 | done
|
---|
| 102 |
|
---|
| 103 | for projects in CustomReferenceAngles CustomTorques; do
|
---|
| 104 | configure $FLAIR_ROOT/flair-src/demos/Skeletons $projects
|
---|
| 105 | compile $FLAIR_ROOT/flair-src/demos/Skeletons $projects
|
---|
| 106 | cross_compile $FLAIR_ROOT/flair-src/demos/Skeletons $projects
|
---|
| 107 | done
|
---|
| 108 |
|
---|
| 109 | if [ -d $FLAIR_ROOT/flair-hds ]; then
|
---|
| 110 | for projects in OpticalFlow; do
|
---|
| 111 | compile_uav_and_simulator_demo $FLAIR_ROOT/flair-hds/src/demos $projects
|
---|
| 112 | done
|
---|
| 113 | fi
|
---|
| 114 |
|
---|
| 115 | exit 0
|
---|
| 116 |
|
---|
| 117 |
|
---|
| 118 | for projects in uav; do
|
---|
| 119 | configure $FLAIR_ROOT/uav_ex/demo_ligne_framework $projects
|
---|
| 120 | compile $FLAIR_ROOT/uav_ex/demo_ligne_framework $projects
|
---|
| 121 | cross_compile $FLAIR_ROOT/uav_ex/demo_ligne_framework $projects
|
---|
| 122 | done
|
---|
| 123 |
|
---|
| 124 |
|
---|
| 125 | }
|
---|
| 126 |
|
---|
| 127 | sanity_check
|
---|
| 128 |
|
---|
| 129 | printf "Compile all from scratch [Y/n]?"
|
---|
| 130 | read answer
|
---|
| 131 |
|
---|
| 132 | if [ "$answer" = "" ] || [ "$answer" = "y" ] || [ "$answer" = "Y" ]; then
|
---|
| 133 | from_scratch=yes
|
---|
| 134 | fi
|
---|
| 135 |
|
---|
| 136 | printf "Compile Flair libs [Y/n]?"
|
---|
| 137 | read answer
|
---|
| 138 |
|
---|
| 139 | if [ "$answer" = "" ] || [ "$answer" = "y" ] || [ "$answer" = "Y" ]; then
|
---|
| 140 | compile_libs
|
---|
| 141 | fi
|
---|
| 142 |
|
---|
| 143 | printf "Compile Flair libs documentation [Y/n]?"
|
---|
| 144 | read answer
|
---|
| 145 |
|
---|
| 146 | if [ "$answer" = "" ] || [ "$answer" = "y" ] || [ "$answer" = "Y" ]; then
|
---|
| 147 | $OECORE_HOST_NATIVE_SYSROOT/usr/bin/doxygen $FLAIR_ROOT/flair-src/lib/Doxyfile.in
|
---|
| 148 | fi
|
---|
| 149 |
|
---|
| 150 | printf "Compile Flair tools [Y/n]?"
|
---|
| 151 | read answer
|
---|
| 152 |
|
---|
| 153 | if [ "$answer" = "" ] || [ "$answer" = "y" ] || [ "$answer" = "Y" ]; then
|
---|
| 154 | compile_tools
|
---|
| 155 | fi
|
---|
| 156 |
|
---|
| 157 | printf "Compile demos [Y/n]?"
|
---|
| 158 | read answer
|
---|
| 159 |
|
---|
| 160 | if [ "$answer" = "" ] || [ "$answer" = "y" ] || [ "$answer" = "Y" ]; then
|
---|
| 161 | compile_demos
|
---|
| 162 | fi
|
---|
| 163 |
|
---|
| 164 | exit 0
|
---|
| 165 |
|
---|
| 166 |
|
---|
| 167 |
|
---|
| 168 | exit 0
|
---|