[Microbit-Python] How to exclude some modules and how to supped up build?

Jim Mussared jim at groklearning.com
Mon Sep 26 05:22:05 EDT 2016


On 24 September 2016 at 22:12, Giovanni Giorgi <jj at gioorgi.com> wrote:
> Hi,
>  I am playing with micro: bit micropython source code:
> https://github.com/bbcmicrobit/micropython
>
> I have found a bit difficult to exclude module from the build.
> Even if I do not expose them in the inc/microbit/mpconfigport.h
> (editing the MICROPY_PORT_BUILTIN_MODULES macro)
> they seems get linked in the final executable.
>
> For instance I have evidence the music callback function microbit_music_tick
> get linked even if I exclude the modmusic module from the
> MICROPY_PORT_BUILTIN_MODULES.

This function will get linked regardless because it is invoked
directly from main.cpp (in the microbit_ticker function).

In general though, removing the module from the list in
MICROPY_PORT_BUILTIN_MODULES works.

e.g.

$ /usr/bin/arm-none-eabi-nm
build/bbc-microbit-classic-gcc-nosd/source/microbit-micropython | grep
neopixel
00022d14 T neopixel_clear
000028e8 t neopixel_clear_
00004568 T neopixel_init
000029a8 t neopixel_make_new
0002b340 T neopixel_module
00022d3a T neopixel_set_color
000045b4 T neopixel_show
000028d8 t neopixel_show_
000028f8 t neopixel_subscr
0002b34c T neopixel_type
000229a8 t neopixel_unary_op
0002b2e8 t _ZL17neopixel_show_obj
0002b2f4 t _ZL18neopixel_clear_obj
0002b300 t _ZL20neopixel_locals_dict
0002b310 t _ZL23neopixel_module_globals
0002b320 t _ZL26neopixel_locals_dict_table
0002b330 t _ZL29neopixel_module_globals_table

Then if I remove the neopixel module from the list:

$ /usr/bin/arm-none-eabi-nm
build/bbc-microbit-classic-gcc-nosd/source/microbit-micropython | grep
neopixel
(nothing)

>
> I have to define a macro to exclude module code from the build, but this is
> quite ugly because I need to put a lot of
> if-define in a lot of file. I feel it is as a dark side path :(
>
> There is a better way of doing it?
>
>
> Also, the "yt build" re-build every time the entire source tree (200+ file).
> There is a faster way to simply check my C++ module syntax?

Just run the ninja build directly:
$ ninja -C build/bbc-microbit-classic-gcc-nosd

'yotta build' runs cmake to generate the ninja script, then invokes
ninja. You'll need to run 'yotta build' if you make changes to the
build (like adding/removing files), but for file changes just running
ninja directly is fine.

>
> Thank you!
>
> --
> Giovanni Giorgi
> jj at gioorgi.com
>
>
>
>
>
>
>
> _______________________________________________
> Microbit mailing list
> Microbit at python.org
> https://mail.python.org/mailman/listinfo/microbit
>


More information about the Microbit mailing list