diff options
author | Maureen Helm <maureen.helm@nxp.com> | 2020-05-02 14:56:27 -0500 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2020-05-05 00:48:44 +1000 |
commit | 25434e976b8d59046e1f49e13d577c1221468c2e (patch) | |
tree | 6b1e0ae3bd414b87e88b9ceede177af611164660 | |
parent | 138a28dc07fdbe633c225e05bee064a6eb41b532 (diff) |
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.
-rw-r--r-- | ports/zephyr/Makefile | 18 | ||||
-rw-r--r-- | ports/zephyr/boards/96b_carbon.conf (renamed from ports/zephyr/prj_96b_carbon.conf) | 0 | ||||
-rw-r--r-- | ports/zephyr/boards/disco_l475_iot1.conf (renamed from ports/zephyr/prj_disco_l475_iot1.conf) | 0 | ||||
-rw-r--r-- | ports/zephyr/boards/frdm_k64f.conf (renamed from ports/zephyr/prj_frdm_k64f.conf) | 0 | ||||
-rw-r--r-- | ports/zephyr/boards/frdm_kw41z.conf (renamed from ports/zephyr/prj_frdm_kw41z.conf) | 0 | ||||
-rw-r--r-- | ports/zephyr/boards/mimxrt1050_evk.conf (renamed from ports/zephyr/prj_mimxrt1050_evk.conf) | 0 | ||||
-rw-r--r-- | ports/zephyr/boards/qemu_cortex_m3.conf (renamed from ports/zephyr/prj_qemu_cortex_m3.conf) | 0 | ||||
-rw-r--r-- | ports/zephyr/boards/qemu_x86.conf (renamed from ports/zephyr/prj_qemu_x86.conf) | 0 | ||||
-rw-r--r-- | ports/zephyr/boards/reel_board.conf (renamed from ports/zephyr/prj_reel_board.conf) | 0 | ||||
-rw-r--r-- | ports/zephyr/boards/rv32m1_vega_ri5cy.conf (renamed from ports/zephyr/prj_rv32m1_vega_ri5cy.conf) | 0 | ||||
-rw-r--r-- | ports/zephyr/makeprj.py | 29 | ||||
-rw-r--r-- | ports/zephyr/prj.conf (renamed from ports/zephyr/prj_base.conf) | 0 |
12 files changed, 7 insertions, 40 deletions
diff --git a/ports/zephyr/Makefile b/ports/zephyr/Makefile index 0d62e5a7a..4fe655284 100644 --- a/ports/zephyr/Makefile +++ b/ports/zephyr/Makefile @@ -8,7 +8,6 @@ # To build a "minimal" configuration, use "make-minimal" wrapper. BOARD ?= qemu_x86 -CONF_FILE = prj_$(BOARD)_merged.conf OUTDIR_PREFIX = $(BOARD) # 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 # 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 z_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: cd $(TOP)/tests && ./run-tests --target minimal --device "execpty:make -C ../ports/zephyr run BOARD=$(BOARD) QEMU_PTY=1" cmake: outdir/$(BOARD)/Makefile -outdir/$(BOARD)/Makefile: $(CONF_FILE) - mkdir -p outdir/$(BOARD) && cmake -DBOARD=$(BOARD) -DCONF_FILE=$(CONF_FILE) -Boutdir/$(BOARD) -H. +ifneq ($(CONF_FILE),) +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 make --no-print-directory -C outdir/$(BOARD) outputexports CMAKE_COMMAND=: >$@ diff --git a/ports/zephyr/prj_96b_carbon.conf b/ports/zephyr/boards/96b_carbon.conf index 40b57e69c..40b57e69c 100644 --- a/ports/zephyr/prj_96b_carbon.conf +++ b/ports/zephyr/boards/96b_carbon.conf diff --git a/ports/zephyr/prj_disco_l475_iot1.conf b/ports/zephyr/boards/disco_l475_iot1.conf index 36c8b99dd..36c8b99dd 100644 --- a/ports/zephyr/prj_disco_l475_iot1.conf +++ b/ports/zephyr/boards/disco_l475_iot1.conf diff --git a/ports/zephyr/prj_frdm_k64f.conf b/ports/zephyr/boards/frdm_k64f.conf index 483e9a29b..483e9a29b 100644 --- a/ports/zephyr/prj_frdm_k64f.conf +++ b/ports/zephyr/boards/frdm_k64f.conf diff --git a/ports/zephyr/prj_frdm_kw41z.conf b/ports/zephyr/boards/frdm_kw41z.conf index ff7b7887e..ff7b7887e 100644 --- a/ports/zephyr/prj_frdm_kw41z.conf +++ b/ports/zephyr/boards/frdm_kw41z.conf diff --git a/ports/zephyr/prj_mimxrt1050_evk.conf b/ports/zephyr/boards/mimxrt1050_evk.conf index 051ab7e60..051ab7e60 100644 --- a/ports/zephyr/prj_mimxrt1050_evk.conf +++ b/ports/zephyr/boards/mimxrt1050_evk.conf diff --git a/ports/zephyr/prj_qemu_cortex_m3.conf b/ports/zephyr/boards/qemu_cortex_m3.conf index dac0c358d..dac0c358d 100644 --- a/ports/zephyr/prj_qemu_cortex_m3.conf +++ b/ports/zephyr/boards/qemu_cortex_m3.conf diff --git a/ports/zephyr/prj_qemu_x86.conf b/ports/zephyr/boards/qemu_x86.conf index dac0c358d..dac0c358d 100644 --- a/ports/zephyr/prj_qemu_x86.conf +++ b/ports/zephyr/boards/qemu_x86.conf diff --git a/ports/zephyr/prj_reel_board.conf b/ports/zephyr/boards/reel_board.conf index a7ed230d1..a7ed230d1 100644 --- a/ports/zephyr/prj_reel_board.conf +++ b/ports/zephyr/boards/reel_board.conf diff --git a/ports/zephyr/prj_rv32m1_vega_ri5cy.conf b/ports/zephyr/boards/rv32m1_vega_ri5cy.conf index dcd6d7a08..dcd6d7a08 100644 --- a/ports/zephyr/prj_rv32m1_vega_ri5cy.conf +++ b/ports/zephyr/boards/rv32m1_vega_ri5cy.conf diff --git a/ports/zephyr/makeprj.py b/ports/zephyr/makeprj.py deleted file mode 100644 index 239c877cd..000000000 --- a/ports/zephyr/makeprj.py +++ /dev/null @@ -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") diff --git a/ports/zephyr/prj_base.conf b/ports/zephyr/prj.conf index 993dfdc26..993dfdc26 100644 --- a/ports/zephyr/prj_base.conf +++ b/ports/zephyr/prj.conf |