From 01e1e510a0d524ecb21f6df9382359494b065c47 Mon Sep 17 00:00:00 2001 From: Mark Date: Sat, 9 Jul 2022 14:25:45 -0700 Subject: [PATCH] Added build files --- Makefile | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 31 +++++++++++++++++++++++ qmk.sh | 2 ++ 3 files changed, 108 insertions(+) create mode 100644 Makefile create mode 100644 README.md create mode 100755 qmk.sh diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..cc308f1 --- /dev/null +++ b/Makefile @@ -0,0 +1,75 @@ +QMK_REPO := ssh://git@git.betalupi.com:33/Mark/qmk_betalupi.git + +# QMK command +QMK_CONF := $(shell pwd)/qmk/qmk.conf +QMK := qmk --config-file $(QMK_CONF) + +# Where to create venv +VENV := $(shell pwd)/venv + +# Where to build firmware +BUILD_DIR := $(shell pwd)/build + +# Path to submodules +QMK_CLI := $(shell pwd)/qmk/qmk_cli +QMK_DIR := $(shell pwd)/qmk/qmk_fw + + +.PHONY: git-submodule +git-submodule: + @git submodule sync --recursive + @git submodule update --init --recursive --progress + @echo "" + + +# Link keyboards into qmk_fw +KEYBOARDS := $(notdir $(shell find keyboards -maxdepth 1 -mindepth 1 -type d)) +.PHONY: $(KEYBOARDS) +$(KEYBOARDS): + @echo "Linking keyboards into $(QMK_DIR)/keyboards..." + @ln -s \ + $(shell pwd)/keyboards/$@ \ + $(QMK_DIR)/keyboards/$@ + + @echo "" + +# Clone all repos and configure qmk +.PHONY: setup +setup: git-submodule $(KEYBOARDS) + @echo "Preparing venv..." + @python -m venv $(VENV) --prompt=qmk_venv + + @echo "Building and installing qmk_cli" + @source $(VENV)/bin/activate && \ + cd $(QMK_CLI) && \ + python3 -m pip install build --quiet && \ + python3 -m build > /dev/null && \ + python3 -m pip install $$(find dist -name 'qmk-*.tar.gz') --quiet + + @echo "" + @echo "" + + @source $(VENV)/bin/activate && \ + $(QMK) config user.qmk_home=$(QMK_DIR) && \ + $(QMK) doctor + + +# Undo all changes done in setup +.PHONY: unsetup +unsetup: + -rm -drf $(VENV) $(BUILD_DIR) + -rm $(QMK_CONF) + -rm -dr $(QMK_CLI)/dist $(QMK_CLI)/qmk.egg-info + -rm $(KEYBOARDS:%=$(QMK_DIR)/keyboards/%) + + + +# Compile and flash a keyboard +.PHONY: flash +flash: + @source $(VENV)/bin/activate && \ + $(QMK) flash \ + -e AVR_CFLAGS="-Wno-array-bounds" \ + -e BUILD_DIR=$(BUILD_DIR) \ + -kb betalupi_ergodox \ + -km default diff --git a/README.md b/README.md new file mode 100644 index 0000000..7e93473 --- /dev/null +++ b/README.md @@ -0,0 +1,31 @@ +# Betalupi QMK environment + +This repository contains everything required to build qmk firmware. + + +### TODO + [ ] Better build/flash command + [ ] Warning when directory is moved + + +------------------------------------------------- + +## Setup + +To initialize the build environment, run `make setup`. This does a few things: + + - Updates all submodules + - Symlinks all directories in `keyboards` into `qmk/qmk_fm/keyboards` + - Creates a python virtualenv in `venv` + - Builds and installs `qmk/qmk_cli` into that venv + - Creates a QMK config file in `qmk/qmk.conf` + - Runs `qmk doctor` to make sure everything worked. + +ONCE `make setup` has been run, this directory (or its parents) CANNOT BE RENAMED OR MOVED! \\ +If you want to move this directory, run `make unsetup`, then run `make setup` again. No data should be lost. + + +## Using QMK + +Run `make flash` to build and flash firmware. If you want to execute qmk manually, activate the virtualenv and use `./qmk.sh`. + diff --git a/qmk.sh b/qmk.sh new file mode 100755 index 0000000..245fc43 --- /dev/null +++ b/qmk.sh @@ -0,0 +1,2 @@ +#!/bin/bash +qmk --config-file qmk/qmk.conf "$@"