Skip to content

Commit cc51cad

Browse files
authored
Merge pull request adafruit#1564 from dhalbert/module-presence-fixes
fix module weak links; add missing nrf features
2 parents 90bc09a + 5ec9241 commit cc51cad

2 files changed

Lines changed: 34 additions & 14 deletions

File tree

ports/nrf/mpconfigport.mk

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ INTERNAL_LIBM = 1
77

88
USB_SERIAL_NUMBER_LENGTH = 16
99

10+
# All nRF ports have longints.
11+
LONGINT_IMPL = MPZ
12+
1013
# No DAC, so no regular audio.
1114
CIRCUITPY_AUDIOIO = 0
1215

py/circuitpy_mpconfig.h

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -168,28 +168,43 @@ typedef long mp_off_t;
168168
{ MP_OBJ_NEW_QSTR(MP_QSTR_input), (mp_obj_t)&mp_builtin_input_obj }, \
169169
{ MP_OBJ_NEW_QSTR(MP_QSTR_open), (mp_obj_t)&mp_builtin_open_obj },
170170

171-
172171
// board specific definitions
173172
#include "mpconfigboard.h"
174173

175174
// CIRCUITPY_FULL_BUILD is defined in a *.mk file.
176175

177176
// Remove some lesser-used functionality to make small builds fit.
178177
#define MICROPY_BUILTIN_METHOD_CHECK_SELF_ARG (CIRCUITPY_FULL_BUILD)
179-
#define MICROPY_PY_ALL_SPECIAL_METHODS (CIRCUITPY_FULL_BUILD)
180-
#define MICROPY_PY_BUILTINS_COMPLEX (CIRCUITPY_FULL_BUILD)
181-
#define MICROPY_PY_BUILTINS_FROZENSET (CIRCUITPY_FULL_BUILD)
182-
#define MICROPY_PY_BUILTINS_REVERSED (CIRCUITPY_FULL_BUILD)
183-
#define MICROPY_PY_BUILTINS_STR_CENTER (CIRCUITPY_FULL_BUILD)
184-
#define MICROPY_PY_BUILTINS_STR_PARTITION (CIRCUITPY_FULL_BUILD)
185-
#define MICROPY_PY_BUILTINS_STR_SPLITLINES (CIRCUITPY_FULL_BUILD)
186-
#define MICROPY_PY_UERRNO (CIRCUITPY_FULL_BUILD)
178+
#define MICROPY_MODULE_WEAK_LINKS (CIRCUITPY_FULL_BUILD)
179+
#define MICROPY_PY_ALL_SPECIAL_METHODS (CIRCUITPY_FULL_BUILD)
180+
#define MICROPY_PY_BUILTINS_COMPLEX (CIRCUITPY_FULL_BUILD)
181+
#define MICROPY_PY_BUILTINS_FROZENSET (CIRCUITPY_FULL_BUILD)
182+
#define MICROPY_PY_BUILTINS_REVERSED (CIRCUITPY_FULL_BUILD)
183+
#define MICROPY_PY_BUILTINS_STR_CENTER (CIRCUITPY_FULL_BUILD)
184+
#define MICROPY_PY_BUILTINS_STR_PARTITION (CIRCUITPY_FULL_BUILD)
185+
#define MICROPY_PY_BUILTINS_STR_SPLITLINES (CIRCUITPY_FULL_BUILD)
186+
#define MICROPY_PY_UERRNO (CIRCUITPY_FULL_BUILD)
187187
// Opposite setting is deliberate.
188-
#define MICROPY_PY_UERRNO_ERRORCODE (!CIRCUITPY_FULL_BUILD)
189-
#define MICROPY_PY_URE (CIRCUITPY_FULL_BUILD)
190-
#define MICROPY_PY_URE_MATCH_GROUPS (CIRCUITPY_FULL_BUILD)
191-
#define MICROPY_PY_URE_MATCH_SPAN_START_END (CIRCUITPY_FULL_BUILD)
192-
#define MICROPY_PY_URE_SUB (CIRCUITPY_FULL_BUILD)
188+
#define MICROPY_PY_UERRNO_ERRORCODE (!CIRCUITPY_FULL_BUILD)
189+
#define MICROPY_PY_URE (CIRCUITPY_FULL_BUILD)
190+
#define MICROPY_PY_URE_MATCH_GROUPS (CIRCUITPY_FULL_BUILD)
191+
#define MICROPY_PY_URE_MATCH_SPAN_START_END (CIRCUITPY_FULL_BUILD)
192+
#define MICROPY_PY_URE_SUB (CIRCUITPY_FULL_BUILD)
193+
194+
#define MICROPY_PORT_BUILTIN_MODULE_WEAK_LINKS \
195+
{ MP_ROM_QSTR(MP_QSTR_errno), MP_ROM_PTR(&mp_module_uerrno) }, \
196+
{ MP_ROM_QSTR(MP_QSTR_io), MP_ROM_PTR(&mp_module_io) }, \
197+
{ MP_ROM_QSTR(MP_QSTR_os), MP_ROM_PTR(&os_module) }, \
198+
{ MP_OBJ_NEW_QSTR(MP_QSTR_time), (mp_obj_t)&time_module }, \
199+
200+
#if MICROPY_MODULE_WEAK_LINKS
201+
#define MICROPY_PORT_BUILTIN_MODULE_WEAK_LINK_ALTERNATES \
202+
{ MP_ROM_QSTR(MP_QSTR__os), MP_ROM_PTR(&os_module) }, \
203+
{ MP_OBJ_NEW_QSTR(MP_QSTR__time), (mp_obj_t)&time_module },
204+
#else
205+
#define MICROPY_PORT_BUILTIN_MODULE_WEAK_LINK_ALTERNATES
206+
#endif
207+
193208

194209
// LONGINT_IMPL_xxx are defined in the Makefile.
195210
//
@@ -462,6 +477,7 @@ extern const struct _mp_obj_module_t ustack_module;
462477
#define JSON_MODULE
463478
#endif
464479

480+
465481
// This is an inclusive list that should correspond to the CIRCUITPY_XXX list above,
466482
// including dependendencies such as TERMINALIO depending on DISPLAYIO (shown by indentation).
467483
// Some of these definitions will be blank depending on what is turned on and off.
@@ -502,6 +518,7 @@ extern const struct _mp_obj_module_t ustack_module;
502518
USB_HID_MODULE \
503519
USB_MIDI_MODULE \
504520
USTACK_MODULE \
521+
MICROPY_PORT_BUILTIN_MODULE_WEAK_LINK_ALTERNATES
505522

506523
// We need to provide a declaration/definition of alloca()
507524
#include <alloca.h>

0 commit comments

Comments
 (0)