Skip to content

Commit 3ad9c44

Browse files
committed
WIP: Initial script to hint at errors in build log
1 parent f692d64 commit 3ad9c44

File tree

4 files changed

+85
-0
lines changed

4 files changed

+85
-0
lines changed

E101.log

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
-- Found devicetree overlay: /__w/test_zmk-config/test_zmk-config/zmk/app/boards/shields/a_dux/a_dux_right.overlay
2+
-- Found devicetree overlay: /__w/test_zmk-config/test_zmk-config/config/a_dux.keymap
3+
Error: nice_nano.dts.pre.tmp:74.3-5 syntax error
4+
FATAL ERROR: Unable to parse input tree
5+
CMake Error at /__w/test_zmk-config/test_zmk-config/zephyr/cmake/dts.cmake:205 (message):
6+
command failed with return code: 1

E102.log

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
In file included from /__w/test_zmk-config/test_zmk-config/zephyr/include/sys/util_macro.h:34,
2+
from /__w/test_zmk-config/test_zmk-config/zephyr/include/sys/util.h:17,
3+
from /__w/test_zmk-config/test_zmk-config/zmk/app/src/keymap.c:7:
4+
zephyr/include/generated/devicetree_unfixed.h:1415:44: error: 'DT_N_S_keymap_S_base_layer_P_bindings_IDX_1_PH_P_label' undeclared here (not in a function); did you mean 'DT_N_S_keymap_S_base_layer_P_bindings_IDX_10_PH'?
5+
1415 | #define DT_N_S_keymap_FOREACH_CHILD(fn) fn(DT_N_S_keymap_S_base_layer)
6+
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
7+

E103.log

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
-- Found devicetree overlay: /__w/test_zmk-config/test_zmk-config/zmk/app/boards/shields/a_dux/a_dux_left.overlay
2+
-- Found devicetree overlay: /__w/test_zmk-config/test_zmk-config/config/a_dux.keymap
3+
nice_nano.dts.pre.tmp:734.14-741.5: ERROR (phandle_references): /keymap/base_layer: Reference to non-existent node or label "kc"
4+
5+
ERROR: Input tree has errors, aborting (use -f to force output)
6+
CMake Error at /__w/test_zmk-config/test_zmk-config/zephyr/cmake/dts.cmake:205 (message):
7+
command failed with return code: 2

hints

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#! /bin/bash
2+
3+
set -e
4+
5+
usage="help text here"
6+
buildlog=$1
7+
8+
if [ $# -eq 0 ]; then
9+
echo "$usage"
10+
exit 1
11+
fi
12+
13+
error() {
14+
error_code="$1"
15+
error_message="$2"
16+
17+
hint="$error_code: $error_message"
18+
notice="See https://zmk.dev/docs/troubleshooting/ for help."
19+
20+
# Markup with annotations for GitHub actions if necessary
21+
if [ "$GITHUB_ACTIONS" = true ]; then
22+
hint="::error::$output"
23+
notice="::notice::Build failed. $notice"
24+
fi
25+
26+
echo -e "$hint\n"
27+
echo "$notice"
28+
}
29+
30+
if [ ! -f "$buildlog" ]; then
31+
error M01 "Build log not found at '$buildlog'"
32+
exit 2
33+
fi
34+
35+
# # Provide helpful GitHub annotations if build fails:
36+
# echo "::notice::Build failed. See https://zmk.dev/docs/troubleshooting/ for help."
37+
38+
# Check that a given sed command ($1) returns a match when run over the
39+
# build.log. Store the output of sed for further parsing.
40+
match() {
41+
output="$(sed -nE "$1" "$buildlog")"
42+
test -n "$output"
43+
}
44+
45+
# Provide annotation for errors due to incorrect keycodes (e.g. `&kp ENTRE`)
46+
# Error: nice_nano.dts.pre.tmp:74.137-138 syntax error
47+
if match 's/^.+ (\S+\.dts.pre.tmp):([0-9]+)\.([0-9]+).+ syntax error.*$/\1 \2 \3/p'; then
48+
read dts_file line_pos char_pos <<< "$output"
49+
line=$(sed -n ${line_pos}p "build/zephyr/${dts_file}")
50+
value=$(cut -c${char_pos}- <<< "$line" | cut -f1 -d\ )
51+
error E101 "Unable to parse \"${value}\" from line: ${line}"
52+
fi
53+
54+
# Provide annotation for errors due to missing parameters (e.g. `&mt LALT`):
55+
# zephyr/include/generated/devicetree_unfixed.h:1415:44: error: 'DT_N_S_keymap_S_base_layer_P_bindings_IDX_1_PH_P_label' undeclared here (not in a function)
56+
if match 's/^.+error: .DT_N_S_keymap_S_(.+)_P_bindings_IDX_([0-9])_PH_P_label. undeclared here.+$/\1 \2/p'; then
57+
read layer index <<< "$output"
58+
error E102 "Problem with index ${index} on layer \"${layer}\"."
59+
fi
60+
61+
# Provide annotation for generic error messages such as:
62+
# nice_nano.dts.pre.tmp:734.14-741.5: ERROR (phandle_references): /keymap/base_layer: Reference to non-existent node or label "kc"
63+
if match 's/^.+dts\.pre\.tmp\S+ ERROR (.+)$/\1/p'; then
64+
error E103 "${output}"
65+
fi

0 commit comments

Comments
 (0)