py/makemoduledefs.py: Allow multiple ways to register a module.
For example, ussl can come from axtls or mbedtls. If neither are enabled then don't try and set an empty definition twice, and only include it once in MICROPY_REGISTERED_MODULES. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
This commit is contained in:
parent
bc42db4496
commit
469450171f
|
@ -59,18 +59,21 @@ def generate_module_table_header(modules):
|
|||
"""
|
||||
|
||||
# Print header file for all external modules.
|
||||
mod_defs = []
|
||||
mod_defs = set()
|
||||
print("// Automatically generated by makemoduledefs.py.\n")
|
||||
for module_name, obj_module, enabled_define in modules:
|
||||
mod_def = "MODULE_DEF_{}".format(module_name.upper())
|
||||
mod_defs.append(mod_def)
|
||||
mod_defs.add(mod_def)
|
||||
print(
|
||||
(
|
||||
"#if ({enabled_define})\n"
|
||||
" extern const struct _mp_obj_module_t {obj_module};\n"
|
||||
" #undef {mod_def}\n"
|
||||
" #define {mod_def} {{ MP_ROM_QSTR({module_name}), MP_ROM_PTR(&{obj_module}) }},\n"
|
||||
"#else\n"
|
||||
" #define {mod_def}\n"
|
||||
" #ifndef {mod_def}\n"
|
||||
" #define {mod_def}\n"
|
||||
" #endif\n"
|
||||
"#endif\n"
|
||||
).format(
|
||||
module_name=module_name,
|
||||
|
@ -82,7 +85,7 @@ def generate_module_table_header(modules):
|
|||
|
||||
print("\n#define MICROPY_REGISTERED_MODULES \\")
|
||||
|
||||
for mod_def in mod_defs:
|
||||
for mod_def in sorted(mod_defs):
|
||||
print(" {mod_def} \\".format(mod_def=mod_def))
|
||||
|
||||
print("// MICROPY_REGISTERED_MODULES")
|
||||
|
|
Loading…
Reference in New Issue