Refactor Makefile copy-* targets for improved readability

This commit is contained in:
xs5871 2023-02-24 17:58:40 +00:00 committed by xs5871
parent 6ab4154ad5
commit 88c3616b6a

View File

@ -102,65 +102,44 @@ reset-board:
@echo "===> Rebooting your board (safe to ignore file not found errors)" @echo "===> Rebooting your board (safe to ignore file not found errors)"
@-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
ifdef MOUNTPOINT
$(MOUNTPOINT)/kmk/.copied: $(shell find kmk/ -name "*.py" | xargs -0)
@echo "===> Copying KMK source folder"
@rsync -rh kmk $(MOUNTPOINT)/
@touch $(MOUNTPOINT)/kmk/.copied
@sync
ifdef MOUNTPOINT ifdef MOUNTPOINT
ifdef BOARD
copy-board:
@echo "===> Copying your board from $(BOARD) to $(MOUNTPOINT)"
@rsync -rhu $(BOARD)/*.py $(MOUNTPOINT)/
@sync
else # BOARD
copy-board:
@echo "**** Missing BOARD argument ****" && exit 1
endif # BOARD
copy-bootpy:
@echo "===> Copying required boot.py"
@rsync -rhu boot.py $(MOUNTPOINT)/boot.py
@sync
copy-compiled: copy-compiled:
@echo "===> Copying compiled KMK folder" @echo "===> Copying compiled KMK folder"
@rsync -urh $(MPY_TARGET_DIR)/* $(MOUNTPOINT)/ @rsync -rhu $(MPY_TARGET_DIR)/* $(MOUNTPOINT)/
@sync
else
copy-compiled:
@echo "**** MOUNTPOINT must be defined (wherever your CIRCUITPY drive is mounted) ****" && exit 1
endif
copy-kmk: $(MOUNTPOINT)/kmk/.copied
else
copy-kmk:
echo "**** MOUNTPOINT must be defined (wherever your CIRCUITPY drive is mounted) ****" && exit 1
endif
ifdef MOUNTPOINT
copy-board:
@echo "===> Copying your board to $(MOUNTPOINT)"
@rsync -urh $(BOARD)/*.py $(MOUNTPOINT)/
@sync
else
copy-board:
@echo "**** MOUNTPOINT must be defined (wherever your CIRCUITPY drive is mounted) ****" && exit 1
endif
ifdef MOUNTPOINT
$(MOUNTPOINT)/kmk/boot.py: boot.py
@echo "===> Copying required boot.py"
@rsync -rh boot.py $(MOUNTPOINT)/
@sync @sync
copy-bootpy: $(MOUNTPOINT)/kmk/boot.py ifdef USER_KEYMAP
else copy-keymap:
copy-bootpy:
echo "**** MOUNTPOINT must be defined (wherever your CIRCUITPY drive is mounted) ****" && exit 1
endif
ifdef MOUNTPOINT
ifndef USER_KEYMAP
$(MOUNTPOINT)/main.py:
@echo "**** USER_KEYMAP must be defined (ex. USER_KEYMAP=user_keymaps/noop.py) ****" && exit 1
else
$(MOUNTPOINT)/main.py: $(USER_KEYMAP)
@echo "===> Copying your keymap to main.py" @echo "===> Copying your keymap to main.py"
@rsync -rh $(USER_KEYMAP) $@ @rsync -rhu $(USER_KEYMAP) $(MOUNTPOINT)/main.py
@sync @sync
else # USER_KEYMAP
copy-keymap:
@echo "**** Missing USER_KEYMAP argument ****" && exit 1
endif # USER_KEYMAP endif # USER_KEYMAP
copy-keymap: $(MOUNTPOINT)/main.py copy-kmk:
else @echo "===> Copying KMK source folder"
copy-keymap: @rsync -rhu kmk $(MOUNTPOINT)/
echo "**** MOUNTPOINT must be defined (wherever your CIRCUITPY drive is mounted) ****" && exit 1 @sync
endif # MOUNTPOINT else # MOUNTPOINT
copy-board copy-bootpy copy-compiled copy-keymap copy-kmk:
@echo "**** MOUNTPOINT must be defined (wherever your CIRCUITPY drive is mounted) ****" && exit 1
endif # ifndef MOUNTPOINT