@@ -6,41 +6,43 @@ use_dongle="${2:-0}"
66build_matrix_path=" /zmk-config/build.yaml"
77
88if [[ -z " ${keyboard} " ]]; then
9- echo " Keyboard is required." >&2
10- exit 1
9+ echo " Keyboard is required." >&2
10+ exit 1
1111fi
1212
1313if [[ ! -f " ${build_matrix_path} " ]]; then
14- echo " Build matrix file not found: ${build_matrix_path} " >&2
15- exit 1
14+ echo " Build matrix file not found: ${build_matrix_path} " >&2
15+ exit 1
1616fi
1717
1818cd /work
1919
2020if [[ ! -d .west ]]; then
21- west init -l /zmk-config/config
21+ mkdir -p .west
22+ printf ' [manifest]\npath = config\nfile = west.yml\n' > .west/config
23+ ln -sfn /zmk-config/config config
2224fi
2325
2426if [[ ! -d zmk || ! -d zephyr ]]; then
25- west update
27+ west update
2628fi
2729
2830right_artifact=" ${keyboard} _right"
2931if [[ " ${use_dongle} " == " 1" ]]; then
30- target_artifacts=(
31- " ${keyboard} _left_peripheral"
32- " ${right_artifact} "
33- " ${keyboard} _dongle"
34- )
32+ target_artifacts=(
33+ " ${keyboard} _left_peripheral"
34+ " ${right_artifact} "
35+ " ${keyboard} _dongle"
36+ )
3537else
36- target_artifacts=(
37- " ${right_artifact} "
38- " ${keyboard} _left_central"
39- )
38+ target_artifacts=(
39+ " ${right_artifact} "
40+ " ${keyboard} _left_central"
41+ )
4042fi
4143
4244mapfile -t artifact_specs < <(
43- python3 - " ${build_matrix_path} " " ${target_artifacts[@]} " << 'PY '
45+ python3 - " ${build_matrix_path} " " ${target_artifacts[@]} " << 'PY '
4446import sys
4547
4648try:
7779)
7880
7981if [[ " ${# artifact_specs[@]} " -ne " ${# target_artifacts[@]} " ]]; then
80- echo " Failed to resolve build specs for ${keyboard} " >&2
81- exit 1
82+ echo " Failed to resolve build specs for ${keyboard} " >&2
83+ exit 1
8284fi
8385
8486mkdir -p /out
8587
8688for spec in " ${artifact_specs[@]} " ; do
87- IFS=$' \x1f ' read -r artifact_name board shield snippet cmake_args_raw <<< " ${spec}"
88-
89- if [[ -z " ${board} " || -z " ${shield} " ]]; then
90- echo " Invalid build matrix entry for ${artifact_name} : board/shield is missing" >&2
91- exit 1
92- fi
93-
94- build_dir=" /work/build/${artifact_name} "
95- west_extra_args=()
96- cmake_args=(
97- -DSHIELD=" ${shield} "
98- -DZMK_CONFIG=/zmk-config/config
99- -DZMK_EXTRA_MODULES=/zmk-config
100- -DZEPHYR_BASE=/work/zephyr
101- -DZephyr_DIR=/work/zephyr/share/zephyr-package/cmake
102- )
103-
104- if [[ -n " ${snippet} " ]]; then
105- west_extra_args=(-S " ${snippet} " )
106- fi
107-
108- if [[ -n " ${cmake_args_raw} " ]]; then
109- # shellcheck disable=SC2206
110- extra_cmake_args=(${cmake_args_raw} )
111- cmake_args+=(" ${extra_cmake_args[@]} " )
112- fi
113-
114- echo " ==> Building ${artifact_name} "
115- rm -rf " ${build_dir} "
116- west build -d " ${build_dir} " -b " ${board} " " ${west_extra_args[@]} " /work/zmk/app -- " ${cmake_args[@]} "
117-
118- if [[ -f " ${build_dir} /zephyr/zmk.uf2" ]]; then
119- cp " ${build_dir} /zephyr/zmk.uf2" " /out/${artifact_name} .uf2"
120- fi
89+ IFS=$' \x1f ' read -r artifact_name board shield snippet cmake_args_raw <<< " ${spec}"
90+
91+ if [[ -z " ${board} " || -z " ${shield} " ]]; then
92+ echo " Invalid build matrix entry for ${artifact_name} : board/shield is missing" >&2
93+ exit 1
94+ fi
95+
96+ build_dir=" /work/build/${artifact_name} "
97+ west_extra_args=()
98+ cmake_args=(
99+ -DSHIELD=" ${shield} "
100+ -DZMK_CONFIG=/zmk-config/config
101+ -DZMK_EXTRA_MODULES=/zmk-config
102+ -DZEPHYR_BASE=/work/zephyr
103+ -DZephyr_DIR=/work/zephyr/share/zephyr-package/cmake
104+ )
105+
106+ if [[ -n " ${snippet} " ]]; then
107+ west_extra_args=(-S " ${snippet} " )
108+ fi
109+
110+ if [[ -n " ${cmake_args_raw} " ]]; then
111+ # shellcheck disable=SC2206
112+ extra_cmake_args=(${cmake_args_raw} )
113+ cmake_args+=(" ${extra_cmake_args[@]} " )
114+ fi
115+
116+ echo " ==> Building ${artifact_name} "
117+ rm -rf " ${build_dir} "
118+ west build -d " ${build_dir} " -b " ${board} " " ${west_extra_args[@]} " /work/zmk/app -- " ${cmake_args[@]} "
119+
120+ if [[ -f " ${build_dir} /zephyr/zmk.uf2" ]]; then
121+ cp " ${build_dir} /zephyr/zmk.uf2" " /out/${artifact_name} .uf2"
122+ fi
121123done
0 commit comments