Improve Makefile: Stop clobbering /vendor, detect submodule changes more intelligently
This commit is contained in:
parent
ad3da0694b
commit
184e4d5f98
137
Makefile
137
Makefile
@ -3,22 +3,30 @@
|
||||
circuitpy-deps \
|
||||
circuitpy-freeze-kmk-nrf \
|
||||
devdeps \
|
||||
freeze-nrf-vendor-deps \
|
||||
freeze-nrf-build-deps \
|
||||
lint
|
||||
|
||||
AMPY_PORT ?= /dev/ttyUSB0
|
||||
AMPY_BAUD ?= 115200
|
||||
AMPY_DELAY ?= 1.5
|
||||
ARDUINO ?= /usr/share/arduino
|
||||
PIPENV ?= $(shell which pipenv)
|
||||
|
||||
devdeps: Pipfile.lock
|
||||
@pipenv install --dev --ignore-pipfile
|
||||
@$(PIPENV) install --dev --ignore-pipfile
|
||||
|
||||
lint: devdeps
|
||||
@pipenv run flake8
|
||||
@$(PIPENV) run flake8
|
||||
|
||||
fix-isort: devdeps
|
||||
@find kmk/ user_keymaps/ -name "*.py" | xargs pipenv run isort
|
||||
@find kmk/ user_keymaps/ -name "*.py" | xargs $(PIPENV) run isort
|
||||
|
||||
clean:
|
||||
rm -rf .submodules .circuitpy-deps .micropython-deps build
|
||||
|
||||
powerwash: clean
|
||||
rm -rf vendor
|
||||
$(PIPENV) --rm
|
||||
|
||||
test: micropython-build-unix
|
||||
@echo "===> Testing keymap_sanity_check.py script"
|
||||
@ -32,102 +40,103 @@ test: micropython-build-unix
|
||||
@MICROPYPATH=tests/test_data:./ ./bin/micropython.sh bin/keymap_sanity_check.py keymaps/duplicate_row_pins.py 2>/dev/null && exit 1 || exit 0
|
||||
@echo "===> The sanity checker is sane, unlike klardotsh"
|
||||
|
||||
.submodules: .gitmodules
|
||||
.submodules: .gitmodules submodules.toml
|
||||
@echo "===> Pulling dependencies, this may take several minutes"
|
||||
@git submodule update --init --recursive
|
||||
@rsync -avh vendor/ build/
|
||||
@touch .submodules
|
||||
|
||||
.circuitpy-deps: .submodules
|
||||
@echo "===> Building circuitpython/mpy-cross"
|
||||
@make -C vendor/circuitpython/mpy-cross
|
||||
@make -C build/circuitpython/mpy-cross
|
||||
@echo "===> Pulling Nordic BLE stack"
|
||||
@cd vendor/circuitpython/ports/nrf && ./drivers/bluetooth/download_ble_stack.sh 2>/dev/null >/dev/null
|
||||
@cd build/circuitpython/ports/nrf && ./drivers/bluetooth/download_ble_stack.sh 2>/dev/null >/dev/null
|
||||
@touch .circuitpy-deps
|
||||
|
||||
.micropython-deps: .submodules
|
||||
@echo "===> Building micropython/mpy-cross"
|
||||
@make -C vendor/micropython/mpy-cross
|
||||
@make -C build/micropython/mpy-cross
|
||||
@touch .micropython-deps
|
||||
|
||||
submodules: .submodules
|
||||
circuitpy-deps: .circuitpy-deps
|
||||
|
||||
micropython-deps: .micropython-deps
|
||||
|
||||
vendor/micropython/ports/unix/micropython: micropython-deps vendor/micropython/ports/unix/modules/.kmk_frozen
|
||||
@make -j4 -C vendor/micropython/ports/unix
|
||||
build/micropython/ports/unix/micropython: micropython-deps build/micropython/ports/unix/modules/.kmk_frozen
|
||||
@make -j4 -C build/micropython/ports/unix
|
||||
|
||||
micropython-build-unix: vendor/micropython/ports/unix/micropython
|
||||
micropython-build-unix: build/micropython/ports/unix/micropython
|
||||
|
||||
freeze-nrf-vendor-deps: vendor/circuitpython/ports/nrf/freeze/.kmk_frozen
|
||||
freeze-teensy3.1-vendor-deps: vendor/micropython/ports/teensy/freeze/.kmk_frozen
|
||||
freeze-stm32-vendor-deps: vendor/micropython/ports/stm32/freeze/.kmk_frozen
|
||||
freeze-nrf-build-deps: build/circuitpython/ports/nrf/freeze/.kmk_frozen
|
||||
freeze-teensy3.1-build-deps: build/micropython/ports/teensy/freeze/.kmk_frozen
|
||||
freeze-stm32-build-deps: build/micropython/ports/stm32/freeze/.kmk_frozen
|
||||
|
||||
vendor/micropython/ports/unix/modules/.kmk_frozen: upy-freeze.txt
|
||||
@echo "===> Preparing vendored dependencies for local development"
|
||||
@rm -rf vendor/micropython/ports/unix/freeze/*
|
||||
@cat $< | xargs -I '{}' cp -a {} vendor/micropython/ports/unix/modules/
|
||||
build/micropython/ports/unix/modules/.kmk_frozen: upy-freeze.txt
|
||||
@echo "===> Preparing builded dependencies for local development"
|
||||
@rm -rf build/micropython/ports/unix/freeze/*
|
||||
@cat $< | xargs -I '{}' cp -a {} build/micropython/ports/unix/modules/
|
||||
@touch $@
|
||||
|
||||
vendor/circuitpython/ports/nrf/freeze/.kmk_frozen: upy-freeze.txt
|
||||
@echo "===> Preparing vendored dependencies for bundling"
|
||||
@rm -rf vendor/circuitpython/ports/nrf/freeze/*
|
||||
@cat $< | xargs -I '{}' cp -a {} vendor/circuitpython/ports/nrf/freeze/
|
||||
build/circuitpython/ports/nrf/freeze/.kmk_frozen: upy-freeze.txt
|
||||
@echo "===> Preparing builded dependencies for bundling"
|
||||
@rm -rf build/circuitpython/ports/nrf/freeze/*
|
||||
@cat $< | xargs -I '{}' cp -a {} build/circuitpython/ports/nrf/freeze/
|
||||
@touch $@
|
||||
|
||||
vendor/micropython/ports/teensy/freeze/.kmk_frozen: upy-freeze.txt
|
||||
@echo "===> Preparing vendored dependencies for bundling"
|
||||
@mkdir -p vendor/micropython/ports/teensy/freeze/
|
||||
@rm -rf vendor/micropython/ports/teensy/freeze/*
|
||||
@cat $< | xargs -I '{}' cp -a {} vendor/micropython/ports/teensy/freeze/
|
||||
build/micropython/ports/teensy/freeze/.kmk_frozen: upy-freeze.txt
|
||||
@echo "===> Preparing builded dependencies for bundling"
|
||||
@mkdir -p build/micropython/ports/teensy/freeze/
|
||||
@rm -rf build/micropython/ports/teensy/freeze/*
|
||||
@cat $< | xargs -I '{}' cp -a {} build/micropython/ports/teensy/freeze/
|
||||
@touch $@
|
||||
|
||||
vendor/micropython/ports/stm32/freeze/.kmk_frozen: upy-freeze.txt
|
||||
@echo "===> Preparing vendored dependencies for bundling"
|
||||
@mkdir -p vendor/micropython/ports/stm32/freeze/
|
||||
@rm -rf vendor/micropython/ports/stm32/freeze/*
|
||||
@cat $< | xargs -I '{}' cp -a {} vendor/micropython/ports/stm32/freeze/
|
||||
build/micropython/ports/stm32/freeze/.kmk_frozen: upy-freeze.txt
|
||||
@echo "===> Preparing builded dependencies for bundling"
|
||||
@mkdir -p build/micropython/ports/stm32/freeze/
|
||||
@rm -rf build/micropython/ports/stm32/freeze/*
|
||||
@cat $< | xargs -I '{}' cp -a {} build/micropython/ports/stm32/freeze/
|
||||
@touch $@
|
||||
|
||||
circuitpy-freeze-kmk-nrf: freeze-nrf-vendor-deps
|
||||
circuitpy-freeze-kmk-nrf: freeze-nrf-build-deps
|
||||
@echo "===> Preparing KMK source for bundling into CircuitPython"
|
||||
@rm -rf vendor/circuitpython/ports/nrf/kmk*
|
||||
@cp -av kmk vendor/circuitpython/ports/nrf/freeze/
|
||||
@rm -rf build/circuitpython/ports/nrf/kmk*
|
||||
@cp -av kmk build/circuitpython/ports/nrf/freeze/
|
||||
|
||||
micropython-freeze-kmk-teensy3.1: freeze-teensy3.1-vendor-deps
|
||||
micropython-freeze-kmk-teensy3.1: freeze-teensy3.1-build-deps
|
||||
@echo "===> Preparing KMK source for bundling into MicroPython"
|
||||
@rm -rf vendor/micropython/ports/teensy/kmk*
|
||||
@cp -av kmk vendor/micropython/ports/teensy/memzip_files/
|
||||
@rm -rf build/micropython/ports/teensy/kmk*
|
||||
@cp -av kmk build/micropython/ports/teensy/memzip_files/
|
||||
|
||||
micropython-freeze-kmk-stm32: freeze-stm32-vendor-deps
|
||||
micropython-freeze-kmk-stm32: freeze-stm32-build-deps
|
||||
@echo "===> Preparing KMK source for bundling into MicroPython"
|
||||
@rm -rf vendor/micropython/ports/stm32/freeze/kmk*
|
||||
@cp -av kmk vendor/micropython/ports/stm32/freeze/
|
||||
@rm -rf build/micropython/ports/stm32/freeze/kmk*
|
||||
@cp -av kmk build/micropython/ports/stm32/freeze/
|
||||
|
||||
circuitpy-build-nrf:
|
||||
@echo "===> Building CircuitPython"
|
||||
@make -C vendor/circuitpython/ports/nrf BOARD=feather_nrf52832 SERIAL=${AMPY_PORT} SD=s132 FROZEN_MPY_DIR=freeze clean all
|
||||
@make -C build/circuitpython/ports/nrf BOARD=feather_nrf52832 SERIAL=${AMPY_PORT} SD=s132 FROZEN_MPY_DIR=freeze clean all
|
||||
|
||||
circuitpy-flash-nrf: circuitpy-build-nrf
|
||||
@echo "===> Flashing CircuitPython with KMK and your keymap"
|
||||
@make -C vendor/circuitpython/ports/nrf BOARD=feather_nrf52832 SERIAL=${AMPY_PORT} SD=s132 FROZEN_MPY_DIR=freeze dfu-gen dfu-flash
|
||||
@make -C build/circuitpython/ports/nrf BOARD=feather_nrf52832 SERIAL=${AMPY_PORT} SD=s132 FROZEN_MPY_DIR=freeze dfu-gen dfu-flash
|
||||
|
||||
micropython-build-teensy3.1:
|
||||
@make -C vendor/micropython/ports/teensy/ BOARD=TEENSY_3.1 all
|
||||
@make -C build/micropython/ports/teensy/ BOARD=TEENSY_3.1 all
|
||||
|
||||
micropython-flash-teensy3.1: micropython-build-teensy3.1
|
||||
@make -C vendor/micropython/ports/teensy/ BOARD=TEENSY_3.1 deploy
|
||||
@make -C build/micropython/ports/teensy/ BOARD=TEENSY_3.1 deploy
|
||||
|
||||
micropython-build-pyboard:
|
||||
@make -j4 -C vendor/micropython/ports/stm32/ BOARD=PYBV11 FROZEN_MPY_DIR=freeze all
|
||||
@make -j4 -C build/micropython/ports/stm32/ BOARD=PYBV11 FROZEN_MPY_DIR=freeze all
|
||||
|
||||
micropython-flash-pyboard: micropython-build-pyboard
|
||||
@make -j4 -C vendor/micropython/ports/stm32/ BOARD=PYBV11 FROZEN_MPY_DIR=freeze deploy
|
||||
@make -j4 -C build/micropython/ports/stm32/ BOARD=PYBV11 FROZEN_MPY_DIR=freeze deploy
|
||||
|
||||
circuitpy-flash-nrf-entrypoint:
|
||||
@echo "===> Flashing entrypoint if it doesn't already exist"
|
||||
@sleep 2
|
||||
@-timeout -k 5s 10s pipenv run ampy -p ${AMPY_PORT} -d ${AMPY_DELAY} -b ${AMPY_BAUD} rm main.py 2>/dev/null
|
||||
@-timeout -k 5s 10s pipenv run ampy -p ${AMPY_PORT} -d ${AMPY_DELAY} -b ${AMPY_BAUD} put entrypoints/feather_nrf52832.py main.py
|
||||
@-timeout -k 5s 10s $(PIPENV) run ampy -p ${AMPY_PORT} -d ${AMPY_DELAY} -b ${AMPY_BAUD} rm main.py 2>/dev/null
|
||||
@-timeout -k 5s 10s $(PIPENV) run ampy -p ${AMPY_PORT} -d ${AMPY_DELAY} -b ${AMPY_BAUD} put entrypoints/feather_nrf52832.py main.py
|
||||
@echo "===> Flashed keyboard successfully!"
|
||||
|
||||
ifndef USER_KEYMAP
|
||||
@ -139,12 +148,12 @@ flash-feather-nrf52832:
|
||||
else
|
||||
build-feather-nrf52832: lint devdeps circuitpy-deps circuitpy-freeze-kmk-nrf
|
||||
@echo "===> Preparing keyboard script for bundling into CircuitPython"
|
||||
@cp -av ${USER_KEYMAP} vendor/circuitpython/ports/nrf/freeze/kmk_keyboard_user.py
|
||||
@cp -av ${USER_KEYMAP} build/circuitpython/ports/nrf/freeze/kmk_keyboard_user.py
|
||||
@$(MAKE) circuitpy-build-nrf
|
||||
|
||||
flash-feather-nrf52832: lint devdeps circuitpy-deps circuitpy-freeze-kmk-nrf
|
||||
@echo "===> Preparing keyboard script for bundling into CircuitPython"
|
||||
@cp -av ${USER_KEYMAP} vendor/circuitpython/ports/nrf/freeze/kmk_keyboard_user.py
|
||||
@cp -av ${USER_KEYMAP} build/circuitpython/ports/nrf/freeze/kmk_keyboard_user.py
|
||||
@$(MAKE) circuitpy-flash-nrf circuitpy-flash-nrf-entrypoint
|
||||
endif
|
||||
|
||||
@ -157,12 +166,12 @@ flash-teensy-3.1:
|
||||
else
|
||||
build-teensy-3.1: lint devdeps micropython-deps micropython-freeze-kmk-teensy3.1
|
||||
@echo "===> Preparing keyboard script for bundling into MicroPython"
|
||||
@cp -av ${USER_KEYMAP} vendor/micropython/ports/teensy/freeze/kmk_keyboard_user.py
|
||||
@cp -av ${USER_KEYMAP} build/micropython/ports/teensy/freeze/kmk_keyboard_user.py
|
||||
@$(MAKE) ARDUINO=${ARDUINO} micropython-build-teensy3.1
|
||||
|
||||
flash-teensy-3.1: lint devdeps micropython-deps micropython-freeze-kmk-teensy3.1
|
||||
@echo "===> Preparing keyboard script for bundling into MicroPython"
|
||||
@cp -av ${USER_KEYMAP} vendor/micropython/ports/teensy/freeze/kmk_keyboard_user.py
|
||||
@cp -av ${USER_KEYMAP} build/micropython/ports/teensy/freeze/kmk_keyboard_user.py
|
||||
@$(MAKE) ARDUINO=${ARDUINO} micropython-flash-teensy3.1
|
||||
endif
|
||||
|
||||
@ -182,22 +191,22 @@ endif
|
||||
ifndef SKIP_KEYMAP_VALIDATION
|
||||
@MICROPYPATH=./ ./bin/micropython.sh bin/keymap_sanity_check.py ${USER_KEYMAP}
|
||||
endif
|
||||
@cp -av ${USER_KEYMAP} vendor/micropython/ports/stm32/freeze/kmk_keyboard_user.py
|
||||
@cp -av ${USER_KEYMAP} build/micropython/ports/stm32/freeze/kmk_keyboard_user.py
|
||||
@$(MAKE) AMPY_PORT=/dev/ttyACM0 AMPY_BAUD=115200 micropython-build-pyboard
|
||||
|
||||
flash-pyboard: lint devdeps micropython-deps micropython-freeze-kmk-stm32
|
||||
@echo "===> Preparing keyboard script for bundling into MicroPython"
|
||||
@cp -av ${USER_KEYMAP} vendor/micropython/ports/stm32/freeze/kmk_keyboard_user.py
|
||||
@cp -av kmk/entrypoints/global.py vendor/micropython/ports/stm32/freeze/_main.py
|
||||
@cp -av kmk/entrypoints/handwire/pyboard_boot.py vendor/micropython/ports/stm32/freeze/_boot.py
|
||||
@cp -av ${USER_KEYMAP} build/micropython/ports/stm32/freeze/kmk_keyboard_user.py
|
||||
@cp -av kmk/entrypoints/global.py build/micropython/ports/stm32/freeze/_main.py
|
||||
@cp -av kmk/entrypoints/handwire/pyboard_boot.py build/micropython/ports/stm32/freeze/_boot.py
|
||||
@$(MAKE) micropython-flash-pyboard
|
||||
endif
|
||||
|
||||
reset-bootloader:
|
||||
@-timeout -k 5s 10s pipenv run ampy -p /dev/ttyACM0 -d ${AMPY_DELAY} -b ${AMPY_BAUD} run util/bootloader.py
|
||||
@-timeout -k 5s 10s $(PIPENV) run ampy -p /dev/ttyACM0 -d ${AMPY_DELAY} -b ${AMPY_BAUD} run util/bootloader.py
|
||||
|
||||
reset-board:
|
||||
@-timeout -k 5s 10s pipenv run ampy -p /dev/ttyACM0 -d ${AMPY_DELAY} -b ${AMPY_BAUD} run util/reset.py
|
||||
@-timeout -k 5s 10s $(PIPENV) run ampy -p /dev/ttyACM0 -d ${AMPY_DELAY} -b ${AMPY_BAUD} run util/reset.py
|
||||
|
||||
# Fully wipe the board with only stock CircuitPython
|
||||
burn-it-all-with-fire: lint devdeps
|
||||
@ -207,14 +216,14 @@ burn-it-all-with-fire: lint devdeps
|
||||
@echo "===> Pulling dependencies, this may take several minutes"
|
||||
@git submodule update --init --recursive
|
||||
@echo "===> Building circuitpython/mpy-cross"
|
||||
@make -C vendor/circuitpython/mpy-cross
|
||||
@make -C build/circuitpython/mpy-cross
|
||||
@echo "===> Pulling Nordic BLE stack"
|
||||
@cd vendor/circuitpython/ports/nrf && ./drivers/bluetooth/download_ble_stack.sh 2>/dev/null >/dev/null
|
||||
@cd build/circuitpython/ports/nrf && ./drivers/bluetooth/download_ble_stack.sh 2>/dev/null >/dev/null
|
||||
@echo "===> Preparing KMK source for bundling into CircuitPython"
|
||||
@rm -rf vendor/circuitpython/ports/nrf/*
|
||||
@rm -rf build/circuitpython/ports/nrf/*
|
||||
@echo "===> Building CircuitPython WITHOUT KMK or user keyboard script to induce ImportError"
|
||||
@$(MAKE) circuitpy-flash-nrf
|
||||
@echo "===> Wiping keyboard config"
|
||||
@sleep 2
|
||||
@-timeout -k 5s 10s pipenv run ampy -p ${AMPY_PORT} -d ${AMPY_DELAY} -b ${AMPY_BAUD} rm main.py 2>/dev/null
|
||||
@-timeout -k 5s 10s $(PIPENV) run ampy -p ${AMPY_PORT} -d ${AMPY_DELAY} -b ${AMPY_BAUD} rm main.py 2>/dev/null
|
||||
@echo "===> Wiped! Probably safe to flash keyboard, try Python serial REPL to verify?"
|
||||
|
4
submodules.toml
Normal file
4
submodules.toml
Normal file
@ -0,0 +1,4 @@
|
||||
[submodules]
|
||||
"vendor/circuitpython" = "d751740"
|
||||
"vendor/micropython" = "65a49fa"
|
||||
"vendor/upy-lib" = "f20d89c"
|
Loading…
Reference in New Issue
Block a user