[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
|
---|
[68] | 6 | toolchains=($OECORE_CMAKE_TOOLCHAINS)
|
---|
[2] | 7 |
|
---|
| 8 | function green_echo () {
|
---|
| 9 | echo -e "\033[32m$1\033[0m"
|
---|
| 10 | }
|
---|
| 11 |
|
---|
| 12 | function red_echo () {
|
---|
| 13 | echo -e "\033[31m$1\033[0m"
|
---|
| 14 | }
|
---|
| 15 |
|
---|
| 16 | function check_error () {
|
---|
| 17 | if [ "$?" != "0" ]; then
|
---|
| 18 | red_echo "Error, exiting"
|
---|
| 19 | exit 1
|
---|
| 20 | fi
|
---|
| 21 | }
|
---|
| 22 |
|
---|
| 23 | function sanity_check () {
|
---|
| 24 | if [ -z $FLAIR_ROOT ]; then
|
---|
| 25 | red_echo "You must set the FLAIR_ROOT environement variable"
|
---|
| 26 | exit 1
|
---|
| 27 | fi
|
---|
| 28 | }
|
---|
| 29 |
|
---|
| 30 | function configure () {
|
---|
| 31 | if [ "$from_scratch" = "yes" ]; then
|
---|
| 32 | green_echo "Configuring $1/$2"
|
---|
| 33 | cd $1/$2
|
---|
| 34 |
|
---|
[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 compile () {
|
---|
[68] | 44 | #iterate over available toolchains
|
---|
| 45 | for arch in ${toolchains[@]}; do
|
---|
| 46 | green_echo "Compiling and installing $2 for $arch"
|
---|
| 47 | cd $1/$2/build_$arch
|
---|
| 48 | if [ "$from_scratch" = "yes" ]; then make clean > /dev/null; fi
|
---|
| 49 | make -j$NB_THREADS > /dev/null
|
---|
| 50 | check_error
|
---|
| 51 | make install
|
---|
| 52 | done
|
---|
[2] | 53 | }
|
---|
| 54 |
|
---|
[26] | 55 | function compile_libs() {
|
---|
[44] | 56 | for projects in FlairCore FlairSensorActuator FlairFilter FlairVisionFilter FlairMeta FlairSimulator ; do
|
---|
[2] | 57 | configure $FLAIR_ROOT/flair-src/lib $projects
|
---|
[3] | 58 | compile $FLAIR_ROOT/flair-src/lib $projects
|
---|
[2] | 59 | done
|
---|
[26] | 60 |
|
---|
| 61 | if [ -d $FLAIR_ROOT/flair-hds ]; then
|
---|
[71] | 62 | for projects in FlairBebop FlairArdrone2 FlairMinidrones FlairMamboEdu VisionFilter; do
|
---|
[26] | 63 | configure $FLAIR_ROOT/flair-hds/src/lib $projects
|
---|
| 64 | compile $FLAIR_ROOT/flair-hds/src/lib $projects
|
---|
| 65 | done
|
---|
| 66 | fi
|
---|
[2] | 67 | }
|
---|
| 68 |
|
---|
[9] | 69 | function compile_tools() {
|
---|
[72] | 70 | for projects in FlairGCS Controller/DualShock3 Controller/Mavlink Dbt2csv VrpnBridge; do
|
---|
[9] | 71 | configure $FLAIR_ROOT/flair-src/tools $projects
|
---|
| 72 | compile $FLAIR_ROOT/flair-src/tools $projects
|
---|
| 73 | done
|
---|
| 74 | }
|
---|
| 75 |
|
---|
[23] | 76 | function compile_uav_and_simulator_demo() {
|
---|
| 77 | for projects in simulator uav; do
|
---|
[26] | 78 | configure $1/$2 $projects
|
---|
| 79 | compile $1/$2 $projects
|
---|
[23] | 80 | done
|
---|
| 81 | }
|
---|
| 82 |
|
---|
[9] | 83 | function compile_demos() {
|
---|
[12] | 84 | for projects in Sinus; do
|
---|
| 85 | configure $FLAIR_ROOT/flair-src/demos $projects
|
---|
| 86 | compile $FLAIR_ROOT/flair-src/demos $projects
|
---|
[2] | 87 | done
|
---|
[14] | 88 |
|
---|
[73] | 89 | for projects in OpticalFlow CircleFollower SimpleFleet Gps PidStandalone; do
|
---|
[26] | 90 | compile_uav_and_simulator_demo $FLAIR_ROOT/flair-src/demos $projects
|
---|
[14] | 91 | done
|
---|
| 92 |
|
---|
[27] | 93 | for projects in CustomReferenceAngles CustomTorques; do
|
---|
| 94 | configure $FLAIR_ROOT/flair-src/demos/Skeletons $projects
|
---|
| 95 | compile $FLAIR_ROOT/flair-src/demos/Skeletons $projects
|
---|
| 96 | done
|
---|
| 97 |
|
---|
[46] | 98 | if [ -d $FLAIR_ROOT/flair-hds ]; then
|
---|
[48] | 99 | for projects in ApriltagFollower LineFollower; do
|
---|
[46] | 100 | compile_uav_and_simulator_demo $FLAIR_ROOT/flair-hds/src/demos $projects
|
---|
| 101 | done
|
---|
| 102 | fi
|
---|
[26] | 103 |
|
---|
[2] | 104 | }
|
---|
| 105 |
|
---|
| 106 | sanity_check
|
---|
| 107 |
|
---|
[46] | 108 | if [ -d $FLAIR_ROOT/flair-hds ]; then
|
---|
| 109 | printf "Found flair-hds repository\n"
|
---|
| 110 | fi
|
---|
| 111 |
|
---|
[2] | 112 | printf "Compile all from scratch [Y/n]?"
|
---|
| 113 | read answer
|
---|
| 114 |
|
---|
| 115 | if [ "$answer" = "" ] || [ "$answer" = "y" ] || [ "$answer" = "Y" ]; then
|
---|
| 116 | from_scratch=yes
|
---|
| 117 | fi
|
---|
| 118 |
|
---|
| 119 | printf "Compile Flair libs [Y/n]?"
|
---|
| 120 | read answer
|
---|
| 121 |
|
---|
| 122 | if [ "$answer" = "" ] || [ "$answer" = "y" ] || [ "$answer" = "Y" ]; then
|
---|
[26] | 123 | compile_libs
|
---|
[2] | 124 | fi
|
---|
[9] | 125 |
|
---|
[14] | 126 | printf "Compile Flair libs documentation [Y/n]?"
|
---|
| 127 | read answer
|
---|
| 128 |
|
---|
| 129 | if [ "$answer" = "" ] || [ "$answer" = "y" ] || [ "$answer" = "Y" ]; then
|
---|
[23] | 130 | $OECORE_HOST_NATIVE_SYSROOT/usr/bin/doxygen $FLAIR_ROOT/flair-src/lib/Doxyfile.in
|
---|
[14] | 131 | fi
|
---|
| 132 |
|
---|
[2] | 133 | printf "Compile Flair tools [Y/n]?"
|
---|
| 134 | read answer
|
---|
| 135 |
|
---|
| 136 | if [ "$answer" = "" ] || [ "$answer" = "y" ] || [ "$answer" = "Y" ]; then
|
---|
| 137 | compile_tools
|
---|
| 138 | fi
|
---|
[12] | 139 |
|
---|
| 140 | printf "Compile demos [Y/n]?"
|
---|
| 141 | read answer
|
---|
| 142 |
|
---|
| 143 | if [ "$answer" = "" ] || [ "$answer" = "y" ] || [ "$answer" = "Y" ]; then
|
---|
| 144 | compile_demos
|
---|
| 145 | fi
|
---|
| 146 |
|
---|
[9] | 147 | exit 0
|
---|
[2] | 148 |
|
---|
| 149 |
|
---|
| 150 |
|
---|
| 151 | exit 0
|
---|