[2] | 1 | #!/bin/bash
|
---|
| 2 | ARCH_DIR=build_$(uname -m)
|
---|
| 3 | NB_THREADS=$(nproc)
|
---|
| 4 | from_scratch=no
|
---|
[43] | 5 | IDE_SCRIPT=cmake_codelite.sh
|
---|
[2] | 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 |
|
---|
[36] | 34 | rm -f build_arm/CMakeCache.txt
|
---|
[43] | 35 | $FLAIR_ROOT/flair-dev/scripts/$IDE_SCRIPT > /dev/null
|
---|
[2] | 36 |
|
---|
| 37 | check_error
|
---|
| 38 | else
|
---|
| 39 | green_echo "Not configuring $1/$2"
|
---|
| 40 | fi
|
---|
| 41 | }
|
---|
| 42 |
|
---|
| 43 | function cross_compile () {
|
---|
[36] | 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
|
---|
[2] | 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 |
|
---|
[26] | 61 | function compile_libs() {
|
---|
[44] | 62 | for projects in FlairCore FlairSensorActuator FlairFilter FlairVisionFilter FlairMeta FlairSimulator ; do
|
---|
[2] | 63 | configure $FLAIR_ROOT/flair-src/lib $projects
|
---|
[3] | 64 | compile $FLAIR_ROOT/flair-src/lib $projects
|
---|
[2] | 65 | cross_compile $FLAIR_ROOT/flair-src/lib $projects
|
---|
| 66 | done
|
---|
[26] | 67 |
|
---|
| 68 | if [ -d $FLAIR_ROOT/flair-hds ]; then
|
---|
[48] | 69 | for projects in FlairBebop FlairArdrone2 VisionFilter; do
|
---|
[26] | 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
|
---|
[2] | 75 | }
|
---|
| 76 |
|
---|
[9] | 77 | function compile_tools() {
|
---|
[35] | 78 | for projects in FlairGCS Controller/DualShock3 Controller/Mavlink Dbt2csv; do
|
---|
[9] | 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 |
|
---|
[23] | 85 | function compile_uav_and_simulator_demo() {
|
---|
| 86 | for projects in simulator uav; do
|
---|
[26] | 87 | configure $1/$2 $projects
|
---|
| 88 | compile $1/$2 $projects
|
---|
| 89 | cross_compile $1/$2 $projects
|
---|
[23] | 90 | done
|
---|
| 91 | }
|
---|
| 92 |
|
---|
[9] | 93 | function compile_demos() {
|
---|
[12] | 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
|
---|
[2] | 98 | done
|
---|
[14] | 99 |
|
---|
[45] | 100 | for projects in OpticalFlow CircleFollower SimpleFleet Gps; do
|
---|
[26] | 101 | compile_uav_and_simulator_demo $FLAIR_ROOT/flair-src/demos $projects
|
---|
[14] | 102 | done
|
---|
| 103 |
|
---|
[27] | 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 |
|
---|
[46] | 110 | if [ -d $FLAIR_ROOT/flair-hds ]; then
|
---|
[48] | 111 | for projects in ApriltagFollower LineFollower; do
|
---|
[46] | 112 | compile_uav_and_simulator_demo $FLAIR_ROOT/flair-hds/src/demos $projects
|
---|
| 113 | done
|
---|
| 114 | fi
|
---|
[26] | 115 |
|
---|
[2] | 116 | }
|
---|
| 117 |
|
---|
| 118 | sanity_check
|
---|
| 119 |
|
---|
[46] | 120 | if [ -d $FLAIR_ROOT/flair-hds ]; then
|
---|
| 121 | printf "Found flair-hds repository\n"
|
---|
| 122 | fi
|
---|
| 123 |
|
---|
[2] | 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
|
---|
[26] | 135 | compile_libs
|
---|
[2] | 136 | fi
|
---|
[9] | 137 |
|
---|
[14] | 138 | printf "Compile Flair libs documentation [Y/n]?"
|
---|
| 139 | read answer
|
---|
| 140 |
|
---|
| 141 | if [ "$answer" = "" ] || [ "$answer" = "y" ] || [ "$answer" = "Y" ]; then
|
---|
[23] | 142 | $OECORE_HOST_NATIVE_SYSROOT/usr/bin/doxygen $FLAIR_ROOT/flair-src/lib/Doxyfile.in
|
---|
[14] | 143 | fi
|
---|
| 144 |
|
---|
[2] | 145 | printf "Compile Flair tools [Y/n]?"
|
---|
| 146 | read answer
|
---|
| 147 |
|
---|
| 148 | if [ "$answer" = "" ] || [ "$answer" = "y" ] || [ "$answer" = "Y" ]; then
|
---|
| 149 | compile_tools
|
---|
| 150 | fi
|
---|
[12] | 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 |
|
---|
[9] | 159 | exit 0
|
---|
[2] | 160 |
|
---|
| 161 |
|
---|
| 162 |
|
---|
| 163 | exit 0
|
---|