From f5769698e5fca8fbae5b86c649204e915b22b19f Mon Sep 17 00:00:00 2001 From: Damien George Date: Sun, 19 Jun 2022 01:29:41 +1000 Subject: [PATCH] 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 --- extmod/extmod.cmake | 3 +++ extmod/extmod.mk | 2 +- extmod/modlwip.c | 4 ++-- ports/esp8266/Makefile | 1 - ports/mimxrt/Makefile | 1 - ports/rp2/CMakeLists.txt | 6 ------ py/py.mk | 1 + 7 files changed, 7 insertions(+), 11 deletions(-) diff --git a/extmod/extmod.cmake b/extmod/extmod.cmake index 551dec714c..966511fac5 100644 --- a/extmod/extmod.cmake +++ b/extmod/extmod.cmake @@ -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() diff --git a/extmod/extmod.mk b/extmod/extmod.mk index ff24a549a9..60f59183d5 100644 --- a/extmod/extmod.mk +++ b/extmod/extmod.mk @@ -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 \ diff --git a/extmod/modlwip.c b/extmod/modlwip.c index ec5f3bfd63..bbfd3a2253 100644 --- a/extmod/modlwip.c +++ b/extmod/modlwip.c @@ -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) }, diff --git a/ports/esp8266/Makefile b/ports/esp8266/Makefile index 705f4f1eeb..96dff46e3e 100644 --- a/ports/esp8266/Makefile +++ b/ports/esp8266/Makefile @@ -109,7 +109,6 @@ SRC_C = \ $(SRC_MOD) EXTMOD_SRC_C = $(addprefix extmod/,\ - modlwip.c \ modonewire.c \ ) diff --git a/ports/mimxrt/Makefile b/ports/mimxrt/Makefile index cfcdb9f7d5..bb6d4d8653 100644 --- a/ports/mimxrt/Makefile +++ b/ports/mimxrt/Makefile @@ -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 \ diff --git a/ports/rp2/CMakeLists.txt b/ports/rp2/CMakeLists.txt index a7a192ea33..d6a428c91c 100644 --- a/ports/rp2/CMakeLists.txt +++ b/ports/rp2/CMakeLists.txt @@ -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) diff --git a/py/py.mk b/py/py.mk index 57fdb6d9b5..49b94b279a 100644 --- a/py/py.mk +++ b/py/py.mk @@ -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\