-
Notifications
You must be signed in to change notification settings - Fork 56
/
Copy pathbuild.sh
executable file
·45 lines (39 loc) · 1.07 KB
/
build.sh
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
#!/bin/bash
# build the raspberry pi pico JLed example using a docker container.
# Run "./build.sh docker-image" first to build the docker-image,
# then run "./build.sh compile" to compile the example.
#
# Jan Delgado 02/2021
set -eou pipefail
usage() {
echo "$0: <docker-image|compile|shell|clean>"
}
build_image() {
docker build \
--build-arg="TZ=$(timedatectl show -p Timezone --value)" \
-t picosdk:latest .
}
run_cmd() {
docker run -ti --rm \
--user="$(id -u):$(id -g)" \
-v "$(pwd)/../..:/src:z" \
picosdk:latest "$@"
}
main() {
case $action in
docker-image) build_image ;;
compile)
run_cmd sh -c "cd /src/examples/raspi_pico && cmake . && make"
local -r line=$(printf '=%.0s' {1..75})
echo "$line"
echo "BUILD SUCCESSFUL."
echo "Now upload the file pico_demo.uf2 to your Pico manually."
echo "$line"
;;
shell) run_cmd bash ;;
clean) git clean -d -x -f ;;
*) usage ;;
esac
}
action=${1:-""}
main action