diff options
| author | ReFil <31960031+ReFil@users.noreply.github.com> | 2022-10-23 17:51:39 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-10-23 17:51:39 +0000 |
| commit | ca29f73863f78898d8a8ac68ab68f1ff1b3af7c3 (patch) | |
| tree | 3e7bc3c7617ebb2ccf207e8f27deca57e09ce97a | |
| parent | d140f7bfb8eecd2efe74995143227eeec4a8b49a (diff) | |
| parent | 7e9cb93cf24f91be6cf2d921fe1ead4c7def9bf4 (diff) | |
Merge pull request #29 from joshfrench/makefile
Reusable Docker image
| -rw-r--r-- | Dockerfile | 3 | ||||
| -rw-r--r-- | Makefile | 20 | ||||
| -rw-r--r-- | README.md | 12 | ||||
| -rwxr-xr-x | bin/build.sh | 4 | ||||
| -rwxr-xr-x | run.sh | 8 | ||||
| -rwxr-xr-x | setup.sh | 5 |
6 files changed, 29 insertions, 23 deletions
@@ -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 . @@ -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" @@ -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 . |
