Commit Graph

4024 Commits

Author SHA1 Message Date
stijn
e82aa2abc4 py/qstr: Make mp_decompress_rom_string decl and def the same.
Fixes MSVC warning about mismatching argument types.
2022-07-18 23:27:28 +10:00
stijn
1f16d682da py/misc: Fix msvc compilation with compressed error messages. 2022-07-18 23:25:12 +10:00
David Lechner
a1ef5ac65d py/scheduler: Use MP_REGISTER_ROOT_POINTER().
This uses MP_REGISTER_ROOT_POINTER() to register sched_queue
instead of using a conditional inside of mp_state_vm_t.

Signed-off-by: David Lechner <david@pybricks.com>
2022-07-18 13:52:01 +10:00
David Lechner
85b4f36100 py/modsys: Use MP_REGISTER_ROOT_POINTER().
This uses MP_REGISTER_ROOT_POINTER() to register cur_exception,
sys_exitfunc, mp_sys_path_obj, mp_sys_argv_obj and sys_mutable
instead of using a conditional inside of mp_state_vm_t.

Signed-off-by: David Lechner <david@pybricks.com>
2022-07-18 13:52:01 +10:00
David Lechner
a98aa66df6 py/persistentcode: Use MP_REGISTER_ROOT_POINTER().
This uses MP_REGISTER_ROOT_POINTER() to register track_reloc_code_list
instead of using a conditional inside of mp_state_vm_t.

Signed-off-by: David Lechner <david@pybricks.com>
2022-07-18 13:52:01 +10:00
David Lechner
2c728c5330 extmod/modbluetooth: Use MP_REGISTER_ROOT_POINTER().
This uses MP_REGISTER_ROOT_POINTER() to register `bluetooth`
instead of using a conditional inside of mp_state_vm_t.

Signed-off-by: David Lechner <david@pybricks.com>
2022-07-18 13:52:01 +10:00
David Lechner
32e32bd761 extmod/vfs: Use MP_REGISTER_ROOT_POINTER().
This uses MP_REGISTER_ROOT_POINTER() to register vfs_cur and
vfs_mount_table instead of using a conditional inside of mp_state_vm_t.

Signed-off-by: David Lechner <david@pybricks.com>
2022-07-18 13:52:01 +10:00
David Lechner
d532c55e3b extmod/modlwip: Use MP_REGISTER_ROOT_POINTER().
This uses MP_REGISTER_ROOT_POINTER() to register lwip_slip_stream
instead of using a conditional inside of mp_state_vm_t.

Signed-off-by: David Lechner <david@pybricks.com>
2022-07-18 13:52:01 +10:00
David Lechner
631b692177 extmod/uos_dupterm: Use MP_REGISTER_ROOT_POINTER().
This uses MP_REGISTER_ROOT_POINTER() to register dupterm_objs
instead of using a conditional inside of mp_state_vm_t.

Signed-off-by: David Lechner <david@pybricks.com>
2022-07-18 13:52:01 +10:00
David Lechner
68f46342aa shared/runtime/pyexec: Use MP_REGISTER_ROOT_POINTER().
This uses MP_REGISTER_ROOT_POINTER() to register repl_line
instead of using a conditional inside of mp_state_vm_t.

Signed-off-by: David Lechner <david@pybricks.com>
2022-07-18 13:52:01 +10:00
David Lechner
7e4b205cb0 py/mpstate: Drop MICROPY_PORT_ROOT_POINTERS from mp_state_vm_t.
All in-tree uses of MICROPY_PORT_ROOT_POINTERS have been replaced with
MP_REGISTER_ROOT_POINTER(), so now we can remove both
MICROPY_PORT_ROOT_POINTERS and MICROPY_BOARD_ROOT_POINTERS from the code
and remaining config files.

Signed-off-by: David Lechner <david@pybricks.com>
2022-07-18 13:51:16 +10:00
David Lechner
81dbea1ce3 shared/readline: Use MP_REGISTER_ROOT_POINTER().
This uses MP_REGISTER_ROOT_POINTER() to register the readline_history root
pointer array used by shared/readline.c and removes the registration from
all mpconfigport.h files.

