tools/makemanifest.py: Provide access to MICROPY_MANIFEST_xxx symbols.

The new function resolve(name) returns the value of a Makefile
symbol defined as MICROPY_MANIFEST_<name>.

Example:

Makefile:

MICROPY_MANIFEST_FROZEN_SET = "default"

manifest.py:

frozen_set = resolve("$FROZEN_SET")

If name is not defined, resolve() returns `None`. Set the symbols
MICROPY_MANIFEST_BOARD and MICROPY_MANIFEST_BOARD_VARIANT by
default.

Notes:
- Instead of "resolve" the function may have any other appropriate
  name.
- The "$XYZ" notation was kept for consistency with the other functions.

Signed-off-by: robert-hh <robert@hammelrath.com>
pull/13243/head
robert-hh 2023-12-20 17:37:46 +01:00
rodzic b3c62f3169
commit 4df350fd3c
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 32EC5F755D5A3A93
2 zmienionych plików z 10 dodań i 0 usunięć

Wyświetl plik

@ -206,6 +206,9 @@ MICROPY_MANIFEST_MPY_LIB_DIR = $(MPY_LIB_DIR)
MICROPY_MANIFEST_PORT_DIR = $(shell pwd)
MICROPY_MANIFEST_BOARD_DIR = $(BOARD_DIR)
MICROPY_MANIFEST_MPY_DIR = $(TOP)
# Set variables for BOARD and BOARD_VARIANT by default
MICROPY_MANIFEST_BOARD = $(BOARD)
MICROPY_MANIFEST_BOARD_VARIANT = $(BOARD_VARIANT)
# Find all MICROPY_MANIFEST_* variables and turn them into command line arguments.
MANIFEST_VARIABLES = $(foreach var,$(filter MICROPY_MANIFEST_%, $(.VARIABLES)),-v "$(subst MICROPY_MANIFEST_,,$(var))=$($(var))")

Wyświetl plik

@ -222,6 +222,7 @@ class ManifestFile:
"add_library": self.add_library,
"package": self.package,
"module": self.module,
"resolve": self.resolve,
"options": IncludeOptions(**kwargs),
}
@ -572,6 +573,12 @@ class ManifestFile:
"""
self._freeze_internal(path, script, exts=(".mpy",), kind=KIND_FREEZE_MPY, opt=opt)
def resolve(self, name):
if name[0] == "$" and name[1:] in self._path_vars.keys():
return self._path_vars[name[1:]]
else:
return None
# Generate a temporary file with a line appended to the end that adds __version__.
@contextlib.contextmanager