py/makemoduledefs.py: Emit useful error for legacy MP_REGISTER_MODULE.

Catch calls to legacy:

MP_REGISTER_MODULE(name, module, enable)

Emit a friendly error suggesting they be rewritten to:

MP_REGISTER_MODULE(name, module).

Signed-off-by: Phil Howard <phil@pimoroni.com>
This commit is contained in:
Phil Howard 2022-06-14 11:17:03 +01:00
parent cedb93c179
commit 37d5114cec
1 changed files with 9 additions and 0 deletions

View File

@ -7,6 +7,7 @@ These are used to generate a header with the required entries for
from __future__ import print_function
import sys
import re
import io
import argparse
@ -40,6 +41,14 @@ def generate_module_table_header(modules):
for module_name, obj_module in modules:
mod_def = "MODULE_DEF_{}".format(module_name.upper())
mod_defs.add(mod_def)
if "," in obj_module:
print(
"ERROR: Call to MP_REGISTER_MODULE({}, {}) should be MP_REGISTER_MODULE({}, {})\n".format(
module_name, obj_module, module_name, obj_module.split(",")[0]
),
file=sys.stderr,
)
sys.exit(1)
print(
(
"extern const struct _mp_obj_module_t {obj_module};\n"