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>
This commit is contained in:
Damien George 2022-06-19 01:29:41 +10:00
parent 1842efbdd9
commit f5769698e5
7 changed files with 7 additions and 11 deletions

View File

@ -16,6 +16,7 @@ set(MICROPY_SOURCE_EXTMOD
${MICROPY_EXTMOD_DIR}/modbluetooth.c
${MICROPY_EXTMOD_DIR}/modbtree.c
${MICROPY_EXTMOD_DIR}/modframebuf.c
${MICROPY_EXTMOD_DIR}/modlwip.c
${MICROPY_EXTMOD_DIR}/modnetwork.c
${MICROPY_EXTMOD_DIR}/modonewire.c
${MICROPY_EXTMOD_DIR}/moduasyncio.c
@ -246,4 +247,6 @@ if(MICROPY_PY_LWIP)
list(APPEND MICROPY_INC_CORE
${MICROPY_LIB_LWIP_DIR}/include
)
string(CONCAT GIT_SUBMODULES "${GIT_SUBMODULES} " lib/lwip)
endif()

View File

@ -153,7 +153,7 @@ LWIP_DIR = lib/lwip/src
INC += -I$(TOP)/$(LWIP_DIR)/include
CFLAGS_MOD += -DMICROPY_PY_LWIP=1
$(BUILD)/$(LWIP_DIR)/core/ipv4/dhcp.o: CFLAGS_MOD += -Wno-address
SRC_MOD += extmod/modlwip.c shared/netutils/netutils.c
SRC_MOD += shared/netutils/netutils.c
SRC_MOD += $(addprefix $(LWIP_DIR)/,\
apps/mdns/mdns.c \
core/def.c \

View File

@ -35,6 +35,8 @@
#include "py/mperrno.h"
#include "py/mphal.h"
#if MICROPY_PY_LWIP
#include "shared/netutils/netutils.h"
#include "lwip/init.h"
@ -1741,8 +1743,6 @@ STATIC mp_obj_t lwip_print_pcbs() {
}
MP_DEFINE_CONST_FUN_OBJ_0(lwip_print_pcbs_obj, lwip_print_pcbs);
#if MICROPY_PY_LWIP
STATIC const mp_rom_map_elem_t mp_module_lwip_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_lwip) },
{ MP_ROM_QSTR(MP_QSTR_reset), MP_ROM_PTR(&mod_lwip_reset_obj) },

View File

@ -109,7 +109,6 @@ SRC_C = \
$(SRC_MOD)
EXTMOD_SRC_C = $(addprefix extmod/,\
modlwip.c \
modonewire.c \
)

View File

@ -150,7 +150,6 @@ SRC_ETH_C += \
$(MCU_DIR)/drivers/fsl_enet.c \
SRC_QSTR += \
extmod/modlwip.c \
extmod/modnetwork.c \
extmod/moduwebsocket.c \
extmod/modusocket.c \

View File

@ -182,12 +182,6 @@ if (MICROPY_PY_LWIP)
target_compile_definitions(${MICROPY_TARGET} PRIVATE
MICROPY_PY_LWIP=1
)
list(APPEND MICROPY_SOURCE_EXTMOD
${MICROPY_EXTMOD_DIR}/modlwip.c
)
string(CONCAT GIT_SUBMODULES "${GIT_SUBMODULES} " lib/lwip)
endif()
if(MICROPY_PY_BLUETOOTH)

View File

@ -194,6 +194,7 @@ PY_EXTMOD_O_BASENAME = \
extmod/machine_i2c.o \
extmod/machine_spi.o \
extmod/modbluetooth.o \
extmod/modlwip.o \
extmod/modussl_axtls.o \
extmod/modussl_mbedtls.o \
extmod/moduplatform.o\