From b89422ceaa8746a9e8441426bb9c0d5eb5a6e040 Mon Sep 17 00:00:00 2001 From: Damien George Date: Mon, 18 Jul 2022 22:55:22 +1000 Subject: [PATCH] extmod: Always use custom mbedtls error message code. All ports that use mbedtls use the custom error messages in mp_mbedtls_errors.c. This commit simplifies the build so that ports don't need to explicitly add this file, it's now used by default when mbedtls is enabled. Signed-off-by: Damien George --- extmod/extmod.cmake | 2 +- extmod/extmod.mk | 2 +- ports/mimxrt/Makefile | 4 +--- ports/rp2/CMakeLists.txt | 7 ------- ports/stm32/Makefile | 3 --- ports/unix/Makefile | 3 --- 6 files changed, 3 insertions(+), 18 deletions(-) diff --git a/extmod/extmod.cmake b/extmod/extmod.cmake index 8fe83a0ada..954bfc7e96 100644 --- a/extmod/extmod.cmake +++ b/extmod/extmod.cmake @@ -114,6 +114,7 @@ if(MICROPY_SSL_MBEDTLS) ) target_sources(micropy_lib_mbedtls INTERFACE + ${MICROPY_DIR}/lib/mbedtls_errors/mp_mbedtls_errors.c ${MICROPY_LIB_MBEDTLS_DIR}/library/aes.c ${MICROPY_LIB_MBEDTLS_DIR}/library/aesni.c ${MICROPY_LIB_MBEDTLS_DIR}/library/arc4.c @@ -141,7 +142,6 @@ if(MICROPY_SSL_MBEDTLS) ${MICROPY_LIB_MBEDTLS_DIR}/library/ecp_curves.c ${MICROPY_LIB_MBEDTLS_DIR}/library/entropy.c ${MICROPY_LIB_MBEDTLS_DIR}/library/entropy_poll.c - ${MICROPY_LIB_MBEDTLS_DIR}/library/error.c ${MICROPY_LIB_MBEDTLS_DIR}/library/gcm.c ${MICROPY_LIB_MBEDTLS_DIR}/library/havege.c ${MICROPY_LIB_MBEDTLS_DIR}/library/hmac_drbg.c diff --git a/extmod/extmod.mk b/extmod/extmod.mk index 93b2a11766..ae3e45bd55 100644 --- a/extmod/extmod.mk +++ b/extmod/extmod.mk @@ -119,6 +119,7 @@ SRC_MOD += $(addprefix $(AXTLS_DIR)/,\ else ifeq ($(MICROPY_SSL_MBEDTLS),1) MBEDTLS_DIR = lib/mbedtls CFLAGS_MOD += -DMICROPY_SSL_MBEDTLS=1 -I$(TOP)/$(MBEDTLS_DIR)/include +SRC_MOD += lib/mbedtls_errors/mp_mbedtls_errors.c SRC_MOD += $(addprefix $(MBEDTLS_DIR)/library/,\ aes.c \ aesni.c \ @@ -147,7 +148,6 @@ SRC_MOD += $(addprefix $(MBEDTLS_DIR)/library/,\ ecp_curves.c \ entropy.c \ entropy_poll.c \ - error.c \ gcm.c \ havege.c \ hmac_drbg.c \ diff --git a/ports/mimxrt/Makefile b/ports/mimxrt/Makefile index be1c95ba95..150727577f 100644 --- a/ports/mimxrt/Makefile +++ b/ports/mimxrt/Makefile @@ -96,15 +96,13 @@ SRC_TINYUSB_C += \ # All settings for Ethernet support are controller by the value of MICROPY_PY_LWIP ifeq ($(MICROPY_PY_LWIP),1) -SRC_MOD := $(filter-out %/mbedtls/library/error.c, $(SRC_MOD)) SRC_ETH_C += \ $(MCU_DIR)/drivers/fsl_enet.c \ hal/phy/device/phydp83825/fsl_phydp83825.c \ hal/phy/device/phydp83848/fsl_phydp83848.c \ hal/phy/device/phyksz8081/fsl_phyksz8081.c \ hal/phy/device/phylan8720/fsl_phylan8720.c \ - hal/phy/mdio/enet/fsl_enet_mdio.c \ - lib/mbedtls_errors/mp_mbedtls_errors.c + hal/phy/mdio/enet/fsl_enet_mdio.c endif # NXP SDK sources diff --git a/ports/rp2/CMakeLists.txt b/ports/rp2/CMakeLists.txt index 8f7895459e..f9a9efe62a 100644 --- a/ports/rp2/CMakeLists.txt +++ b/ports/rp2/CMakeLists.txt @@ -77,7 +77,6 @@ set(MICROPY_SOURCE_LIB ${MICROPY_DIR}/lib/littlefs/lfs1_util.c ${MICROPY_DIR}/lib/littlefs/lfs2.c ${MICROPY_DIR}/lib/littlefs/lfs2_util.c - ${MICROPY_DIR}/lib/mbedtls_errors/mp_mbedtls_errors.c ${MICROPY_DIR}/lib/oofatfs/ff.c ${MICROPY_DIR}/lib/oofatfs/ffunicode.c ${MICROPY_DIR}/shared/netutils/dhcpserver.c @@ -343,12 +342,6 @@ target_sources(${MICROPY_TARGET} PRIVATE target_link_libraries(${MICROPY_TARGET} micropy_lib_mbedtls) -# Filter out library/error.c as we're using mp_mbedtls_errors.c instead. -set_source_files_properties(${MICROPY_LIB_MBEDTLS_DIR}/library/error.c - TARGET_DIRECTORY micropy_lib_mbedtls - PROPERTIES HEADER_FILE_ONLY ON -) - target_link_libraries(${MICROPY_TARGET} usermod) target_include_directories(${MICROPY_TARGET} PRIVATE diff --git a/ports/stm32/Makefile b/ports/stm32/Makefile index bab62eaae9..75a1abeabd 100644 --- a/ports/stm32/Makefile +++ b/ports/stm32/Makefile @@ -499,9 +499,6 @@ endif ifeq ($(MICROPY_SSL_MBEDTLS),1) CFLAGS_MOD += -DMBEDTLS_CONFIG_FILE='"mbedtls/mbedtls_config.h"' SRC_MOD += mbedtls/mbedtls_port.c -# replace mbedtls' error.c by ours -SRC_MOD := $(filter-out %/mbedtls/library/error.c, $(SRC_MOD)) -LIB_SRC_C += lib/mbedtls_errors/mp_mbedtls_errors.c endif ifeq ($(MICROPY_PY_BLUETOOTH),1) diff --git a/ports/unix/Makefile b/ports/unix/Makefile index 05b8d9bff6..04d2242a27 100644 --- a/ports/unix/Makefile +++ b/ports/unix/Makefile @@ -140,9 +140,6 @@ endif ifeq ($(MICROPY_SSL_MBEDTLS),1) GIT_SUBMODULES += lib/mbedtls CFLAGS_MOD += -DMBEDTLS_CONFIG_FILE='"mbedtls/mbedtls_config.h"' -# replace mbedtls' error.c by ours -SRC_MOD := $(filter-out %/mbedtls/library/error.c, $(SRC_MOD)) -LIB_SRC_C += lib/mbedtls_errors/mp_mbedtls_errors.c endif endif