Add missing recipes
This commit is contained in:
parent
084ec61d2e
commit
3294db21ab
2 changed files with 73 additions and 20 deletions
92
Justfile
92
Justfile
|
@ -1,29 +1,77 @@
|
||||||
default:
|
default:
|
||||||
@just --list --unsorted
|
@just --list --unsorted
|
||||||
|
|
||||||
build := ".build"
|
config := absolute_path('config')
|
||||||
out := "firmware"
|
build := absolute_path('.build')
|
||||||
|
out := absolute_path('firmware')
|
||||||
|
|
||||||
# build firmware
|
# parse combos.dtsi and update all conf files
|
||||||
build board *args:
|
_auto-conf:
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
BUILD="{{build}}/{{board}}"
|
cconf="{{ config / 'combos.dtsi' }}"
|
||||||
echo "Building firmware..."
|
if [[ -f $cconf ]]; then
|
||||||
west build -d "$BUILD" -s zmk/app -b {{board}} {{args}} -- -DZMK_CONFIG="{{absolute_path('config')}}"
|
# set MAX_COMBOS_PER_KEY to the most frequent combos count in combos.dtsi
|
||||||
if [[ -f "$BUILD/zephyr/zmk.uf2" ]]; then
|
count=$(
|
||||||
mkdir -p {{out}} && cp "$BUILD/zephyr/zmk.uf2" "{{out}}/{{board}}.uf2"
|
tail -n +10 $cconf |
|
||||||
else
|
grep -Eo '[LR][TMBH][0-9]' |
|
||||||
mkdir -p {{out}} && cp "$BUILD/zephyr/zmk.bin" "{{out}}/{{board}}.bin"
|
sort | uniq -c | sort -nr |
|
||||||
|
awk 'NR==1{print $1}'
|
||||||
|
)
|
||||||
|
sed -Ei "/CONFIG_ZMK_COMBO_MAX_COMBOS_PER_KEY/s/=.+/=$count/" "{{ config }}"/*.conf
|
||||||
|
echo "Setting MAX_COMBOS_PER_KEY to $count"
|
||||||
|
|
||||||
|
# set MAX_KEYS_PER_COMBO to the most frequent key count in combos.dtsi
|
||||||
|
count=$(
|
||||||
|
tail -n +10 $cconf |
|
||||||
|
grep -o -n '[LR][TMBH][0-9]' |
|
||||||
|
cut -d : -f 1 | uniq -c | sort -nr |
|
||||||
|
awk 'NR==1{print $1}'
|
||||||
|
)
|
||||||
|
sed -Ei "/CONFIG_ZMK_COMBO_MAX_KEYS_PER_COMBO/s/=.+/=$count/" "{{ config }}"/*.conf
|
||||||
|
echo "Setting MAX_KEYS_PER_COMBO to $count"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# parse build.yaml and filter targets by expression
|
||||||
|
_parse_targets $expr:
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
attrs="[.board, .shield]"
|
||||||
|
filter="(($attrs | map(. // [.]) | combinations), (.include[] | $attrs)) | join(\",\")"
|
||||||
|
echo "$(yq -r "$filter" build.yaml | grep -i "${expr/#all/.}")"
|
||||||
|
|
||||||
|
# build firmware for single board + shield combination
|
||||||
|
_build $board $shield *args:
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
artifact="${shield:+$shield-}${board}"
|
||||||
|
build_dir="{{ build / '$artifact' }}"
|
||||||
|
|
||||||
|
echo "Building firmware for $artifact..."
|
||||||
|
west build -s zmk/app -d "$build_dir" -b $board {{ args }} -- \
|
||||||
|
-DZMK_CONFIG="{{ config }}" ${shield:+-DSHIELD="$shield"}
|
||||||
|
|
||||||
|
if [[ -f "$build_dir/zephyr/zmk.uf2" ]]; then
|
||||||
|
mkdir -p "{{ out }}" && cp "$build_dir/zephyr/zmk.uf2" "{{ out }}/$artifact.uf2"
|
||||||
|
else
|
||||||
|
mkdir -p "{{ out }}" && cp "$build_dir/zephyr/zmk.bin" "{{ out }}/$artifact.bin"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# build firmware for matching targets
|
||||||
|
build expr *args: _auto-conf
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
targets=$(just _parse_targets {{ expr }})
|
||||||
|
|
||||||
|
[[ -z $targets ]] && echo "No matching targets found. Aborting..." >&2 && exit 1
|
||||||
|
echo "$targets" | while IFS=, read -r board shield; do
|
||||||
|
echo "board: $board"
|
||||||
|
echo "shield: $shield"
|
||||||
|
just _build "$board" "$shield" {{ args }}
|
||||||
|
done
|
||||||
|
|
||||||
# clear build cache and artifacts
|
# clear build cache and artifacts
|
||||||
clean:
|
clean:
|
||||||
rm -rf {{build}} {{out}}
|
rm -rf {{ build }} {{ out }}
|
||||||
|
|
||||||
# list all build targets
|
|
||||||
list:
|
|
||||||
echo "TBD"
|
|
||||||
|
|
||||||
# initialize west
|
# initialize west
|
||||||
init:
|
init:
|
||||||
|
@ -31,10 +79,14 @@ init:
|
||||||
west update
|
west update
|
||||||
west zephyr-export
|
west zephyr-export
|
||||||
|
|
||||||
# upgrade west
|
# list build targets
|
||||||
upgrade:
|
list:
|
||||||
|
@just _parse_targets all | sed 's/,$//' | sort | column
|
||||||
|
|
||||||
|
# update west
|
||||||
|
update:
|
||||||
west update
|
west update
|
||||||
|
|
||||||
# upgrade zephyr
|
# upgrade zephyr-sdk and python dependencies
|
||||||
upgrade-zephyr:
|
upgrade-sdk:
|
||||||
nix flake update --flake .
|
nix flake update --flake .
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
pkgs.cmake
|
pkgs.cmake
|
||||||
pkgs.dtc
|
pkgs.dtc
|
||||||
pkgs.ninja
|
pkgs.ninja
|
||||||
|
pkgs.yq
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue