simplify circuitpy_mpconfig with enable-if-any, -all
and make corresponding simplifications in shared-bindings-matrix, but directly using the final defines from CFLAGS instead of the status quo. The net changes are to disable audiocore & audiomixer on some espressif devices that have no audio output at all. Other than that, the shared-bindings-matrix seems to be identical.
This commit is contained in:
parent
fd60cccb06
commit
9a18524c30
|
@ -148,50 +148,21 @@ def get_board_mapping():
|
|||
return boards
|
||||
|
||||
|
||||
def read_mpconfig():
|
||||
"""Open 'circuitpy_mpconfig.mk' and return the contents."""
|
||||
configs = []
|
||||
cpy_mpcfg = get_circuitpython_root_dir() / "py" / "circuitpy_mpconfig.mk"
|
||||
with open(cpy_mpcfg) as mpconfig:
|
||||
configs = mpconfig.read()
|
||||
|
||||
return configs
|
||||
|
||||
|
||||
def build_module_map():
|
||||
"""Establish the base of the JSON file, based on the contents from
|
||||
`configs`. Base will contain module names, if they're part of
|
||||
the `FULL_BUILD`, or their default value (0, 1, or a list of
|
||||
modules that determine default [see audiocore, audiomixer, etc.]).
|
||||
|
||||
`configs`. Base contains the module name and the controlling C macro name.
|
||||
"""
|
||||
base = dict()
|
||||
modules = get_bindings()
|
||||
configs = read_mpconfig()
|
||||
full_build = False
|
||||
for module in modules:
|
||||
full_name = module
|
||||
if module in ADDITIONAL_MODULES:
|
||||
search_identifier = ADDITIONAL_MODULES[module]
|
||||
else:
|
||||
search_identifier = "CIRCUITPY_" + module.lstrip("_").upper()
|
||||
re_pattern = f"{re.escape(search_identifier)}\s*\??=\s*(.+)"
|
||||
find_config = re.findall(re_pattern, configs)
|
||||
if not find_config:
|
||||
continue
|
||||
find_config = ", ".join([x.strip("$()") for x in find_config])
|
||||
|
||||
full_build = int("CIRCUITPY_FULL_BUILD" in find_config)
|
||||
if not full_build:
|
||||
default_val = find_config
|
||||
else:
|
||||
default_val = "None"
|
||||
|
||||
base[module] = {
|
||||
"name": full_name,
|
||||
"full_build": str(full_build),
|
||||
"default_value": default_val,
|
||||
"excluded": {},
|
||||
"key": search_identifier,
|
||||
}
|
||||
|
||||
|
@ -199,15 +170,14 @@ def build_module_map():
|
|||
|
||||
|
||||
def get_settings_from_makefile(port_dir, board_name):
|
||||
"""Invoke make in a mode which prints the database, then parse it for
|
||||
settings.
|
||||
"""Invoke make to print the value of critical build settings
|
||||
|
||||
This means that the effect of all Makefile directives is taken
|
||||
into account, without having to re-encode the logic that sets them
|
||||
in this script, something that has proved error-prone
|
||||
"""
|
||||
contents = subprocess.run(
|
||||
["make", "-C", port_dir, f"BOARD={board_name}", "-qp", "print-CC"],
|
||||
["make", "-C", port_dir, "-f", "Makefile", f"BOARD={board_name}", "print-CFLAGS", "print-CIRCUITPY_BUILD_EXTENSIONS", "print-FROZEN_MPY_DIRS"],
|
||||
encoding="utf-8",
|
||||
errors="replace",
|
||||
stdout=subprocess.PIPE,
|
||||
|
@ -223,9 +193,10 @@ def get_settings_from_makefile(port_dir, board_name):
|
|||
|
||||
settings = {}
|
||||
for line in contents.stdout.split("\n"):
|
||||
# Handle both = and := definitions.
|
||||
m = re.match(r"^([A-Z][A-Z0-9_]*) :?= (.*)$", line)
|
||||
if m:
|
||||
if line.startswith('CFLAGS ='):
|
||||
for m in re.findall('-D([A-Z][A-Z0-9_]*)=(\d+)', line):
|
||||
settings[m[0]] = m[1]
|
||||
elif m := re.match(r"^([A-Z][A-Z0-9_]*) = (.*)$", line):
|
||||
settings[m.group(1)] = m.group(2)
|
||||
|
||||
return settings
|
||||
|
@ -280,7 +251,7 @@ def frozen_modules_from_dirs(frozen_mpy_dirs, withurl):
|
|||
"""
|
||||
frozen_modules = []
|
||||
for frozen_path in filter(lambda x: x, frozen_mpy_dirs.split(" ")):
|
||||
source_dir = get_circuitpython_root_dir() / frozen_path[7:]
|
||||
source_dir = get_circuitpython_root_dir() / frozen_path[6:]
|
||||
url_repository = get_repository_url(source_dir)
|
||||
for sub in source_dir.glob("*"):
|
||||
if sub.name in FROZEN_EXCLUDES:
|
||||
|
|
|
@ -14,7 +14,6 @@ CIRCUITPY_FULL_BUILD ?= 1
|
|||
CIRCUITPY_ALARM ?= 1
|
||||
CIRCUITPY_ANALOGBUFIO ?= 1
|
||||
CIRCUITPY_AUDIOBUSIO ?= 1
|
||||
CIRCUITPY_AUDIOBUSIO_I2SOUT ?= 1
|
||||
CIRCUITPY_AUDIOBUSIO_PDMIN ?= 0
|
||||
CIRCUITPY_AUDIOIO ?= 0
|
||||
CIRCUITPY_AUDIOMP3 ?= 0
|
||||
|
|
|
@ -26,6 +26,18 @@
|
|||
# Boards default to all modules enabled (with exceptions)
|
||||
# Manually disable by overriding in #mpconfigboard.mk
|
||||
|
||||
enable-if-any=$(lastword $(sort $(1) 0))
|
||||
enable-if-all=$(firstword $(sort $(1) 1))
|
||||
|
||||
#$(info enable-if-any 0 1 -> $(call enable-if-any,0 1))
|
||||
#$(info enable-if-any 1 0 -> $(call enable-if-any,1 0))
|
||||
#$(info enable-if-any 1 1 -> $(call enable-if-any,1 1))
|
||||
#$(info enable-if-any 0 0 -> $(call enable-if-any,0 0))
|
||||
#$(info enable-if-all 0 1 -> $(call enable-if-all,0 1))
|
||||
#$(info enable-if-all 1 0 -> $(call enable-if-all,1 0))
|
||||
#$(info enable-if-all 1 1 -> $(call enable-if-all,1 1))
|
||||
#$(info enable-if-all 0 0 -> $(call enable-if-all,0 0))
|
||||
|
||||
# Always on. Present here to help generate documentation module support matrix for "builtins".
|
||||
CIRCUITPY = 1
|
||||
CFLAGS += -DCIRCUITPY=$(CIRCUITPY)
|
||||
|
@ -95,13 +107,7 @@ CFLAGS += -DCIRCUITPY_AUDIOIO=$(CIRCUITPY_AUDIOIO)
|
|||
CIRCUITPY_AUDIOPWMIO ?= 0
|
||||
CFLAGS += -DCIRCUITPY_AUDIOPWMIO=$(CIRCUITPY_AUDIOPWMIO)
|
||||
|
||||
ifndef CIRCUITPY_AUDIOCORE
|
||||
ifeq ($(CIRCUITPY_AUDIOPWMIO),1)
|
||||
CIRCUITPY_AUDIOCORE = $(CIRCUITPY_AUDIOPWMIO)
|
||||
else
|
||||
CIRCUITPY_AUDIOCORE = $(CIRCUITPY_AUDIOIO)
|
||||
endif
|
||||
endif
|
||||
CIRCUITPY_AUDIOCORE ?= $(call enable-if-any,$(CIRCUITPY_AUDIOPWMIO) $(CIRCUITPY_AUDIOIO) $(CIRCUITPY_AUDIOBUSIO))
|
||||
CFLAGS += -DCIRCUITPY_AUDIOCORE=$(CIRCUITPY_AUDIOCORE)
|
||||
|
||||
CIRCUITPY_AUDIOMIXER ?= $(CIRCUITPY_AUDIOCORE)
|
||||
|
@ -112,13 +118,7 @@ CIRCUITPY_AUDIOCORE_DEBUG ?= 0
|
|||
endif
|
||||
CFLAGS += -DCIRCUITPY_AUDIOCORE_DEBUG=$(CIRCUITPY_AUDIOCORE_DEBUG)
|
||||
|
||||
ifndef CIRCUITPY_AUDIOMP3
|
||||
ifeq ($(CIRCUITPY_FULL_BUILD),1)
|
||||
CIRCUITPY_AUDIOMP3 = $(CIRCUITPY_AUDIOCORE)
|
||||
else
|
||||
CIRCUITPY_AUDIOMP3 = 0
|
||||
endif
|
||||
endif
|
||||
CIRCUITPY_AUDIOMP3 ?= $(call enable-if-all,$(CIRCUITPY_FULL_BUILD) $(CIRCUITPY_AUDIOCORE))
|
||||
CFLAGS += -DCIRCUITPY_AUDIOMP3=$(CIRCUITPY_AUDIOMP3)
|
||||
|
||||
CIRCUITPY_BINASCII ?= $(CIRCUITPY_FULL_BUILD)
|
||||
|
@ -200,15 +200,9 @@ endif
|
|||
CFLAGS += -DCIRCUITPY_PARALLELDISPLAY=$(CIRCUITPY_PARALLELDISPLAY)
|
||||
|
||||
# bitmaptools and framebufferio rely on displayio
|
||||
ifeq ($(CIRCUITPY_DISPLAYIO),1)
|
||||
CIRCUITPY_BITMAPTOOLS ?= $(CIRCUITPY_FULL_BUILD)
|
||||
CIRCUITPY_FRAMEBUFFERIO ?= $(CIRCUITPY_FULL_BUILD)
|
||||
CIRCUITPY_VECTORIO ?= 1
|
||||
else
|
||||
CIRCUITPY_BITMAPTOOLS ?= 0
|
||||
CIRCUITPY_FRAMEBUFFERIO ?= 0
|
||||
CIRCUITPY_VECTORIO ?= 0
|
||||
endif
|
||||
CIRCUITPY_BITMAPTOOLS ?= $(call enable-if-all,$(CIRCUITPY_FULL_BUILD) $(CIRCUITPY_DISPLAYIO))
|
||||
CIRCUITPY_FRAMEBUFFERIO ?= $(call enable-if-all,$(CIRCUITPY_FULL_BUILD) $(CIRCUITPY_DISPLAYIO))
|
||||
CIRCUITPY_VECTORIO ?= $(CIRCUITPY_DISPLAYIO)
|
||||
CFLAGS += -DCIRCUITPY_BITMAPTOOLS=$(CIRCUITPY_BITMAPTOOLS)
|
||||
CFLAGS += -DCIRCUITPY_FRAMEBUFFERIO=$(CIRCUITPY_FRAMEBUFFERIO)
|
||||
CFLAGS += -DCIRCUITPY_VECTORIO=$(CIRCUITPY_VECTORIO)
|
||||
|
@ -255,12 +249,7 @@ CFLAGS += -DCIRCUITPY_FUTURE=$(CIRCUITPY_FUTURE)
|
|||
CIRCUITPY_GETPASS ?= $(CIRCUITPY_FULL_BUILD)
|
||||
CFLAGS += -DCIRCUITPY_GETPASS=$(CIRCUITPY_GETPASS)
|
||||
|
||||
ifeq ($(CIRCUITPY_DISPLAYIO),1)
|
||||
#CIRCUITPY_GIFIO ?= $(CIRCUITPY_CAMERA)
|
||||
CIRCUITPY_GIFIO ?= 1
|
||||
else
|
||||
CIRCUITPY_GIFIO ?= 0
|
||||
endif
|
||||
CIRCUITPY_GIFIO ?= $(call enable-if-any,$(CIRCUITPY_DISPLAYIO) $(CIRCUITPY_CAMERA))
|
||||
CFLAGS += -DCIRCUITPY_GIFIO=$(CIRCUITPY_GIFIO)
|
||||
|
||||
CIRCUITPY_GNSS ?= 0
|
||||
|
@ -468,10 +457,7 @@ CFLAGS += -DCIRCUITPY_SYS=$(CIRCUITPY_SYS)
|
|||
CIRCUITPY_TERMINALIO ?= $(CIRCUITPY_DISPLAYIO)
|
||||
CFLAGS += -DCIRCUITPY_TERMINALIO=$(CIRCUITPY_TERMINALIO)
|
||||
|
||||
ifeq ($(CIRCUITPY_DISPLAYIO),1)
|
||||
CIRCUITPY_FONTIO ?= $(CIRCUITPY_TERMINALIO)
|
||||
endif
|
||||
CFLAGS += -DCIRCUITPY_FONTIO=$(CIRCUITPY_FONTIO)
|
||||
CIRCUITPY_FONTIO ?= $(call enable-if-all,$(CIRCUITPY_DISPLAYIO) $(CIRCUITPY_TERMINALIO))
|
||||
|
||||
CIRCUITPY_TIME ?= 1
|
||||
CFLAGS += -DCIRCUITPY_TIME=$(CIRCUITPY_TIME)
|
||||
|
|
Loading…
Reference in New Issue