Reworked build system

master
Mark 2022-11-18 23:33:15 -08:00
parent 6e84592338
commit 7082172bc4
Signed by: Mark
GPG Key ID: AD62BB059C2AAEE4
8 changed files with 16 additions and 118 deletions

4
.gitignore vendored
View File

@ -1,5 +1,3 @@
/venv
/build
qmk/qmk.conf
output
secrets.h

10
.gitmodules vendored
View File

@ -1,10 +0,0 @@
[submodule "qmk/qmk_fw"]
path = qmk/qmk_fw
url = ssh://git@git.betalupi.com:33/mirrors-QMK/qmk_firmware.git
[submodule "qmk/qmk_cli"]
path = qmk/qmk_cli
url = ssh://git@git.betalupi.com:33/mirrors-QMK/qmk_cli.git
[submodule "qmk_cli"]
url = ssh://git@git.betalupi.com:33/QMK/qmk_cli.git
[submodule "qmk_fw"]
url = ssh://git@git.betalupi.com:33/QMK/qmk_firmware.git

View File

@ -1,85 +0,0 @@
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 -sT \
$(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
# Compile and flash a keyboard
.PHONY: comp-db
comp-db:
@source $(VENV)/bin/activate && \
$(QMK) generate-compilation-database \
-kb betalupi_ergodox \
-km default

View File

@ -13,22 +13,8 @@ This repository contains everything required to build qmk firmware.
-------------------------------------------------
## Setup
To initialize the build environment, run `make setup`. This does a few things:
## Building
- 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`.
Run `./build.sh`. Uses docker, doesn't need a local install of qmk.

13
build.sh Executable file
View File

@ -0,0 +1,13 @@
#!/bin/bash
# Uses the qmk container found here:
# https://git.betalupi.com/Mark/docker
#
# Be careful, it may not be using the latest QMK.
docker run -it \
--user $(id -u):$(id -g) \
-v "$(pwd)/output:/build_output" \
-v "$(pwd)/keyboards:/qmk_firmware/keyboards:ro" \
-e QMK_TARGET="betalupi_ergodox:default" \
git.betalupi.com/mark/qmk

2
qmk.sh
View File

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

@ -1 +0,0 @@
Subproject commit 7cb41c2daa0e90ced9bbb25e46df810aded78d9c

@ -1 +0,0 @@
Subproject commit 2106acc24a5c223a5429ea5413bd78f6f0ad038c