2019-02-22 14:39:41 +00:00
|
|
|
|
2019-02-25 05:54:45 +00:00
|
|
|
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))
|
2019-02-22 14:39:41 +00:00
|
|
|
|
|
|
|
build: micropython
|
|
|
|
|
2019-02-25 05:54:45 +00:00
|
|
|
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; \
|
|
|
|
)
|
2019-02-22 14:39:41 +00:00
|
|
|
|
2019-02-25 05:54:45 +00:00
|
|
|
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
|
|
|
|
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) $<) $@
|
|
|
|
|
|
|
|
|
|
|
|
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); \
|
|
|
|
)
|
2019-02-22 14:39:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
check-and-reinit-submodules:
|
2019-02-25 05:54:45 +00:00
|
|
|
@echo ":: Checking submodules"
|
2019-02-22 14:39:41 +00:00
|
|
|
@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
|
2019-02-25 05:54:45 +00:00
|
|
|
@echo -n ":: Checking micropython submodules: "
|
2019-02-22 14:39:41 +00:00
|
|
|
@if cd micropython; git submodule status | egrep -q '^[-]|^[+]' ; then \
|
2019-02-25 05:54:45 +00:00
|
|
|
echo "info: Need to reinitialize micropython git submodules"; \
|
2019-02-22 14:39:41 +00:00
|
|
|
git submodule update --init; \
|
2019-02-25 05:54:45 +00:00
|
|
|
else \
|
|
|
|
echo "success"; \
|
2019-02-22 14:39:41 +00:00
|
|
|
fi
|
|
|
|
|
2019-02-25 05:54:45 +00:00
|
|
|
.PHONY: check-and-reinit-submodules check-and-reinit-micropython-submodules check-esp-sdk clean
|