From 1d14ffdb3007ee906a59e0392d4ae78f797d8e77 Mon Sep 17 00:00:00 2001 From: Josh French Date: Tue, 11 Oct 2022 11:13:38 -0400 Subject: [PATCH 1/7] Use makefile for a reusable docker image --- Dockerfile | 4 +--- Makefile | 21 +++++++++++++++++++++ bin/build.sh | 4 ++-- 3 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 Makefile diff --git a/Dockerfile b/Dockerfile index dd98a29ef2..cf25a84fb3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,4 @@ -FROM zmkfirmware/zmk-build-arm:2.4 - -RUN mkdir -p /app/firmware +FROM zmkfirmware/zmk-build-arm:stable WORKDIR /app diff --git a/Makefile b/Makefile new file mode 100644 index 0000000000..7849774e53 --- /dev/null +++ b/Makefile @@ -0,0 +1,21 @@ +.PHONY: clean timestamp setup + +all: setup build + +build: timestamp firmware/$$(TIMESTAMP)-left.uf2 firmware/$$(TIMESTAMP)-right.uf2 + +clean: + rm ./firmware/*.uf2 + +firmware/%-left.uf2 firmware/%-right.uf2: config/adv360.keymap timestamp + docker run --rm -it --name zmk \ + -v $(PWD)/firmware:/app/firmware \ + -v $(PWD)/config:/app/config:ro \ + -e TIMESTAMP=$(TIMESTAMP) \ + zmk + +setup: + docker build --tag zmk . + +timestamp: + $(eval TIMESTAMP:=$(shell date -u +"%Y%m%d%H%M%S")) diff --git a/bin/build.sh b/bin/build.sh index 2f6c8cde64..e783844840 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" From b3e58a53b89c014f61c0afbcb72c37ed5f89771e Mon Sep 17 00:00:00 2001 From: Josh French Date: Tue, 11 Oct 2022 11:24:22 -0400 Subject: [PATCH 2/7] Update docs --- README.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 4a916f810d..c2878b5230 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 From 1660f0c75eab5d286d4daa07cdf67953eda2928a Mon Sep 17 00:00:00 2001 From: Josh French Date: Tue, 11 Oct 2022 11:26:42 -0400 Subject: [PATCH 3/7] this is being handled elsewhere --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index cf25a84fb3..7793f6f07d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM zmkfirmware/zmk-build-arm:stable +FROM zmkfirmware/zmk-build-arm:2.4 WORKDIR /app From 3b0bfd72febab6990f713c9db26e82f8be956890 Mon Sep 17 00:00:00 2001 From: Josh French Date: Tue, 11 Oct 2022 11:32:30 -0400 Subject: [PATCH 4/7] Remove old scripts --- run.sh | 8 -------- setup.sh | 5 ----- 2 files changed, 13 deletions(-) delete mode 100755 run.sh delete mode 100755 setup.sh diff --git a/run.sh b/run.sh deleted file mode 100755 index 4fc5cacccd..0000000000 --- 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 96a478e774..0000000000 --- a/setup.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash - -set -e - -docker build --tag zmk . From 90c3c41b9dfa44c6e9d99f277bf6c44ce8de3699 Mon Sep 17 00:00:00 2001 From: Josh French Date: Tue, 11 Oct 2022 12:15:49 -0400 Subject: [PATCH 5/7] We only need config/west.yml at this stage --- Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 7793f6f07d..388cdc5021 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,7 +11,6 @@ RUN west update # West Zephyr export RUN west zephyr-export -COPY config config COPY bin/build.sh ./ CMD ["./build.sh"] From 4f09557004c1ef073d5b816432814293bf130f14 Mon Sep 17 00:00:00 2001 From: Josh French Date: Wed, 12 Oct 2022 16:08:31 -0400 Subject: [PATCH 6/7] Specify setup prereqs Co-authored-by: Ed Flanagan --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 7849774e53..0e6afcd9e7 100644 --- a/Makefile +++ b/Makefile @@ -14,8 +14,8 @@ firmware/%-left.uf2 firmware/%-right.uf2: config/adv360.keymap timestamp -e TIMESTAMP=$(TIMESTAMP) \ zmk -setup: - docker build --tag zmk . +setup: Dockerfile bin/build.sh config/west.yml + docker build --tag zmk --file Dockerfile . timestamp: $(eval TIMESTAMP:=$(shell date -u +"%Y%m%d%H%M%S")) From 7e9cb93cf24f91be6cf2d921fe1ead4c7def9bf4 Mon Sep 17 00:00:00 2001 From: Josh French Date: Thu, 13 Oct 2022 10:22:16 -0400 Subject: [PATCH 7/7] timestamp doesn't need to be a target --- Makefile | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 0e6afcd9e7..ea54d90d64 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,15 @@ -.PHONY: clean timestamp setup +TIMESTAMP := $(shell date -u +"%Y%m%d%H%M%S") + +.PHONY: clean setup all: setup build -build: timestamp firmware/$$(TIMESTAMP)-left.uf2 firmware/$$(TIMESTAMP)-right.uf2 +build: firmware/$$(TIMESTAMP)-left.uf2 firmware/$$(TIMESTAMP)-right.uf2 clean: rm ./firmware/*.uf2 -firmware/%-left.uf2 firmware/%-right.uf2: config/adv360.keymap timestamp +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 \ @@ -16,6 +18,3 @@ firmware/%-left.uf2 firmware/%-right.uf2: config/adv360.keymap timestamp setup: Dockerfile bin/build.sh config/west.yml docker build --tag zmk --file Dockerfile . - -timestamp: - $(eval TIMESTAMP:=$(shell date -u +"%Y%m%d%H%M%S"))