Skip to content

Commit 110c15c

Browse files
committed
fix naming
when duplicate names, append index new yaml option: name - define custom name(build dir) output
1 parent 3d4ff8f commit 110c15c

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

zmk/config/zmk-build

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,16 +102,34 @@ fi
102102
_zmkbuild() {
103103
i=0
104104
for board in $(yq ".include[].board" "$build_file"); do
105-
for var in shield cmake_args west_args env_args; do
105+
for var in shield cmake_args west_args env_args name; do
106106
val="$(yq ".include[$i].${var}" "$build_file")"
107107
export $var="$val"
108108
if [ "$val" = "null" ]; then
109109
unset $var
110110
fi
111111
done
112-
# TODO: somehow fix naming
113-
# shellcheck disable=SC2154
114-
build_dir="$ZMK_CONFIG_DIR/$(echo "build/$board.$shield" | sed 's/ /_/g')"
112+
113+
if [ -n "$name" ]; then
114+
# TODO: solve duplicate names or just behaviour is overwrite/unexpected
115+
build_dir="$ZMK_CONFIG_DIR/$(echo "build/$name" | sed 's/ /_/g')"
116+
else
117+
# shellcheck disable=SC2154
118+
placeholder="$(echo "build/$board.$shield" | sed 's/ /_/g')"
119+
120+
index=0
121+
for n in $name_exists; do
122+
if [ "$n" = "$placeholder" ]; then
123+
index=$((index + 1))
124+
fi
125+
done
126+
if [ $index -eq 0 ]; then
127+
index=""
128+
fi
129+
130+
build_dir="$ZMK_CONFIG_DIR/$placeholder$index"
131+
name_exists="$name_exists $placeholder"
132+
fi
115133

116134
mkdir -p "$build_dir"
117135
fifo="$build_dir/fifo"

0 commit comments

Comments
 (0)