diff options
Diffstat (limited to 'py')
| -rw-r--r-- | py/circuitpy_mpconfig.h | 71 | ||||
| -rw-r--r-- | py/circuitpy_mpconfig.mk | 7 | ||||
| -rw-r--r-- | py/objmodule.c | 1 |
3 files changed, 52 insertions, 27 deletions
diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index 910879d06..884ec5983 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -191,21 +191,6 @@ typedef long mp_off_t; #define MICROPY_PY_URE_MATCH_SPAN_START_END (CIRCUITPY_FULL_BUILD) #define MICROPY_PY_URE_SUB (CIRCUITPY_FULL_BUILD) -#define MICROPY_PORT_BUILTIN_MODULE_WEAK_LINKS \ - { MP_ROM_QSTR(MP_QSTR_errno), MP_ROM_PTR(&mp_module_uerrno) }, \ - { MP_ROM_QSTR(MP_QSTR_io), MP_ROM_PTR(&mp_module_io) }, \ - { MP_ROM_QSTR(MP_QSTR_os), MP_ROM_PTR(&os_module) }, \ - { MP_OBJ_NEW_QSTR(MP_QSTR_time), (mp_obj_t)&time_module }, \ - -#if MICROPY_MODULE_WEAK_LINKS -#define MICROPY_PORT_BUILTIN_MODULE_WEAK_LINK_ALTERNATES \ - { MP_ROM_QSTR(MP_QSTR__os), MP_ROM_PTR(&os_module) }, \ - { MP_OBJ_NEW_QSTR(MP_QSTR__time), (mp_obj_t)&time_module }, -#else -#define MICROPY_PORT_BUILTIN_MODULE_WEAK_LINK_ALTERNATES -#endif - - // LONGINT_IMPL_xxx are defined in the Makefile. // #ifdef LONGINT_IMPL_NONE @@ -355,8 +340,10 @@ extern const struct _mp_obj_module_t nvm_module; #if CIRCUITPY_OS extern const struct _mp_obj_module_t os_module; #define OS_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_os), (mp_obj_t)&os_module }, +#define OS_MODULE_ALT_NAME { MP_OBJ_NEW_QSTR(MP_QSTR__os), (mp_obj_t)&os_module }, #else #define OS_MODULE +#define OS_MODULE_ALT_NAME #endif #if CIRCUITPY_PIXELBUF @@ -432,8 +419,10 @@ extern const struct _mp_obj_module_t supervisor_module; #if CIRCUITPY_TIME extern const struct _mp_obj_module_t time_module; #define TIME_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_time), (mp_obj_t)&time_module }, +#define TIME_MODULE_ALT_NAME { MP_OBJ_NEW_QSTR(MP_QSTR__time), (mp_obj_t)&time_module }, #else #define TIME_MODULE +#define TIME_MODULE_ALT_NAME #endif #if CIRCUITPY_TOUCHIO @@ -471,18 +460,44 @@ extern const struct _mp_obj_module_t ustack_module; #define USTACK_MODULE #endif +// These modules are not yet in shared-bindings, but we prefer the non-uxxx names. +#if MICROPY_PY_UERRNO +#define ERRNO_MODULE { MP_ROM_QSTR(MP_QSTR_errno), MP_ROM_PTR(&mp_module_uerrno) }, +#else +#define ERRNO_MODULE +#endif + #if MICROPY_PY_UJSON -#define JSON_MODULE { MP_ROM_QSTR(MP_QSTR_json), MP_ROM_PTR(&mp_module_ujson) }, +#define JSON_MODULE { MP_ROM_QSTR(MP_QSTR_json), MP_ROM_PTR(&mp_module_ujson) }, #else #define JSON_MODULE #endif +#if MICROPY_PY_URE +#define RE_MODULE { MP_ROM_QSTR(MP_QSTR_re), MP_ROM_PTR(&mp_module_ure) }, +#else +#define RE_MODULE +#endif + +// Define certain native modules with weak links so they can be replaced with Python +// implementations. This list may grow over time. +#define MICROPY_PORT_BUILTIN_MODULE_WEAK_LINKS \ + OS_MODULE \ + TIME_MODULE \ + +// Native modules that are weak links can be accessed directly +// by prepending their name with an underscore. This list should correspond to +// MICROPY_PORT_BUILTIN_MODULE_WEAK_LINKS, assuming you want the native modules +// to be accessible when overriden. +#define MICROPY_PORT_BUILTIN_MODULE_ALT_NAMES \ + OS_MODULE_ALT_NAME \ + TIME_MODULE_ALT_NAME \ // This is an inclusive list that should correspond to the CIRCUITPY_XXX list above, -// including dependendencies such as TERMINALIO depending on DISPLAYIO (shown by indentation). +// including dependencies such as TERMINALIO depending on DISPLAYIO (shown by indentation). // Some of these definitions will be blank depending on what is turned on and off. -// -#define MICROPY_PORT_BUILTIN_MODULES \ +// Some are omitted because they're in MICROPY_PORT_BUILTIN_MODULE_WEAK_LINKS above. +#define MICROPY_PORT_BUILTIN_MODULES_STRONG_LINKS \ ANALOGIO_MODULE \ AUDIOBUSIO_MODULE \ AUDIOIO_MODULE \ @@ -493,6 +508,7 @@ extern const struct _mp_obj_module_t ustack_module; DIGITALIO_MODULE \ TERMINALIO_MODULE \ DISPLAYIO_MODULE \ + ERRNO_MODULE \ GAMEPAD_MODULE \ I2CSLAVE_MODULE \ JSON_MODULE \ @@ -502,23 +518,34 @@ extern const struct _mp_obj_module_t ustack_module; NETWORK_MODULE \ SOCKET_MODULE \ WIZNET_MODULE \ - OS_MODULE \ PIXELBUF_MODULE \ PULSEIO_MODULE \ RANDOM_MODULE \ + RE_MODULE \ RTC_MODULE \ SAMD_MODULE \ STAGE_MODULE \ STORAGE_MODULE \ STRUCT_MODULE \ SUPERVISOR_MODULE \ - TIME_MODULE \ TOUCHIO_MODULE \ UHEAP_MODULE \ USB_HID_MODULE \ USB_MIDI_MODULE \ USTACK_MODULE \ - MICROPY_PORT_BUILTIN_MODULE_WEAK_LINK_ALTERNATES + +// If weak links are enabled, just include strong links in the main list of modules, +// and also include the underscore alternate names. +#if MICROPY_MODULE_WEAK_LINKS +#define MICROPY_PORT_BUILTIN_MODULES \ + MICROPY_PORT_BUILTIN_MODULES_STRONG_LINKS \ + MICROPY_PORT_BUILTIN_MODULE_ALT_NAMES +#else +// If weak links are disabled, included both strong and potentially weak lines +#define MICROPY_PORT_BUILTIN_MODULES \ + MICROPY_PORT_BUILTIN_MODULES_STRONG_LINKS \ + MICROPY_PORT_BUILTIN_MODULE_WEAK_LINKS +#endif // We need to provide a declaration/definition of alloca() #include <alloca.h> diff --git a/py/circuitpy_mpconfig.mk b/py/circuitpy_mpconfig.mk index 30d5a7554..a4a59170f 100644 --- a/py/circuitpy_mpconfig.mk +++ b/py/circuitpy_mpconfig.mk @@ -158,15 +158,12 @@ CIRCUITPY_RTC = 1 endif CFLAGS += -DCIRCUITPY_RTC=$(CIRCUITPY_RTC) +# CIRCUITPY_SAMD is handled in the atmel-samd tree. # Only for SAMD chips. +# Assume not a SAMD build. ifndef CIRCUITPY_SAMD -ifneq ($(findstring sam,$(CHIP_FAMILY)),) -CIRCUITPY_SAMD = $(CIRCUITPY_FULL_BUILD) -else -# Not a SAMD build. CIRCUITPY_SAMD = 0 endif -endif CFLAGS += -DCIRCUITPY_SAMD=$(CIRCUITPY_SAMD) # Currently always off. diff --git a/py/objmodule.c b/py/objmodule.c index 828f556f3..4ac94311e 100644 --- a/py/objmodule.c +++ b/py/objmodule.c @@ -148,6 +148,7 @@ STATIC const mp_rom_map_elem_t mp_builtin_module_table[] = { { MP_ROM_QSTR(MP_QSTR_array), MP_ROM_PTR(&mp_module_array) }, #endif #if MICROPY_PY_IO + { MP_ROM_QSTR(MP_QSTR_io), MP_ROM_PTR(&mp_module_io) }, { MP_ROM_QSTR(MP_QSTR_uio), MP_ROM_PTR(&mp_module_io) }, #endif #if MICROPY_PY_COLLECTIONS |
