forked from iNavFlight/inav
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·73 lines (64 loc) · 2 KB
/
build.sh
File metadata and controls
executable file
·73 lines (64 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/env bash
set -euo pipefail
if [[ $# == 0 ]]; then
echo -e "\
Usage syntax: ./build.sh <TARGET>
Notes:
* You can specify multiple targets.
./build.sh <TARGET_1> <TARGET_2> <TARGET_N>
* To get a list of release targets use \"release_targets\"
./build.sh release_targets
* To get a list of valid targets use \"valid_targets\"
./build.sh valid_targets
* To get a list of all targets use \"help\". Hint: pipe the output through a pager.
./build.sh help | less
* To build all targets use \"all\"
./build.sh all
* To clean a target prefix it with \"clean_\".
./build.sh clean_MATEKF405SE
* To clean all targets just use \"clean\".
./build.sh clean"
exit 1
fi
run_docker() {
docker run --rm -it -v "$(pwd)":/src inav-build "$@"
}
if [ -z "$(docker images -q inav-build)" ]; then
echo "*** Building Docker image"
docker build -t inav-build \
--build-arg USER_ID="$(id -u)" \
--build-arg GROUP_ID="$(id -g)" .
else
docker build -q -t inav-build \
--build-arg USER_ID="$(id -u)" \
--build-arg GROUP_ID="$(id -g)" . >/dev/null ||
{ echo "*** Building Docker image: ERROR"; exit 1; }
fi
if [ ! -d ./build ]; then
echo -e "*** Creating build directory\n"
mkdir ./build && chmod 777 ./build
fi
if [ ! -d ./downloads ]; then
echo -e "*** Creating downloads directory\n"
mkdir ./downloads && chmod 777 ./downloads
fi
if [ ! -d ./tools ]; then
echo -e "*** Creating tools directory\n"
mkdir ./tools && chmod 777 ./tools
fi
case "$1" in
release_targets)
run_docker targets | sed -n 's/^Release targets: \(.*\)/\1/p'|tr ' ' '\n'
;;
valid_targets)
run_docker targets | sed -n 's/^Valid targets: \(.*\)/\1/p'|tr ' ' '\n'
;;
*)
echo -e "*** Building targets [$@]\n"
run_docker "$@"
if ls ./build/*.hex &> /dev/null; then
echo -e "\n*** Built targets in ./build:"
stat -c "%n (%.19y)" ./build/*.hex
fi
;;
esac