From a3a0090d23d42c87144f0b3931906fc425e75b06 Mon Sep 17 00:00:00 2001 From: urob <978080+urob@users.noreply.github.com> Date: Wed, 7 Aug 2024 16:20:32 -0400 Subject: [PATCH] Add build recipe --- .gitignore | 2 ++ Justfile | 22 +++++++++++++++++----- flake.nix | 5 +++-- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 43e4bdb..148376e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ +.build .direnv .venv .west modules +firmware zmk diff --git a/Justfile b/Justfile index a3e32f8..68a8d35 100644 --- a/Justfile +++ b/Justfile @@ -1,13 +1,25 @@ default: @just --list --unsorted -# build firmware -build: - echo "Building firmware..." +build := ".build" +out := "firmware" -# clear build cache +# build firmware +build board *args: + #!/usr/bin/env bash + set -euo pipefail + BUILD="{{build}}/{{board}}" + echo "Building firmware..." + west build -d "$BUILD" -s zmk/app -b {{board}} {{args}} -- -DZMK_CONFIG="{{absolute_path('config')}}" + if [[ -f "$BUILD/zephyr/zmk.uf2" ]]; then + mkdir -p {{out}} && cp "$BUILD/zephyr/zmk.uf2" "{{out}}/{{board}}.uf2" + else + mkdir -p {{out}} && cp "$BUILD/zephyr/zmk.bin" "{{out}}/{{board}}.bin" + fi + +# clear build cache and artifacts clean: - rm -rf build + rm -rf {{build}} {{out}} # list all build targets list: diff --git a/flake.nix b/flake.nix index ec1dced..79f08fb 100644 --- a/flake.nix +++ b/flake.nix @@ -20,10 +20,11 @@ in { devShells.${system}.default = pkgs.mkShell { packages = [ - zephyr.sdkFull + zephyr.hosttools zephyr.pythonEnv - # zephyr.hosttools + zephyr.sdkFull pkgs.cmake + pkgs.dtc pkgs.ninja ]; };