summaryrefslogtreecommitdiffstatshomepage
path: root/py/makemoduledefs.py
Commit message (Collapse)AuthorAge
* py/makemoduledefs.py: Automatically declare delegation attr functions.Damien George2023-06-14
| | | | | | | | So that the delegation functions don't need to be put somewhere global, like in mpconfigport.h. That would otherwise make it hard for extension modules to use delegation. Signed-off-by: Damien George <damien@micropython.org>
* py/makemoduledefs.py: Fix declaring multiple module delegations.Damien George2023-06-14
| | | | Signed-off-by: Damien George <damien@micropython.org>
* py/objmodule: Workaround for MSVC with no module delegation.Jim Mussared2023-06-08
| | | | | | | | | | When compiling mpy-cross, there is no `sys` module, and so there will be no entries in the `mp_builtin_module_delegation_table`. MSVC doesn't like this, so instead pretend as if the feature isn't enabled at all. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
* py/objmodule: Add a table of built-in modules with delegation.Jim Mussared2023-06-08
| | | | | | | | | | | | | | | | | This replaces the previous QSTR_null entry in the globals dict which could leak out to Python (e.g. via iteration of mod.__dict__) and could lead to crashes. It results in smaller code size at the expense of turning a lookup into a loop, but the list it is looping over likely only contains one or two elements. To allow a module to register its custom attr function it can use the new `MP_REGISTER_MODULE_DELEGATION` macro. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
* py/makemoduledefs.py: Add a way to register extensible built-in modules.Jim Mussared2023-06-08
| | | | Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
* py/makemoduledefs.py: Emit useful error for legacy MP_REGISTER_MODULE.Phil Howard2022-06-14
| | | | | | | | | | | | 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>
* py/makemoduledefs.py: Remove shebang line and adjust style of comment.Damien George2022-06-08
| | | | | | | | | | | | This file is not executable so shouldn't have the shebang line. This line can cause issues when building on Windows msvc when the PyPython variable is set to something other than "python", because it reverts back to using the shebang line. The top comment is also changed to """ style which matches all other preprocessing scripts in the py/ directory. Signed-off-by: Damien George <damien@micropython.org>
* all: Remove third argument to MP_REGISTER_MODULE.Damien George2022-06-02
| | | | | | | | It's no longer needed because this macro is now processed after preprocessing the source code via cpp (in the qstr extraction stage), which means unused MP_REGISTER_MODULE's are filtered out by the preprocessor. Signed-off-by: Damien George <damien@micropython.org>
* py: Change makemoduledefs process so it uses output of qstr extraction.Damien George2022-06-02
| | | | | | | | | | | | | | | | This cleans up the parsing of MP_REGISTER_MODULE() and generation of genhdr/moduledefs.h so that it uses the same process as compressed error string messages, using the output of qstr extraction. This makes sure all MP_REGISTER_MODULE()'s that are part of the build are correctly picked up. Previously the extraction would miss some (eg if you had a mod.c file in the board directory for an stm32 board). Build speed is more or less unchanged. Thanks to @stinos for the ports/windows/msvc/genhdr.targets changes. Signed-off-by: Damien George <damien@micropython.org>
* py/makemoduledefs.py: Allow multiple ways to register a module.Jim Mussared2022-05-18
| | | | | | | | 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>
* all: Update Python code to conform to latest black formatting.Damien George2020-08-29
| | | | | | | | | | | | | Updating to Black v20.8b1 there are two changes that affect the code in this repository: - If there is a trailing comma in a list (eg [], () or function call) then that list is now written out with one line per element. So remove such trailing commas where the list should stay on one line. - Spaces at the start of """ doc strings are removed. Signed-off-by: Damien George <damien@micropython.org>
* all: Reformat C and Python source code with tools/codeformat.py.Damien George2020-02-28
| | | | This is run with uncrustify 0.70.1, and black 19.10b0.
* py/makedefs: Use io.open with utf-8 encoding when processing source.Damien George2019-04-12
| | | | | | | In case (user) source code contains utf-8 encoded data and the default locale is not utf-8. See #4592.
* py: Allow registration of modules at their definition.Andrew Leech2019-03-08
During make, makemoduledefs.py parses the current builds c files for MP_REGISTER_MODULE(module_name, obj_module, enabled_define) These are used to generate a header with the required entries for "mp_rom_map_elem_t mp_builtin_module_table[]" in py/objmodule.c