aboutsummaryrefslogtreecommitdiff
path: root/build.sh
blob: 8995312195501763130976152b3fcd51eac8f3ba (plain)
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
#!/bin/sh
ZSDK_VERSION=0.13.2
ZEN_BRANCH=Board-Corne-ish-Zen-dedicated-work-queue
CONFIG_DIR=~/waffle_git/zmk-build/config
ZMK_DIR=~/waffle_git/zmk
UF2=~/*.uf2

update() {
  (cd ${ZMK_DIR} ; git pull ; west update)
  wget "https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v${ZSDK_VERSION}/zephyr-toolchain-arm-${ZSDK_VERSION}-linux-x86_64-setup.run"
  chmod +x zephyr-toolchain-arm-${ZSDK_VERSION}-linux-x86_64-setup.run
  ./zephyr-toolchain-arm-${ZSDK_VERSION}-linux-x86_64-setup.run -- -d ~/.local/zephyr-sdk-${ZSDK_VERSION}
  rm zephyr-toolchain-arm-${ZSDK_VERSION}-linux-x86_64-setup.run
}

test_uf2() {
  if test -f ${UF2}; then
    rm ${UF2}
  fi
}

read -p "update? (y/n) " -n 1 -r
if [[ $REPLY =~ ^[Yy]$ ]]
then
  update
fi

echo -e "\n"
PS3="choose keyboard to build: "
options=("corne" "corne-ish zen" "quit")
select opt in "${options[@]}"
do
  case $opt in
    "corne")
      echo "building corne firmware..."
      test_uf2
      (cd ${ZMK_DIR}
      if [ $(git branch --show-current) == "${ZEN_BRANCH}"]; then
        git checkout main
        update
      fi)
      (cd ${ZMK_DIR}/app
      west build -p -b nice_nano -- -DSHIELD=corne_left -DZMK_CONFIG="${CONFIG_DIR}"
      cp ${ZMK_DIR}/app/build/zephyr/zmk.uf2 ~/corne_left.uf2
      west build -p -b nice_nano_v2 -- -DSHIELD=corne_right -DZMK_CONFIG="${CONFIG_DIR}"
      cp ${ZMK_DIR}/app/build/zephyr/zmk.uf2 ~/corne_right.uf2
      )
      break
      ;;
    "corne-ish zen")
      echo "building corne-ish zen firmware..."
      test_uf2
      (cd ${ZMK_DIR}
      if [[ $(git branch --show-current) = "main" ]]; then
        git checkout ${ZEN_BRANCH}
        update
      fi)
      (cd ${ZMK_DIR}/app
      west build -p -b corne-ish_zen_left -- -DZMK_CONFIG="${CONFIG_DIR}"
      cp ${ZMK_DIR}/app/build/zephyr/zmk.uf2 ~/corne-ish_zen_left.uf2
      west build -p -b corne-ish_zen_right -- -DZMK_CONFIG="${CONFIG_DIR}"
      cp ${ZMK_DIR}/app/build/zephyr/zmk.uf2 ~/corne-ish_zen_right.uf2
      )
      break
      ;;
    "quit")
      break
      ;;
    *) echo "invalid option: $REPLY";;
  esac
done