[2] | 1 | #!/bin/bash
|
---|
| 2 | NB_THREADS=$(nproc)
|
---|
| 3 | from_scratch=no
|
---|
[43] | 4 | IDE_SCRIPT=cmake_codelite.sh
|
---|
[68] | 5 | toolchains=($OECORE_CMAKE_TOOLCHAINS)
|
---|
[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 |
|
---|
[43] | 34 | $FLAIR_ROOT/flair-dev/scripts/$IDE_SCRIPT > /dev/null
|
---|
[2] | 35 |
|
---|
| 36 | check_error
|
---|
| 37 | else
|
---|
| 38 | green_echo "Not configuring $1/$2"
|
---|
| 39 | fi
|
---|
| 40 | }
|
---|
| 41 |
|
---|
| 42 | function compile () {
|
---|
[68] | 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
|
---|
[2] | 52 | }
|
---|
| 53 |
|
---|
[26] | 54 | function compile_libs() {
|
---|
[44] | 55 | for projects in FlairCore FlairSensorActuator FlairFilter FlairVisionFilter FlairMeta FlairSimulator ; do
|
---|
[2] | 56 | configure $FLAIR_ROOT/flair-src/lib $projects
|
---|
[3] | 57 | compile $FLAIR_ROOT/flair-src/lib $projects
|
---|
[2] | 58 | done
|
---|
[26] | 59 |
|
---|
| 60 | if [ -d $FLAIR_ROOT/flair-hds ]; then
|
---|
[71] | 61 | for projects in FlairBebop FlairArdrone2 FlairMinidrones FlairMamboEdu VisionFilter; do
|
---|
[26] | 62 | configure $FLAIR_ROOT/flair-hds/src/lib $projects
|
---|
| 63 | compile $FLAIR_ROOT/flair-hds/src/lib $projects
|
---|
| 64 | done
|
---|
| 65 | fi
|
---|
[2] | 66 | }
|
---|
| 67 |
|
---|
[9] | 68 | function compile_tools() {
|
---|
[72] | 69 | for projects in FlairGCS Controller/DualShock3 Controller/Mavlink Dbt2csv VrpnBridge; do
|
---|
[9] | 70 | configure $FLAIR_ROOT/flair-src/tools $projects
|
---|
| 71 | compile $FLAIR_ROOT/flair-src/tools $projects
|
---|
| 72 | done
|
---|
| 73 | }
|
---|
| 74 |
|
---|
[23] | 75 | function compile_uav_and_simulator_demo() {
|
---|
| 76 | for projects in simulator uav; do
|
---|
[26] | 77 | configure $1/$2 $projects
|
---|
| 78 | compile $1/$2 $projects
|
---|
[23] | 79 | done
|
---|
| 80 | }
|
---|
| 81 |
|
---|
[9] | 82 | function compile_demos() {
|
---|
[12] | 83 | for projects in Sinus; do
|
---|
| 84 | configure $FLAIR_ROOT/flair-src/demos $projects
|
---|
| 85 | compile $FLAIR_ROOT/flair-src/demos $projects
|
---|
[2] | 86 | done
|
---|
[14] | 87 |
|
---|
[73] | 88 | for projects in OpticalFlow CircleFollower SimpleFleet Gps PidStandalone; do
|
---|
[26] | 89 | compile_uav_and_simulator_demo $FLAIR_ROOT/flair-src/demos $projects
|
---|
[14] | 90 | done
|
---|
| 91 |
|
---|
[27] | 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 |
|
---|
[46] | 97 | if [ -d $FLAIR_ROOT/flair-hds ]; then
|
---|
[48] | 98 | for projects in ApriltagFollower LineFollower; do
|
---|
[46] | 99 | compile_uav_and_simulator_demo $FLAIR_ROOT/flair-hds/src/demos $projects
|
---|
| 100 | done
|
---|
| 101 | fi
|
---|
[26] | 102 |
|
---|
[2] | 103 | }
|
---|
| 104 |
|
---|
| 105 | sanity_check
|
---|
| 106 |
|
---|
[46] | 107 | if [ -d $FLAIR_ROOT/flair-hds ]; then
|
---|
| 108 | printf "Found flair-hds repository\n"
|
---|
| 109 | fi
|
---|
| 110 |
|
---|
[2] | 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
|
---|
[26] | 122 | compile_libs
|
---|
[2] | 123 | fi
|
---|
[9] | 124 |
|
---|
[14] | 125 | printf "Compile Flair libs documentation [Y/n]?"
|
---|
| 126 | read answer
|
---|
| 127 |
|
---|
| 128 | if [ "$answer" = "" ] || [ "$answer" = "y" ] || [ "$answer" = "Y" ]; then
|
---|
[23] | 129 | $OECORE_HOST_NATIVE_SYSROOT/usr/bin/doxygen $FLAIR_ROOT/flair-src/lib/Doxyfile.in
|
---|
[14] | 130 | fi
|
---|
| 131 |
|
---|
[2] | 132 | printf "Compile Flair tools [Y/n]?"
|
---|
| 133 | read answer
|
---|
| 134 |
|
---|
| 135 | if [ "$answer" = "" ] || [ "$answer" = "y" ] || [ "$answer" = "Y" ]; then
|
---|
| 136 | compile_tools
|
---|
| 137 | fi
|
---|
[12] | 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 |
|
---|
[9] | 146 | exit 0
|
---|
[2] | 147 |
|
---|
| 148 |
|
---|
| 149 |
|
---|
| 150 | exit 0
|
---|