-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
77 lines (63 loc) · 2.01 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
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
73
74
75
76
77
#!/usr/bin/env bash
# Usage:
# build.sh --board nice_nano_v2 --left microdox_left --right microdox_right
#
set -eou pipefail
main() {
local board='' shield_left='' shield_right='' GID
GID="$(id -g)"
while true; do
case "${1:-}" in
--board) board="$2"; shift 2 ;;
--left) shield_left="$2"; shift 2 ;;
--right) shield_right="$2"; shift 2 ;;
*) break ;;
esac
done
if [[ -z "${board}${shield_left}${shield_right}" ]]; then
echo 'Specify --board <board> --left <shield> --right <shield>'
return 1
fi
rm -rf build/*.out
docker run -it --rm \
-v "$(pwd)/.cache:/keeb" \
-v "$(pwd)/config:/keeb/config:ro" \
-v "$(pwd)/build:/build" \
zmkfirmware/zmk-build-arm:2.5 sh -c "
cd /keeb
if [ ! -d .west ]; then
west init -l config
fi
if [ ! -d zmk ]; then
west update
fi
west zephyr-export
echo 'Building left'
west build --pristine -b $board zmk/app -- \
-DSHIELD=$shield_left \
-DZMK_CONFIG=/keeb/config
cp /keeb/build/zephyr/zmk.uf2 /build/${shield_left}_${board}.uf2.out
chown $UID:$GID /build/${shield_left}_${board}.uf2.out
echo 'Building right'
west build --pristine -b $board zmk/app -- \
-DSHIELD=$shield_right \
-DZMK_CONFIG=/keeb/config
cp /keeb/build/zephyr/zmk.uf2 /build/${shield_right}_${board}.uf2.out
chown $UID:$GID /build/${shield_right}_${board}.uf2.out
"
if [[ ! -e "build/${shield_left}_${board}.uf2.out" ]] \
|| [[ ! -e "build/${shield_right}_${board}.uf2.out" ]]; then
echo ''
echo '-- Errors in building'
exit 1
fi
echo ''
echo '-- Done'
rm -f build/${shield_left}_${board}.uf2 build/${shield_right}_${board}.uf2
mv build/${shield_left}_${board}.uf2{.out,}
mv build/${shield_right}_${board}.uf2{.out,}
ls -la build/${shield_left}_${board}.uf2
ls -la build/${shield_right}_${board}.uf2
}
main "$@"
# Thanks to https://git.lyte.dev/lytedev/keyboards/src/branch/master/zorne/build.fish