Added build files

master
Mark 2022-07-09 14:25:45 -07:00
parent 068134e368
commit 01e1e510a0
Signed by: Mark
GPG Key ID: AD62BB059C2AAEE4
3 changed files with 108 additions and 0 deletions

75
Makefile Normal file
View File

@ -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

31
README.md Normal file
View File

@ -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`.

2
qmk.sh Executable file
View File

@ -0,0 +1,2 @@
#!/bin/bash
qmk --config-file qmk/qmk.conf "$@"