diff --git a/Dockerfile b/Dockerfile index 121e0db..e61dc54 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,5 @@ FROM zmkfirmware/zmk-build-arm:stable -RUN mkdir -p /app/firmware - WORKDIR /app COPY config/west.yml config/west.yml @@ -13,7 +11,6 @@ RUN west update # West Zephyr export RUN west zephyr-export -COPY config config COPY bin/build.sh ./ CMD ["./build.sh"] diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..ea54d90 --- /dev/null +++ b/Makefile @@ -0,0 +1,20 @@ +TIMESTAMP := $(shell date -u +"%Y%m%d%H%M%S") + +.PHONY: clean setup + +all: setup build + +build: firmware/$$(TIMESTAMP)-left.uf2 firmware/$$(TIMESTAMP)-right.uf2 + +clean: + rm ./firmware/*.uf2 + +firmware/%-left.uf2 firmware/%-right.uf2: config/adv360.keymap + docker run --rm -it --name zmk \ + -v $(PWD)/firmware:/app/firmware \ + -v $(PWD)/config:/app/config:ro \ + -e TIMESTAMP=$(TIMESTAMP) \ + zmk + +setup: Dockerfile bin/build.sh config/west.yml + docker build --tag zmk --file Dockerfile . diff --git a/README.md b/README.md index 4a916f8..c2878b5 100644 --- a/README.md +++ b/README.md @@ -14,14 +14,16 @@ ## To build Firmware locally using Docker -### Setup +### First run -1. Execute `setup.sh`. +1. Execute `make all`. +2. Check the `firmware` directory for the latest firmware build. -### Build firmware +### Subsequent runs -1. Execute `run.sh` -2. Check the `firmware` directory for the latest firmware build. +If the only file you have changed is `config/adv360.keymap`, execute `make build` and check the `firmware` directory for the latest firmware build. + +If you have changed other files in the `config` directory (such as `config/west.yml`) you will need to execute `make all` to rebuild the Docker image as well as the firmware. ### Flash firmware diff --git a/bin/build.sh b/bin/build.sh index 2f6c8cd..e783844 100755 --- a/bin/build.sh +++ b/bin/build.sh @@ -1,9 +1,9 @@ #!/usr/bin/env bash -set -e +set -eu PWD=$(pwd) -TIMESTAMP=$(date -u +"%Y%m%d%H%M%S") +TIMESTAMP="${TIMESTAMP:-$(date -u +"%Y%m%d%H%M%S")}" # West Build (left) west build -s zmk/app -d build/left -b adv360_left -- -DZMK_CONFIG="${PWD}/config" diff --git a/run.sh b/run.sh deleted file mode 100755 index 4fc5cac..0000000 --- a/run.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env bash - -set -e - -docker run -it --name zmk zmk -docker cp zmk:/app/firmware/ ./ -docker stop zmk -docker rm zmk diff --git a/setup.sh b/setup.sh deleted file mode 100755 index 96a478e..0000000 --- a/setup.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash - -set -e - -docker build --tag zmk .