Makefile can compile KMK to MPY files

This commit is contained in:
Josh Klar 2019-07-20 15:50:56 -07:00
parent ffe3fa3c64
commit 8f5511327e
No known key found for this signature in database
GPG Key ID: A4A0C7B4E8EEE222
2 changed files with 18 additions and 5 deletions

View File

@ -1,5 +1,3 @@
# vim: ft=dockerfile
FROM python:3.7-alpine
RUN mkdir -p /app

View File

@ -12,13 +12,28 @@ DOCKER_TAG ?= latest
AMPY_PORT ?= /dev/ttyUSB0
AMPY_BAUD ?= 115200
AMPY_DELAY ?= 1.5
PIPENV ?= $(shell which pipenv)
PIPENV ?= $(shell which pipenv 2>/dev/null)
MPY_CROSS ?= $(shell which mpy-cross 2>/dev/null)
MPY_FLAGS ?= '-O2'
MPY_SOURCES = 'kmk/'
MPY_TARGET_DIR ?= .compiled
all: copy-kmk copy-bootpy copy-keymap
.docker_base: Dockerfile_base
compile: $(MPY_TARGET_DIR)/.mpy.compiled
ifeq ($(MPY_CROSS),)
@echo "===> Could not find mpy-cross in PATH, exiting"
@false
endif
$(MPY_TARGET_DIR)/.mpy.compiled: $(shell find $(MPY_SOURCES) -name "*.py")
@mkdir -p $(MPY_TARGET_DIR)
@find $(MPY_SOURCES) -name "*.py" -exec sh -c 'mkdir -p $(MPY_TARGET_DIR)/$$(dirname {}) && mpy-cross $(MPY_FLAGS) {} -o $(MPY_TARGET_DIR)/$$(dirname {})/$$(basename -s .py {}).mpy' \;
.docker_base: Dockerfile
@echo "===> Building Docker base image kmkfw/base:${DOCKER_BASE_TAG}"
@docker build -f Dockerfile_base -t kmkfw/base:${DOCKER_BASE_TAG} .
@docker build -t kmkfw/base:${DOCKER_BASE_TAG} .
@touch .docker_base
docker-base: .docker_base