Bug fix after merge from master
[inav.git] / build.sh
blobfe5a5281e4229970d6e6453ed086d4e893d73d98
1 #!/usr/bin/env bash
2 set -e
4 if [[ $# == 0 ]]; then
5 echo -e "\
6 Usage syntax: ./build.sh <TARGET>
8 Notes:
9 * You can specify multiple targets.
10 ./build.sh <TARGET_1> <TARGET_2> <TARGET_N>
11 * To get a list of all targets use \"help\". Hint: pipe the output through a pager.
12 ./build.sh help | less
13 * To build all targets use \"all\"
14 ./build.sh all
15 * To clean a target prefix it with \"clean_\".
16 ./build.sh clean_MATEKF405SE
17 * To clean all targets just use \"clean\".
18 ./build.sh clean"
19 exit 1
22 if [ -z "$(docker images -q inav-build)" ]; then
23 echo -e "*** Building image\n"
24 docker build -t inav-build --build-arg USER_ID="$(id -u)" --build-arg GROUP_ID="$(id -g)" .
25 echo -ne "\n"
28 if [ ! -d ./build ]; then
29 echo -e "*** Creating build directory\n"
30 mkdir ./build && chmod 777 ./build
33 if [ ! -d ./downloads ]; then
34 echo -e "*** Creating downloads directory\n"
35 mkdir ./downloads && chmod 777 ./downloads
38 if [ ! -d ./tools ]; then
39 echo -e "*** Creating tools directory\n"
40 mkdir ./tools && chmod 777 ./tools
43 echo -e "*** Building targets [$@]\n"
44 docker run --rm -it -v "$(pwd)":/src inav-build $@
46 if [ -z "$(ls ./build/*.hex &> /dev/null)" ]; then
47 echo -e "\n*** Built targets in ./build:"
48 stat -c "%n (%.19y)" ./build/*.hex