Skip to content

Commit

Permalink
Update build files
Browse files Browse the repository at this point in the history
  • Loading branch information
calebdw committed Oct 3, 2023
1 parent e63586b commit b736bdf
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 13 deletions.
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ WORKDIR /app

COPY config/west.yml config/west.yml

RUN west init -l config \
RUN mkdir -p build \
&& west init -l config \
&& west update \
&& west zephyr-export

Expand Down
16 changes: 8 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@ DOCKER := $(shell { command -v podman || command -v docker; })
.PHONY: all clean distclean

all:
$(DOCKER) zmk_build --tag zmk-config --build-arg USER_ID=$(shell id -u) .
$(DOCKER) volume create zmk_app
$(DOCKER) run --rm -it --name zmk-config -u zmk \
-v zmk_app:/app \
$(DOCKER) build --tag zmk-build-user-config --build-arg USER_ID=$(shell id -u) .
$(DOCKER) volume create zmk_build
$(DOCKER) run --rm -it --name zmk-build-user-config -u zmk \
-v zmk_build:/app/build \
-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-config
zmk-build-user-config

clean:
rm -rf firmware/[^.]*
-$(DOCKER) volume rm build config firmware
-$(DOCKER) volume rm zmk_app
-$(DOCKER) volume rm zmk_build

distclean: clean
-$(DOCKER) image rm zmk-config
-$(DOCKER) image rm zmk-build-user-config
-$(DOCKER) system prune
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ OUTPUT_ZMK_CONFIG=1 make
The configs with then be outputted to the `firmware` directory along with the firmware files.

#### Build Cache
A docker volume is used to cache the build artifacts, this allows subsequent builds to compile faster.
A docker volume is used to cache the build artifacts, allowing subsequent builds to compile faster.

### Cleanup

Expand Down
13 changes: 10 additions & 3 deletions bin/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ 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}"
filename="${PWD}/firmware/${timestamp}-${artifact_name}"
build_dir="${PWD}/build/${artifact_name}"

echo ""
echo "-----------------"
Expand All @@ -30,7 +30,14 @@ while IFS=$',' read -r board shield; do
| sort > "${filename}.config"
fi

cp ${build_dir}/zephyr/zmk.uf2 "${filename}.uf2"
extensions="uf2 hex bin"
for extension in $extensions; do
artifact=${build_dir}/zephyr/zmk.$extension
if [[ -f $artifact ]]; then
cp $artifact "${filename}.$extension"
break
fi
done
done < <(yq '
[{"board": .board[], "shield": .shield[] // ""}] + .include
| filter(.board)
Expand Down

0 comments on commit b736bdf

Please sign in to comment.