micropython-apploader/Makefile

88 lines
2.4 KiB
Makefile
Raw Normal View History

export PATH := $(CURDIR)/esp-open-sdk/xtensa-lx106-elf/bin:$(PATH)
export CPATH := $(CURDIR)/esp-open-sdk/sdk/include:$(CPATH)
MP_PORT = micropython/ports/esp8266
MOD_DIR = $(MP_PORT)/modules
MP_UNIX = micropython/ports/unix/micropython
SRC_MODULES = src/app_loader.py src/settings.py
# MOD_TO_SRC_REL = $(shell realpath --relative-to $(MOD_DIR) src)
LIB_SYMLINKS = $(patsubst src/%.py,$(MOD_DIR)/%.py,$(SRC_MODULES))
# LIB_SYMLINK_TARGETS = $(patsubst %.py,$(MOD_DIR)/%.py,$(SRC_MODULES))
build: micropython
clean:
$(MAKE) -C $(MP_PORT) clean clean-frozen
rm .requirements.txt.installed
deploy: micropython
( \
[ -f python2-venv/bin/activate ] && source python2-venv/bin/activate; \
$(MAKE) -C $(MP_PORT) deploy BAUD=460800; \
)
erase: micropython
( \
[ -f python2-venv/bin/activate ] && source python2-venv/bin/activate; \
$(MAKE) -C $(MP_PORT) erase; \
)
check-esp-sdk:
@echo -n ":: Checking ESP SDK: "
@if (which xtensa-lx106-elf-gcc 2> /dev/null) ; then \
echo "success"; \
else \
echo "error: SDK not found. Add the location of xtensa-lx106-elf-gcc to PATH or run setup_sdk.sh to install the SDK locally"; \
false; \
fi
.requirements.txt.installed: requirements.txt $(MP_UNIX)
cat requirements.txt | xargs -n1 $(MP_UNIX) -m upip install -p $(MOD_DIR)
touch $@
$(MOD_DIR)/%.py: src/%.py
ln -s $(shell realpath --relative-to $(MOD_DIR) $<) $@
$(MP_UNIX):
make -C micropython/ports/unix
frozen-libs: .requirements.txt.installed $(LIB_SYMLINKS)
micropython: micropython/ports/esp8266/build/firmware-combined.bin
micropython/ports/esp8266/build/firmware-combined.bin: check-and-reinit-micropython-submodules check-esp-sdk frozen-libs
$(MAKE) -C micropython/mpy-cross
( \
[ -f python2-venv/bin/activate ] && source python2-venv/bin/activate; \
$(MAKE) -C $(MP_PORT); \
)
check-and-reinit-submodules:
@echo ":: Checking submodules"
@if git submodule status | egrep -q '^[-]|^[+]' ; then \
echo "INFO: Need to reinitialize git submodules"; \
git submodule update --init; \
fi
check-and-reinit-micropython-submodules: check-and-reinit-submodules
@echo -n ":: Checking micropython submodules: "
@if cd micropython; git submodule status | egrep -q '^[-]|^[+]' ; then \
echo "info: Need to reinitialize micropython git submodules"; \
git submodule update --init; \
else \
echo "success"; \
fi
.PHONY: check-and-reinit-submodules check-and-reinit-micropython-submodules check-esp-sdk clean