Skip to content

Commit 6c6eaee

Browse files
committed
fix maual west workspace init in container script
1 parent 0463ed2 commit 6c6eaee

2 files changed

Lines changed: 63 additions & 59 deletions

File tree

tools/docker/build-profile-in-container.sh

Lines changed: 54 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -6,41 +6,43 @@ use_dongle="${2:-0}"
66
build_matrix_path="/zmk-config/build.yaml"
77

88
if [[ -z "${keyboard}" ]]; then
9-
echo "Keyboard is required." >&2
10-
exit 1
9+
echo "Keyboard is required." >&2
10+
exit 1
1111
fi
1212

1313
if [[ ! -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
1616
fi
1717

1818
cd /work
1919

2020
if [[ ! -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
2224
fi
2325

2426
if [[ ! -d zmk || ! -d zephyr ]]; then
25-
west update
27+
west update
2628
fi
2729

2830
right_artifact="${keyboard}_right"
2931
if [[ "${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+
)
3537
else
36-
target_artifacts=(
37-
"${right_artifact}"
38-
"${keyboard}_left_central"
39-
)
38+
target_artifacts=(
39+
"${right_artifact}"
40+
"${keyboard}_left_central"
41+
)
4042
fi
4143

4244
mapfile -t artifact_specs < <(
43-
python3 - "${build_matrix_path}" "${target_artifacts[@]}" <<'PY'
45+
python3 - "${build_matrix_path}" "${target_artifacts[@]}" <<'PY'
4446
import sys
4547
4648
try:
@@ -77,45 +79,45 @@ PY
7779
)
7880

7981
if [[ "${#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
8284
fi
8385

8486
mkdir -p /out
8587

8688
for 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
121123
done

tools/docker/draw-in-container.sh

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ set -euo pipefail
44
KEYMAP_PATH="${1:-}"
55

66
if [[ -z "${KEYMAP_PATH}" ]]; then
7-
echo "No keymap was provided." >&2
8-
exit 1
7+
echo "No keymap was provided." >&2
8+
exit 1
99
fi
1010

1111
if [[ ! -f "/zmk-config/${KEYMAP_PATH}" ]]; then
12-
echo "Keymap not found: /zmk-config/${KEYMAP_PATH}" >&2
13-
exit 1
12+
echo "Keymap not found: /zmk-config/${KEYMAP_PATH}" >&2
13+
exit 1
1414
fi
1515

1616
export HOME="/work/home"
@@ -19,9 +19,11 @@ mkdir -p "${HOME}"
1919
cd /work
2020

2121
if [[ ! -d .west ]]; then
22-
west init -l /zmk-config/config
23-
west config --local manifest.project-filter "-zmk,-zephyr"
24-
west update --fetch-opt=--filter=tree:0
22+
mkdir -p .west
23+
printf '[manifest]\npath = config\nfile = west.yml\n' > .west/config
24+
ln -sfn /zmk-config/config config
25+
west config --local -- manifest.project-filter "-zmk,-zephyr"
26+
west update --fetch-opt=--filter=tree:0
2527
fi
2628

2729
keyboard="$(basename "${KEYMAP_PATH}" .keymap)"

0 commit comments

Comments
 (0)