This also required adding a new MICROPY_READLINE_HISTORY_SIZE config option
since not all ports used the same sized array.

Signed-off-by: David Lechner <david@pybricks.com>
2022-07-18 13:48:49 +10:00
David Lechner
fc3d7ae11b py/make_root_pointers: Add MP_REGISTER_ROOT_POINTER parser/generator.
This adds new compile-time infrastructure to parse source code files for
`MP_REGISTER_ROOT_POINTER()` and generates a new `root_pointers.h` header
file containing the collected declarations.  This works the same as the
existing `MP_REGISTER_MODULE()` feature.

Signed-off-by: David Lechner <david@pybricks.com>
2022-07-18 13:48:23 +10:00
Yonatan Goldschmidt
a8d78cc398 py/obj: Add debug-only runtime checks to mp_obj_is_type().
Zero effect on non debug builds, and also usually optimized out even in
debug builds as mp_obj_is_type() is called with a compile-time known type.
I'm not sure we even have dynamic uses of mp_obj_is_type() at the moment,
but if we ever will they will be protected from now on.

Signed-off-by: Yonatan Goldschmidt <yon.goldschmidt@gmail.com>
2022-07-18 11:17:49 +10:00
Yonatan Goldschmidt
2a6ba47110 py/obj: Add static safety checks to mp_obj_is_type().
Commit d96cfd13e3 introduced a regression by breaking existing
users of mp_obj_is_type(.., &mp_obj_bool).  This function (and associated
helpers like mp_obj_is_int()) have some specific nuances, and mistakes like
this one can happen again.

This commit adds mp_obj_is_exact_type() which behaves like the the old
mp_obj_is_type().  The new mp_obj_is_type() has the same prototype but it
attempts to statically assert that it's not called with types which should
be checked using mp_obj_is_type().  If called with any of these types: int,
str, bool, NoneType - it will cause a compilation error.  Additional
checked types (e.g function types) can be added in the future.

Existing users of mp_obj_is_type() with the now "invalid" types, were
translated to use mp_obj_is_exact_type().

