forked from petejohanson/unified-zmk-config-template
-
-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
FROM docker.io/zmkfirmware/zmk-build-arm:stable | ||
|
||
RUN apt-get update \ | ||
&& apt-get install -y wget \ | ||
&& wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/bin/yq \ | ||
&& chmod +x /usr/bin/yq | ||
|
||
ARG USER_ID=1000 | ||
|
||
RUN adduser --disabled-password --gecos '' --uid ${USER_ID} zmk | ||
|
||
USER zmk | ||
|
||
WORKDIR /app | ||
|
||
COPY config/west.yml config/west.yml | ||
|
||
RUN west init -l config \ | ||
&& west update \ | ||
&& west zephyr-export | ||
|
||
COPY bin/build.sh ./ | ||
|
||
CMD ["./build.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
DOCKER := $(shell { command -v podman || command -v docker; }) | ||
|
||
.PHONY: all clean distclean | ||
|
||
all: | ||
$(DOCKER) build --tag zmk --build-arg USER_ID=$(shell id -u) . | ||
$(DOCKER) volume create build | ||
$(DOCKER) run --rm -it --name zmk \ | ||
-v build:/app \ | ||
-v $(PWD)/build.yaml:/app/build.yaml:ro \ | ||
-v $(PWD)/config:/app/config:ro \ | ||
-v $(PWD)/firmware:/app/firmware \ | ||
-e OUTPUT_ZMK_CONFIG=$(OUTPUT_ZMK_CONFIG) \ | ||
zmk | ||
|
||
clean: | ||
rm -rf firmware/[^.]* | ||
-$(DOCKER) volume rm build config firmware | ||
|
||
distclean: clean | ||
-$(DOCKER) image rm zmk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/usr/bin/env bash | ||
|
||
config_dir="${PWD}/config" | ||
timestamp=$(date -u +"%Y%m%d%H%M%S") | ||
|
||
while IFS=$',' read -r board shield; do | ||
extra_cmake_args=${shield:+-DSHIELD="$shield"} | ||
artifact_name=${shield:+${shield// /-}-}${board}-zmk | ||
filename="firmware/${timestamp}-${artifact_name}" | ||
build_dir="build/${artifact_name}" | ||
|
||
echo "" | ||
echo "-----------------" | ||
echo "BUILDING FIRMWARE" | ||
echo "-----------------" | ||
echo "Zephyr: ${ZEPHYR_VERSION}" | ||
echo "Board: ${board}" | ||
echo "Shield: ${shield}" | ||
echo "" | ||
|
||
if [[ ! -d "$build_dir" ]]; then | ||
west build -s zmk/app -b "$board" -d ${build_dir} -- \ | ||
-DZMK_CONFIG="$config_dir" "${extra_cmake_args}" | ||
else | ||
west build -d ${build_dir} -- -DZMK_CONFIG="$config_dir" | ||
fi | ||
|
||
if [[ ! -z $OUTPUT_ZMK_CONFIG ]]; then | ||
grep -v -e "^#" -e "^$" ${build_dir}/zephyr/.config \ | ||
| sort > "${filename}.config" | ||
fi | ||
|
||
cp ${build_dir}/zephyr/zmk.uf2 "${filename}.uf2" | ||
done < <(yq ' | ||
[{"board": .board[], "shield": .shield[] // ""}] + .include | ||
| filter(.board) | ||
| unique_by(.board + .shield).[] | ||
| [.board, .shield // ""] | ||
| @csv | ||
' build.yaml) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
* | ||
!.gitignore |