mirror of
https://github.com/espressif/openthread.git
synced 2026-06-05 21:14:49 +00:00
[build] enable -Wundef for MTD, FTD, and Radio builds (#11418)
This commit adds the `-Wundef` compiler flag to the OpenThread core, CLI, and NCP builds when configured for MTD, FTD, or Radio types. This flag helps ensure that no undefined macros are used within the source code, protecting against potential typos in conditional compilation checks (`#if` checks).
This commit is contained in:
committed by
GitHub
parent
e1407fbab6
commit
2918437bb8
@@ -122,15 +122,21 @@ list(APPEND OT_PUBLIC_INCLUDES ${PROJECT_SOURCE_DIR}/include)
|
||||
if(OT_PLATFORM STREQUAL "posix")
|
||||
target_include_directories(ot-config INTERFACE ${PROJECT_SOURCE_DIR}/src/posix/platform)
|
||||
target_compile_definitions(ot-config INTERFACE OPENTHREAD_PLATFORM_POSIX=1)
|
||||
target_compile_definitions(ot-config INTERFACE OPENTHREAD_PLATFORM_NEXUS=0)
|
||||
add_subdirectory("${PROJECT_SOURCE_DIR}/src/posix/platform")
|
||||
elseif(OT_PLATFORM STREQUAL "external")
|
||||
target_compile_definitions(ot-config INTERFACE OPENTHREAD_PLATFORM_POSIX=0)
|
||||
target_compile_definitions(ot-config INTERFACE OPENTHREAD_PLATFORM_NEXUS=0)
|
||||
# skip in this case
|
||||
elseif(OT_PLATFORM STREQUAL "nexus")
|
||||
if (OT_APP_CLI OR OT_APP_NCP OR OT_APP_RCP)
|
||||
message(FATAL_ERROR "no app (cli/ncp/rcp) should be enabled with nexus simulation platform")
|
||||
endif()
|
||||
target_compile_definitions(ot-config INTERFACE OPENTHREAD_PLATFORM_NEXUS=1)
|
||||
target_compile_definitions(ot-config INTERFACE OPENTHREAD_PLATFORM_POSIX=0)
|
||||
else()
|
||||
target_compile_definitions(ot-config INTERFACE OPENTHREAD_PLATFORM_POSIX=0)
|
||||
target_compile_definitions(ot-config INTERFACE OPENTHREAD_PLATFORM_NEXUS=0)
|
||||
target_include_directories(ot-config INTERFACE ${PROJECT_SOURCE_DIR}/examples/platforms/${OT_PLATFORM})
|
||||
add_subdirectory("${PROJECT_SOURCE_DIR}/examples/platforms/${OT_PLATFORM}")
|
||||
endif()
|
||||
|
||||
@@ -37,6 +37,7 @@ target_compile_definitions(openthread-cli-ftd
|
||||
|
||||
target_compile_options(openthread-cli-ftd PRIVATE
|
||||
${OT_CFLAGS}
|
||||
-Wundef
|
||||
)
|
||||
|
||||
target_include_directories(openthread-cli-ftd PUBLIC ${OT_PUBLIC_INCLUDES} PRIVATE ${COMMON_INCLUDES})
|
||||
|
||||
@@ -37,6 +37,7 @@ target_compile_definitions(openthread-cli-mtd
|
||||
|
||||
target_compile_options(openthread-cli-mtd PRIVATE
|
||||
${OT_CFLAGS}
|
||||
-Wundef
|
||||
)
|
||||
|
||||
target_include_directories(openthread-cli-mtd PUBLIC ${OT_PUBLIC_INCLUDES} PRIVATE ${COMMON_INCLUDES})
|
||||
|
||||
@@ -38,6 +38,7 @@ target_compile_definitions(openthread-cli-radio
|
||||
|
||||
target_compile_options(openthread-cli-radio PRIVATE
|
||||
${OT_CFLAGS}
|
||||
-Wundef
|
||||
)
|
||||
|
||||
target_include_directories(openthread-cli-radio PUBLIC ${OT_PUBLIC_INCLUDES} PRIVATE ${COMMON_INCLUDES})
|
||||
|
||||
@@ -381,6 +381,15 @@
|
||||
#define OPENTHREAD_CONFIG_POSIX_SETTINGS_PATH "tmp"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_PLATFORM_BOOTLOADER_MODE_ENABLE
|
||||
*
|
||||
* Define to 1 to enable support reset to bootloader mode.
|
||||
*/
|
||||
#ifndef OPENTHREAD_CONFIG_PLATFORM_BOOTLOADER_MODE_ENABLE
|
||||
#define OPENTHREAD_CONFIG_PLATFORM_BOOTLOADER_MODE_ENABLE 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_PLATFORM_FLASH_API_ENABLE
|
||||
*
|
||||
@@ -590,6 +599,24 @@
|
||||
#define OPENTHREAD_CONFIG_PLATFORM_LOG_CRASH_DUMP_ENABLE 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_ENABLE_VENDOR_EXTENSION
|
||||
*
|
||||
* Define to 1 to enable vendor extension support.
|
||||
*/
|
||||
#ifndef OPENTHREAD_ENABLE_VENDOR_EXTENSION
|
||||
#define OPENTHREAD_ENABLE_VENDOR_EXTENSION 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_EXAMPLES_SIMULATION
|
||||
*
|
||||
* Define 1 to to enable simulation example support.
|
||||
*/
|
||||
#ifndef OPENTHREAD_EXAMPLES_SIMULATION
|
||||
#define OPENTHREAD_EXAMPLES_SIMULATION 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
@@ -36,6 +36,7 @@ target_compile_definitions(openthread-ftd PRIVATE
|
||||
|
||||
target_compile_options(openthread-ftd PRIVATE
|
||||
${OT_CFLAGS}
|
||||
-Wundef
|
||||
)
|
||||
|
||||
target_include_directories(openthread-ftd PUBLIC ${OT_PUBLIC_INCLUDES} PRIVATE ${COMMON_INCLUDES})
|
||||
|
||||
@@ -36,6 +36,7 @@ target_compile_definitions(openthread-mtd PRIVATE
|
||||
|
||||
target_compile_options(openthread-mtd PRIVATE
|
||||
${OT_CFLAGS}
|
||||
-Wundef
|
||||
)
|
||||
|
||||
target_include_directories(openthread-mtd PUBLIC ${OT_PUBLIC_INCLUDES} PRIVATE ${COMMON_INCLUDES})
|
||||
|
||||
@@ -37,6 +37,7 @@ target_compile_definitions(openthread-radio PRIVATE
|
||||
|
||||
target_compile_options(openthread-radio PRIVATE
|
||||
${OT_CFLAGS}
|
||||
-Wundef
|
||||
)
|
||||
|
||||
target_include_directories(openthread-radio PUBLIC ${OT_PUBLIC_INCLUDES} PRIVATE ${COMMON_INCLUDES})
|
||||
|
||||
@@ -37,6 +37,7 @@ target_compile_definitions(openthread-ncp-ftd PRIVATE
|
||||
|
||||
target_compile_options(openthread-ncp-ftd PRIVATE
|
||||
${OT_CFLAGS}
|
||||
-Wundef
|
||||
)
|
||||
|
||||
target_include_directories(openthread-ncp-ftd PUBLIC ${OT_PUBLIC_INCLUDES} PRIVATE ${COMMON_INCLUDES})
|
||||
|
||||
@@ -37,6 +37,7 @@ target_compile_definitions(openthread-ncp-mtd PRIVATE
|
||||
|
||||
target_compile_options(openthread-ncp-mtd PRIVATE
|
||||
${OT_CFLAGS}
|
||||
-Wundef
|
||||
)
|
||||
|
||||
target_include_directories(openthread-ncp-mtd PUBLIC ${OT_PUBLIC_INCLUDES} PRIVATE ${COMMON_INCLUDES})
|
||||
|
||||
@@ -207,4 +207,13 @@
|
||||
#define OPENTHREAD_ENABLE_NCP_VENDOR_HOOK 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_ENABLE_NCP_SPINEL_ENCRYPTER
|
||||
*
|
||||
* Define to 1 to enable NCP spinel encrypter.
|
||||
*/
|
||||
#ifndef OPENTHREAD_ENABLE_NCP_SPINEL_ENCRYPTER
|
||||
#define OPENTHREAD_ENABLE_NCP_SPINEL_ENCRYPTER 0
|
||||
#endif
|
||||
|
||||
#endif // CONFIG_NCP_H_
|
||||
|
||||
Reference in New Issue
Block a user