zephyr: Use zephyr build system to merge configurations.
The zephyr build system supports merging application-level board configurations, so there is no need to reproduce this functionality in MicroPython. If CONF_FILE is not explicitly set, then the zephyr build system looks for prj.conf in the application directory. Therefore we rename the MicroPython prj_base.conf to prj.conf. Furthermore, if the zephyr build system finds boards/$(BOARD).conf in the application directory, it merges that configuration with prj.conf. Therefore we rename all the MicroPython board .conf files and move them into a boards/ directory. The minimal configuration, prj_minimal.conf, is left in the application directory because it is used as an explicitly set CONF_FILE in make-minimal.
This commit is contained in:
parent
138a28dc07
commit
25434e976b
@ -8,7 +8,6 @@
|
|||||||
# To build a "minimal" configuration, use "make-minimal" wrapper.
|
# To build a "minimal" configuration, use "make-minimal" wrapper.
|
||||||
|
|
||||||
BOARD ?= qemu_x86
|
BOARD ?= qemu_x86
|
||||||
CONF_FILE = prj_$(BOARD)_merged.conf
|
|
||||||
OUTDIR_PREFIX = $(BOARD)
|
OUTDIR_PREFIX = $(BOARD)
|
||||||
|
|
||||||
# Default heap size is 16KB, which is on conservative side, to let
|
# Default heap size is 16KB, which is on conservative side, to let
|
||||||
@ -92,26 +91,23 @@ build/genhdr/qstr.i.last: | $(Z_EXPORTS)
|
|||||||
LIBMICROPYTHON_EXTRA_CMD = -$(RM) -f outdir/$(OUTDIR_PREFIX)/zephyr.lnk
|
LIBMICROPYTHON_EXTRA_CMD = -$(RM) -f outdir/$(OUTDIR_PREFIX)/zephyr.lnk
|
||||||
|
|
||||||
# MicroPython's global clean cleans everything, fast
|
# MicroPython's global clean cleans everything, fast
|
||||||
CLEAN_EXTRA = outdir libmicropython.a prj_*_merged.conf
|
CLEAN_EXTRA = outdir libmicropython.a
|
||||||
|
|
||||||
# Clean Zephyr things in Zephyr way
|
# Clean Zephyr things in Zephyr way
|
||||||
z_clean:
|
z_clean:
|
||||||
$(MAKE) -f Makefile.zephyr BOARD=$(BOARD) clean
|
$(MAKE) -f Makefile.zephyr BOARD=$(BOARD) clean
|
||||||
|
|
||||||
# This rule is for prj_$(BOARD)_merged.conf, not $(CONF_FILE), which
|
|
||||||
# can be overriden.
|
|
||||||
# prj_$(BOARD).conf is optional, that's why it's resolved with $(wildcard)
|
|
||||||
# function.
|
|
||||||
prj_$(BOARD)_merged.conf: prj_base.conf $(wildcard prj_$(BOARD).conf)
|
|
||||||
$(PYTHON) makeprj.py prj_base.conf prj_$(BOARD).conf $@
|
|
||||||
|
|
||||||
test:
|
test:
|
||||||
cd $(TOP)/tests && ./run-tests --target minimal --device "execpty:make -C ../ports/zephyr run BOARD=$(BOARD) QEMU_PTY=1"
|
cd $(TOP)/tests && ./run-tests --target minimal --device "execpty:make -C ../ports/zephyr run BOARD=$(BOARD) QEMU_PTY=1"
|
||||||
|
|
||||||
cmake: outdir/$(BOARD)/Makefile
|
cmake: outdir/$(BOARD)/Makefile
|
||||||
|
|
||||||
outdir/$(BOARD)/Makefile: $(CONF_FILE)
|
ifneq ($(CONF_FILE),)
|
||||||
mkdir -p outdir/$(BOARD) && cmake -DBOARD=$(BOARD) -DCONF_FILE=$(CONF_FILE) -Boutdir/$(BOARD) -H.
|
CMAKE_MOD += -DCONF_FILE=$(CONF_FILE)
|
||||||
|
endif
|
||||||
|
|
||||||
|
outdir/$(BOARD)/Makefile:
|
||||||
|
mkdir -p outdir/$(BOARD) && cmake -DBOARD=$(BOARD) $(CMAKE_MOD) -Boutdir/$(BOARD) -H.
|
||||||
|
|
||||||
$(Z_EXPORTS): outdir/$(BOARD)/Makefile
|
$(Z_EXPORTS): outdir/$(BOARD)/Makefile
|
||||||
make --no-print-directory -C outdir/$(BOARD) outputexports CMAKE_COMMAND=: >$@
|
make --no-print-directory -C outdir/$(BOARD) outputexports CMAKE_COMMAND=: >$@
|
||||||
|
@ -1,29 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
import sys
|
|
||||||
import os
|
|
||||||
import hashlib
|
|
||||||
|
|
||||||
|
|
||||||
def hash_file(fname):
|
|
||||||
if not os.path.exists(fname):
|
|
||||||
return b""
|
|
||||||
hasher = hashlib.md5()
|
|
||||||
with open(fname, "rb") as f:
|
|
||||||
hasher.update(f.read())
|
|
||||||
return hasher.digest()
|
|
||||||
|
|
||||||
|
|
||||||
old_digest = hash_file(sys.argv[3])
|
|
||||||
|
|
||||||
with open(sys.argv[3] + ".tmp", "wb") as f:
|
|
||||||
f.write(open(sys.argv[1], "rb").read())
|
|
||||||
if os.path.exists(sys.argv[2]):
|
|
||||||
f.write(open(sys.argv[2], "rb").read())
|
|
||||||
|
|
||||||
new_digest = hash_file(sys.argv[3] + ".tmp")
|
|
||||||
|
|
||||||
if new_digest != old_digest:
|
|
||||||
print("Replacing")
|
|
||||||
os.rename(sys.argv[3] + ".tmp", sys.argv[3])
|
|
||||||
else:
|
|
||||||
os.remove(sys.argv[3] + ".tmp")
|
|
Loading…
x
Reference in New Issue
Block a user