The use of MP_STATIC_ASSERT() is not bulletproof - usually GCC (and other
compilers) can't statically check conditions that are only known during
link-time (like variables' addresses comparison).  However, in this case,
GCC is able to statically detect these conditions, probably because it's
the exact same object - `&mp_type_int == &mp_type_int` is detected.
Misuses of this function with runtime-chosen types (e.g:
`mp_obj_type_t *x = ...; mp_obj_is_type(..., x);` won't be detected.  MSC
is unable to detect this, so we use MP_STATIC_ASSERT_NOT_MSC().

Compiling with this commit and without the fix for d96cfd13e3 shows
that it detects the problem.

Signed-off-by: Yonatan Goldschmidt <yon.goldschmidt@gmail.com>
2022-07-18 11:17:46 +10:00
Yonatan Goldschmidt
6670281472 py/misc: Add MP_STATIC_ASSERT_NOT_MSC().
To be used in cases where the condition of the assert does not compile
under msvc.

Signed-off-by: Yonatan Goldschmidt <yon.goldschmidt@gmail.com>
2022-07-18 11:11:00 +10:00
Lars Haulin
5bf3765631 py/objnamedtuple: Fix segfault with empty namedtuple.
The empty tuple is usually a constant object, but named tuples must be
allocated to allow modification.  Added explicit allocation to fix this.

Also added a regression test to verify creating an empty named tuple works.

Fixes issue #7870.

Signed-off-by: Lars Haulin <lars.haulin@gmail.com>
2022-07-13 16:25:35 +10:00
Damien George
b878fc042f py/vm: Consistently indent #if guards to match the code they surround.
Signed-off-by: Damien George <damien@micropython.org>
2022-07-12 22:48:55 +10:00
Damien George
893a5c8341 py/vm: In YIELD_FROM opcode, expand helper macros and remove them.
The GENERATOR_EXIT_IF_NEEDED macro is only used once and it's easier to
read and understand the code if this macro body is written in the code.
Then the comment just before it makes more sense.

Signed-off-by: Damien George <damien@micropython.org>
2022-07-12 22:48:07 +10:00
Damien George
d84220b8c6 py/vm: Remove check for ip being NULL when handling StopIteration.
This check for code_state->ip being NULL was added in
a7c02c4538 with a commit message that "When
generator raises exception, it is automatically terminated (by setting its
code_state.ip to 0)".  It was also added without any tests to test for this
particular case.  (The commit did mention that CPython's test_pep380.py
triggered a bug, but upon re-running this test it did not show any need for
this NULL check of code_state->ip.)

It is true that generators that have completed (either by running to their
end or raising an exception) set "code_state.ip = 0".  But there is an
explicit check at the start of mp_obj_gen_resume() to return immediately
for any attempt to resume an already-stopped generator.  So the VM can
never execute a generator with NULL ip (and this was true at the time of
the above-referenced commit).

Furthermore, the other parts of the VM just before and after this piece
of code do require (or at least assume) code_state->ip is non-NULL.

Signed-off-by: Damien George <damien@micropython.org>
2022-07-12 18:17:44 +10:00
Jim Mussared
9714a0ead5 py/emitnative: Fix STORE_ATTR viper code-gen when value is not a pyobj.
There was a missing call to MP_F_CONVERT_NATIVE_TO_OBJ.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-07-12 17:18:27 +10:00
Jim Mussared
158f1794e8 py/vm: Document internal SELECTIVE_EXC_IP option.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-07-12 16:13:14 +10:00
Jim Mussared
8db99f11a7 py/scheduler: De-inline and fix race with pending exception / scheduler.
The optimisation that allows a single check in the VM for either a pending
exception or non-empty scheduler queue doesn't work when threading is
enabled, as one thread can clear the sched_state if it has no pending
exception, meaning the thread with the pending exception will never see it.

This removes that optimisation for threaded builds.

Also fixes a race in non-scheduler builds where get-and-clear of the
pending exception is not protected by the atomic section.

Also removes the bulk of the inlining of pending exceptions and scheduler
handling from the VM. This just costs code size and complexity at no
performance benefit.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-07-12 15:54:33 +10:00
Damien George
f1b5761ced py/mkrules.cmake: Improve printing of git-submodules error.
Signed-off-by: Damien George <damien@micropython.org>
2022-06-30 13:49:47 +10:00
Damien George
6e83bb47eb py/builtinhelp: Don't show help for an MP_MODULE_ATTR_DELEGATION_ENTRY.
Otherwise it can lead to a crash.

Fixes issue #8816.

Signed-off-by: Damien George <damien@micropython.org>
2022-06-28 16:35:01 +10:00
Damien George
5b66d08609 py/builtin: Remove unnecessary module declarations.
Signed-off-by: Damien George <damien@micropython.org>
2022-06-27 22:17:13 +10:00
Damien George
e22b7fb4af py/objfun: Support function attributes on native functions.
Native functions can just reuse the bytecode function attribute code.

Signed-off-by: Damien George <damien@micropython.org>
2022-06-25 00:22:15 +10:00
Michael Bentley
d68532558d py/objclosure: Forward function attributes for closures.
Add .attr attribute which forwards to self->fun.

A closure is intended to wrap around a function object, so forward any
requested attributes to the wrapped function object.

Signed-off-by: Michael Bentley <mikebentley15@gmail.com>
2022-06-24 23:46:59 +10:00
Damien George
627ba38154 py/parsenum: Optimise when building with complex disabled.
To reduce code size when MICROPY_PY_BUILTINS_COMPLEX is disabled.

Signed-off-by: Damien George <damien@micropython.org>
2022-06-23 11:46:47 +10:00
Damien George
61ce260ff7 py/parsenum: Fix parsing of complex "j" and also "nanj", "infj".
Prior to this commit, complex("j") would return 0j, and complex("nanj")
would return nan+0j.  This commit makes sure "j" is tested for after
parsing the number (nan, inf or a decimal), and also supports the case of
"j" on its own.

Signed-off-by: Damien George <damien@micropython.org>
2022-06-23 11:46:47 +10:00
Jim Mussared
0172292762 py/parsenum: Support parsing complex numbers of the form "a+bj".
To conform with CPython.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-06-23 11:46:47 +10:00
David Lechner
c118b5d0e4 extmod/extmod.mk: Separate out extmod file list from py.mk to extmod.mk.
This separates extmod source files from `py.mk`.  Previously, `py.mk`
assumed that every consumer of the py/ directory also wanted to include
extmod/.  However, this is not the case.  For example, building mpy-cross
uses py/ but doesn't need extmod/.

This commit moves all extmod-specific items from `py.mk` to `extmod.mk` and
explicitly includes `extmod.mk` in ports that use it.

Signed-off-by: David Lechner <david@pybricks.com>
2022-06-21 00:14:34 +10:00
Damien George
f5769698e5 extmod/modlwip: Clean up inclusion of modlwip in build process.
The following changes are made:

- Guard entire file with MICROPY_PY_LWIP, so it can be included in the
  build while still being disabled (for consistency with other extmod
  modules).

- Add modlwip.c to list of all extmod source in py/py.mk and
  extmod/extmod.cmake so all ports can easily use it.

- Move generic modlwip GIT_SUBMODULES build configuration code from
  ports/rp2/CMakeLists.txt to extmod/extmod.cmake, so it can be reused by
  other ports.

- Remove now unnecessary inclusion of modlwip.c in EXTMOD_SRC_C in esp8266
  port, and in SRC_QSTR in mimxrt port.

Signed-off-by: Damien George <damien@micropython.org>
2022-06-20 23:37:38 +10:00
Damien George
5d3a0bb59c py/objcell: Make cell get/set funcs static-inline to reduce code size.
Change in code size is:

       bare-arm:   -36 -0.062%
    minimal x86:   -92 -0.056%
       unix x64:   -72 -0.014%
    unix nanbox:  -276 -0.060%
          stm32:    +0 +0.000% PYBV10
          stm32:   -40 +0.021% NUCLEO_L073RZ
         cc3200:   -16 -0.009%
        esp8266:  +176 +0.025% GENERIC
          esp32:   -28 -0.002% GENERIC
         mimxrt:   -56 -0.016% TEENSY40
     renesas-ra:    +0 +0.000% RA6M2_EK
            nrf:    +0 +0.000% pca10040
            rp2:   -64 -0.013% PICO
           samd:   -32 -0.023% ADAFRUIT_ITSYBITSY_M4_EXPRESS

Ports like stm32 that build the VM with -O3 have no change because the
savings from the inlining are offset by additional gcc performance
optimisations in the VM.

Signed-off-by: Damien George <damien@micropython.org>
2022-06-20 23:37:38 +10:00
Damien George
a506335524 py/emit: Suppress unreachable bytecode/native code that follows jump.
This new logic tracks when an unconditional jump/raise occurs in the
emitted code stream (bytecode or native machine code) and suppresses all
subsequent code, until a label is assigned.  This eliminates a lot of
cases of dead code, with relatively simple logic.

This commit combined with the previous one (that removed the existing
dead-code finding logic) has the following code size change:

       bare-arm:   -16 -0.028%
    minimal x86:   -60 -0.036%
       unix x64:  -368 -0.070%
    unix nanbox:   -80 -0.017%
          stm32:  -204 -0.052% PYBV10
         cc3200:    +0 +0.000%
        esp8266:  -232 -0.033% GENERIC
          esp32:  -224 -0.015% GENERIC[incl -40(data)]
         mimxrt:  -192 -0.054% TEENSY40
     renesas-ra:  -200 -0.032% RA6M2_EK
            nrf:   +28 +0.015% pca10040
            rp2:  -256 -0.050% PICO
           samd:   -12 -0.009% ADAFRUIT_ITSYBITSY_M4_EXPRESS

Signed-off-by: Damien George <damien@micropython.org>
2022-06-20 22:28:18 +10:00
Damien George
e85a096302 py/emit: Remove logic to detect last-emit-was-return-value.
This optimisation to remove dead code is not as good as it could be.

Signed-off-by: Damien George <damien@micropython.org>
2022-06-20 22:28:18 +10:00
Damien George
0db046b67b py/vm: Change comparison for finally handler search from > to >=.
The search in these cases should include all finally handlers that are
after the current ip.  If a handler starts at exactly ip then it is
considered "after" the ip.  This can happen when END_FINALLY is followed
immediately by a finally handler (from a different finally).

Consider the function:

    def f():
        try:
            return 0
        finally:
            print(1)

The current bytecode emitter generates the following code:

    00 SETUP_FINALLY 5
    02 LOAD_CONST_SMALL_INT 0
    03 RETURN_VALUE
    04 LOAD_CONST_NONE              ****
    05 LOAD_GLOBAL print
    07 LOAD_CONST_SMALL_INT 1
    08 CALL_FUNCTION n=1 nkw=0
    10 POP_TOP
    11 END_FINALLY
    12 LOAD_CONST_NONE
    13 RETURN_VALUE

The LOAD_CONST_NONE marked with **** is dead code because it follows a
RETURN_VALUE, and nothing jumps to this LOAD_CONST_NONE.  If the emitter
could remove this this dead code it would produce:

    00 SETUP_FINALLY 4
    02 LOAD_CONST_SMALL_INT 0
    03 RETURN_VALUE
    04 LOAD_GLOBAL print
    06 LOAD_CONST_SMALL_INT 1
    07 CALL_FUNCTION n=1 nkw=0
    09 POP_TOP
    10 END_FINALLY
    11 LOAD_CONST_NONE
    12 RETURN_VALUE

In this case the finally block (which starts at offset 4) immediately
follows the RETURN_VALUE.  When RETURN_VALUE executes ip will point to
offset 4 in the bytecode (because the dispatch of the opcode does *ip++)
and so the finally handler will only be found if a >= comparison is used.

It's a similar story for break/continue:

    while True:
        try:
            break
        finally:
            print(1)

Although technically in this case the > comparison still works because the
extra byte from the UNWIND_JUMP (encoding the number of exception handlers
to unwind) doesn't have a *ip++ (just a *ip) so ip remains pointing within
the UNWIND_JUMP opcode, and not at the start of the following finally
handler.  Nevertheless, the change is made to use >= for consistency with
the RETURN_VALUE change.

Signed-off-by: Damien George <damien@micropython.org>
2022-06-20 22:28:18 +10:00
Damien George
9b486340da all: Bump version to 1.19.1.
Signed-off-by: Damien George <damien@micropython.org>
2022-06-17 12:57:59 +10:00
Damien George
d7919ea71e all: Bump version to 1.19.
Signed-off-by: Damien George <damien@micropython.org>
2022-06-16 15:11:02 +10:00
Phil Howard
37d5114cec 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>
2022-06-14 15:05:37 +01:00
Damien George
0e556f22a2 py/dynruntime: Add macros to access more types and mp_const_empty_bytes.
Signed-off-by: Damien George <damien@micropython.org>
2022-06-10 16:42:43 +10:00
Jeremy Herbert
148d12252b py/dynruntime: Add macros to create a new dict and store to dicts. 2022-06-10 16:42:43 +10:00
Damien George
f63b4f85aa py/parse: Work around xtensa esp-2020r3 compiler bug.
This commit works around a bug in xtensa-esp32-elf-gcc version esp-2020r3.

The bug is in generation of loop constructs.  The below code is generated
by the xtensa-esp32 compiler.  The first extract is the buggy machine code
and the second extract is the corrected machine code.  The test
`basics/logic_constfolding.py` fails with the first code and succeeds with
the second.

Disassembly of section .text.push_result_rule:

00000000 <push_result_rule>:
  ...
  d6:   209770       or      a9, a7, a7
  d9:   178976       loop    a9, f4 <push_result_rule+0xf4>
                     d9: R_XTENSA_SLOT0_OP   .text.push_result_rule+0xf4
  dc:   030190       rsr.lend        a9
  df:   130090       wsr.lbeg        a9
  e2:   a8c992       addi    a9, a9, -88
  e5:   06d992       addmi   a9, a9, 0x600
  e8:   130190       wsr.lend        a9
  eb:   002000       isync
  ee:   030290       rsr.lcount      a9
  f1:   01c992       addi    a9, a9, 1
  f4:   1494e7       bne     a4, a14, 10c <push_result_rule+0x10c>
                     f4: R_XTENSA_SLOT0_OP   .text.push_result_rule+0x10c

Disassembly of section .text.push_result_rule:

00000000 <push_result_rule>:
  ...
  d6:   209770       or      a9, a7, a7
  d9:   178976       loop    a9, f4 <push_result_rule+0xf4>
                     d9: R_XTENSA_SLOT0_OP   .text.push_result_rule+0xf4
  dc:   030190       rsr.lend        a9
  df:   130090       wsr.lbeg        a9
  e2:   000091       l32r    a9, fffc00e4 <push_result_rule+0xfffc00e4>
                     e2: R_XTENSA_SLOT0_OP   .literal.push_result_rule+0x18
  e5:   0020f0       nop
  e8:   130190       wsr.lend        a9
  eb:   002000       isync
  ee:   030290       rsr.lcount      a9
  f1:   01c992       addi    a9, a9, 1
  f4:   1494e7       bne     a4, a14, 10c <push_result_rule+0x10c>
                     f4: R_XTENSA_SLOT0_OP   .text.push_result_rule+0x10c

Work done in collaboration with @jimmo.

Signed-off-by: Damien George <damien@micropython.org>
2022-06-09 13:56:30 +10:00
Damien George
c7271a86ca py/makemoduledefs.py: Remove shebang line and adjust style of comment.
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>
2022-06-08 15:00:59 +10:00
Damien George
cbad559366 py/compile: Give the compiler a hint about num nodes being non-zero.
Without this, newer versions of gcc (eg 11.2.0) used with -O2 can warn
about `q_ptr` being maybe uninitialized, because it doesn't know that there
is at least one qstr being written in to this (alloca'd) memory.

As part of this, change the type of `n` to `size_t` so the compiler knows
it's unsigned and can generate better code.

Code size change for this commit:

       bare-arm:   -28 -0.049%
    minimal x86:    -4 -0.002%
       unix x64:    +0 +0.000%
    unix nanbox:   -16 -0.003%
          stm32:   -24 -0.006% PYBV10
         cc3200:   -32 -0.017%
        esp8266:    +8 +0.001% GENERIC
          esp32:   -52 -0.003% GENERIC
            nrf:   -24 -0.013% pca10040
            rp2:   -32 -0.006% PICO
           samd:   -28 -0.020% ADAFRUIT_ITSYBITSY_M4_EXPRESS

Signed-off-by: Damien George <damien@micropython.org>
2022-06-08 14:59:43 +10:00
Damien George
f506bf342a py/bc: Remove unused mp_opcode_format function.
This was made redundant by f2040bfc7e, which
also did not update this function for the change to qstr-opcode encoding,
so it does not work correctly anyway.

Signed-off-by: Damien George <damien@micropython.org>
2022-06-07 13:32:38 +10:00
Damien George
b37b578214 py/persistentcode: Remove remaining native qstr linking support.
Support for architecture-specific qstr linking was removed in
d4d53e9e11, where native code was changed to
access qstr values via qstr_table.  The only remaining use for the special
qstr link table in persistentcode.c is to support native module written in
C, linked via mpy_ld.py.  But native modules can also use the standard
module-level qstr_table (and obj_table) which was introduced in the .mpy
file reworking in f2040bfc7e.

This commit removes the remaining native qstr liking support in
persistentcode.c's load_raw_code function, and adds two new relocation
options for constants.qstr_table and constants.obj_table.  mpy_ld.py is
updated to use these relocations options instead of the native qstr link
table.

Signed-off-by: Damien George <damien@micropython.org>
2022-06-07 13:19:55 +10:00
Andrew Leech
7d9cc69645 rp2/Makefile: Use cmake for "make submodules" task when needed.
Because the submodule list can be updated by cmake files.

Signed-off-by: Andrew Leech <andrew@alelec.net>
2022-06-03 14:29:11 +10:00
Damien George
efe23aca71 all: Remove third argument to MP_REGISTER_MODULE.
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>
2022-06-02 16:31:37 +10:00
Damien George
47f634300c py: Change makemoduledefs process so it uses output of qstr extraction.
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>
2022-06-02 16:29:53 +10:00