Skip to content

Commit bd0e002

Browse files
committed
pybricks: modules: add conditional around MP_REGISTER_MODULE()
Add a conditional compilation check around MP_REGISTER_MODULE() that checks MICROPY_MODULE_BUILTIN_SUBPACKAGES. If this option is enabled, we don't need to register subpackages as they are already handled by the parent package.
1 parent 343793b commit bd0e002

File tree

10 files changed

+22
-0
lines changed

10 files changed

+22
-0
lines changed

pybricks/ev3devices/pb_module_ev3devices.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ const mp_obj_module_t pb_module_ev3devices = {
2828
.globals = (mp_obj_dict_t *)&pb_module_ev3devices_globals,
2929
};
3030

31+
#if !MICROPY_MODULE_BUILTIN_SUBPACKAGES
3132
MP_REGISTER_MODULE(MP_QSTR_pybricks_dot_ev3devices, pb_module_ev3devices);
33+
#endif
3234

3335
#endif // PYBRICKS_PY_EV3DEVICES

pybricks/experimental/pb_module_experimental.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ const mp_obj_module_t pb_module_experimental = {
6969
.globals = (mp_obj_dict_t *)&pb_module_experimental_globals,
7070
};
7171

72+
#if !MICROPY_MODULE_BUILTIN_SUBPACKAGES
7273
MP_REGISTER_MODULE(MP_QSTR_pybricks_dot_experimental, pb_module_experimental);
74+
#endif
7375

7476
#endif // PYBRICKS_PY_EXPERIMENTAL

pybricks/hubs/pb_module_hubs.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ const mp_obj_module_t pb_module_hubs = {
2626
.globals = (mp_obj_dict_t *)&pb_module_hubs_globals,
2727
};
2828

29+
#if !MICROPY_MODULE_BUILTIN_SUBPACKAGES
2930
MP_REGISTER_MODULE(MP_QSTR_pybricks_dot_hubs, pb_module_hubs);
31+
#endif
3032

3133
#endif // PYBRICKS_PY_HUBS

pybricks/iodevices/pb_module_iodevices.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ const mp_obj_module_t pb_module_iodevices = {
3535
.globals = (mp_obj_dict_t *)&pb_module_iodevices_globals,
3636
};
3737

38+
#if !MICROPY_MODULE_BUILTIN_SUBPACKAGES
3839
MP_REGISTER_MODULE(MP_QSTR_pybricks_dot_iodevices, pb_module_iodevices);
40+
#endif
3941

4042
#endif // PYBRICKS_PY_IODEVICES

pybricks/media/pb_module_media.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ const mp_obj_module_t pb_module_media = {
2020
.globals = (mp_obj_dict_t *)&pb_module_media_globals,
2121
};
2222

23+
#if !MICROPY_MODULE_BUILTIN_SUBPACKAGES
2324
MP_REGISTER_MODULE(MP_QSTR_pybricks_dot_media, pb_module_media);
25+
#endif
2426

2527
#endif // PYBRICKS_PY_MEDIA

pybricks/nxtdevices/pb_module_nxtdevices.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ const mp_obj_module_t pb_module_nxtdevices = {
3030
.globals = (mp_obj_dict_t *)&pb_module_nxtdevices_globals,
3131
};
3232

33+
#if !MICROPY_MODULE_BUILTIN_SUBPACKAGES
3334
MP_REGISTER_MODULE(MP_QSTR_pybricks_dot_nxtdevices, pb_module_nxtdevices);
35+
#endif
3436

3537
#endif // PYBRICKS_PY_NXTDEVICES

pybricks/parameters/pb_module_parameters.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ const mp_obj_module_t pb_module_parameters = {
3030
.globals = (mp_obj_dict_t *)&pb_module_parameters_globals,
3131
};
3232

33+
#if !MICROPY_MODULE_BUILTIN_SUBPACKAGES
3334
MP_REGISTER_MODULE(MP_QSTR_pybricks_dot_parameters, pb_module_parameters);
35+
#endif
3436

3537
#endif // PYBRICKS_PY_PARAMETERS

pybricks/pupdevices/pb_module_pupdevices.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ const mp_obj_module_t pb_module_pupdevices = {
3535
.globals = (mp_obj_dict_t *)&pb_module_pupdevices_globals,
3636
};
3737

38+
#if !MICROPY_MODULE_BUILTIN_SUBPACKAGES
3839
MP_REGISTER_MODULE(MP_QSTR_pybricks_dot_pupdevices, pb_module_pupdevices);
40+
#endif
3941

4042
#endif // PYBRICKS_PY_PUPDEVICES

pybricks/robotics/pb_module_robotics.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ const mp_obj_module_t pb_module_robotics = {
2828
.globals = (mp_obj_dict_t *)&pb_module_robotics_globals,
2929
};
3030

31+
#if !MICROPY_MODULE_BUILTIN_SUBPACKAGES
3132
MP_REGISTER_MODULE(MP_QSTR_pybricks_dot_robotics, pb_module_robotics);
33+
#endif
3234

3335
#endif // PYBRICKS_PY_ROBOTICS

pybricks/tools/pb_module_tools.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,11 +382,15 @@ const mp_obj_module_t pb_module_tools = {
382382
.globals = (mp_obj_dict_t *)&pb_module_tools_globals,
383383
};
384384

385+
#if !MICROPY_MODULE_BUILTIN_SUBPACKAGES
386+
385387
MP_REGISTER_MODULE(MP_QSTR_pybricks_dot_tools, pb_module_tools);
386388

387389
// backwards compatibility for pybricks.geometry
388390
#if MICROPY_PY_BUILTINS_FLOAT
389391
MP_REGISTER_MODULE(MP_QSTR_pybricks_dot_geometry, pb_module_tools);
390392
#endif // MICROPY_PY_BUILTINS_FLOAT
391393

394+
#endif // !MICROPY_MODULE_BUILTIN_SUBPACKAGES
395+
392396
#endif // PYBRICKS_PY_TOOLS

0 commit comments

Comments
 (0)