summaryrefslogtreecommitdiff
path: root/py/makemoduledefs.py
diff options
context:
space:
mode:
authorJeff Epler <jepler@unpythonic.net>2025-09-26 10:23:06 -0500
committerDamien George <damien@micropython.org>2025-10-04 16:22:32 +1000
commit41284577ca389c463a3e69302de8ad0edaf97f24 (patch)
treee588263e8bc49c14c5c9cbb04e00e69b6a558492 /py/makemoduledefs.py
parent653f7784d7e566531ed1678486631c6c89aeedb7 (diff)
py/makemoduledefs.py: Avoid empty extensible module lists.
An empty array is a C extension supported by clang & GCC but not MSVC. This also saves a bit of code size if there are no extensible modules. Fixes issue #18141. Signed-off-by: Jeff Epler <jepler@unpythonic.net>
Diffstat (limited to 'py/makemoduledefs.py')
-rw-r--r--py/makemoduledefs.py16
1 files changed, 11 insertions, 5 deletions
diff --git a/py/makemoduledefs.py b/py/makemoduledefs.py
index 1488db5c9..c8fdc21f6 100644
--- a/py/makemoduledefs.py
+++ b/py/makemoduledefs.py
@@ -85,19 +85,25 @@ def generate_module_table_header(modules):
)
)
+ # There should always be at least one module (__main__ in runtime.c)
+ assert mod_defs
+
print("\n#define MICROPY_REGISTERED_MODULES \\")
for mod_def in sorted(mod_defs):
print(" {mod_def} \\".format(mod_def=mod_def))
-
print("// MICROPY_REGISTERED_MODULES")
- print("\n#define MICROPY_REGISTERED_EXTENSIBLE_MODULES \\")
+ # There are not necessarily any extensible modules (e.g., bare-arm or minimal x86)
+ print("\n#define MICROPY_HAVE_REGISTERED_EXTENSIBLE_MODULES ", len(extensible_mod_defs))
- for mod_def in sorted(extensible_mod_defs):
- print(" {mod_def} \\".format(mod_def=mod_def))
+ if extensible_mod_defs:
+ print("\n#define MICROPY_REGISTERED_EXTENSIBLE_MODULES \\")
+
+ for mod_def in sorted(extensible_mod_defs):
+ print(" {mod_def} \\".format(mod_def=mod_def))
- print("// MICROPY_REGISTERED_EXTENSIBLE_MODULES")
+ print("// MICROPY_REGISTERED_EXTENSIBLE_MODULES")
def generate_module_delegations(delegations):