mirror of
https://github.com/hathach/tinyusb.git
synced 2025-10-29 19:49:07 +00:00
improve warnings with rp2040 family
This commit is contained in:
parent
8865ec4781
commit
d55e074a36
@ -63,8 +63,9 @@ set(WARN_FLAGS_GNU
|
||||
-Wunused
|
||||
-Wunused-function
|
||||
-Wreturn-type
|
||||
#-Wredundant-decls
|
||||
#-Wmissing-prototypes
|
||||
-Wredundant-decls
|
||||
-Wmissing-prototypes
|
||||
# -Wconversion
|
||||
)
|
||||
set(WARN_FLAGS_Clang ${WARN_FLAGS_GNU})
|
||||
|
||||
@ -391,56 +392,6 @@ function(family_example_missing_dependency TARGET DEPENDENCY)
|
||||
message(WARNING "${DEPENDENCY} submodule needed by ${TARGET} not found, please run 'python tools/get_deps.py ${DEPENDENCY}' to fetch it")
|
||||
endfunction()
|
||||
|
||||
#----------------------------------
|
||||
# RPI specific: refactor later
|
||||
#----------------------------------
|
||||
function(family_add_default_example_warnings TARGET)
|
||||
target_compile_options(${TARGET} PUBLIC
|
||||
-Wall
|
||||
-Wextra
|
||||
-Werror
|
||||
-Wfatal-errors
|
||||
-Wdouble-promotion
|
||||
-Wfloat-equal
|
||||
# FIXME commented out because of https://github.com/raspberrypi/pico-sdk/issues/1468
|
||||
#-Wshadow
|
||||
-Wwrite-strings
|
||||
-Wsign-compare
|
||||
-Wmissing-format-attribute
|
||||
-Wunreachable-code
|
||||
-Wcast-align
|
||||
-Wcast-qual
|
||||
-Wnull-dereference
|
||||
-Wuninitialized
|
||||
-Wunused
|
||||
-Wredundant-decls
|
||||
#-Wstrict-prototypes
|
||||
#-Werror-implicit-function-declaration
|
||||
#-Wundef
|
||||
)
|
||||
|
||||
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
||||
if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 12.0 AND NO_WARN_RWX_SEGMENTS_SUPPORTED)
|
||||
target_link_options(${TARGET} PUBLIC "LINKER:--no-warn-rwx-segments")
|
||||
endif()
|
||||
|
||||
# GCC 10
|
||||
if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 10.0)
|
||||
target_compile_options(${TARGET} PUBLIC -Wconversion)
|
||||
endif()
|
||||
|
||||
# GCC 8
|
||||
if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0)
|
||||
target_compile_options(${TARGET} PUBLIC -Wcast-function-type -Wstrict-overflow)
|
||||
endif()
|
||||
|
||||
# GCC 6
|
||||
if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 6.0)
|
||||
target_compile_options(${TARGET} PUBLIC -Wno-strict-aliasing)
|
||||
endif()
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
#----------------------------------
|
||||
# Flashing target
|
||||
#----------------------------------
|
||||
|
||||
@ -92,7 +92,7 @@ static uart_inst_t *uart_inst;
|
||||
//
|
||||
// This doesn't work if others are trying to access flash at the same time,
|
||||
// e.g. XIP streamer, or the other core.
|
||||
bool __no_inline_not_in_flash_func(get_bootsel_button)(void) {
|
||||
static bool __no_inline_not_in_flash_func(get_bootsel_button)(void) {
|
||||
const uint CS_PIN_INDEX = 1;
|
||||
|
||||
// Must disable interrupts, as interrupt handlers may be in flash, and we
|
||||
|
||||
@ -184,6 +184,43 @@ endif()
|
||||
#------------------------------------
|
||||
# Functions
|
||||
#------------------------------------
|
||||
function(family_add_default_example_warnings TARGET)
|
||||
# Apply warnings to all TinyUSB interface library sources as well as examples sources
|
||||
# we cannot set compile options for target since it will not propagate to INTERFACE sources then picosdk files
|
||||
foreach(TINYUSB_TARGET IN ITEMS tinyusb_common_base tinyusb_device_base tinyusb_host_base tinyusb_host_max3421 tinyusb_bsp)
|
||||
get_target_property(TINYUSB_SOURCES ${TINYUSB_TARGET} INTERFACE_SOURCES)
|
||||
set_source_files_properties(${TINYUSB_SOURCES} PROPERTIES COMPILE_OPTIONS "${WARN_FLAGS_${CMAKE_C_COMPILER_ID}}")
|
||||
endforeach()
|
||||
|
||||
# Also apply to example sources, but filter out any source files from lib/ (e.g. fatfs)
|
||||
get_target_property(EXAMPLE_SOURCES ${TARGET} SOURCES)
|
||||
set(FILTERED_SOURCES "")
|
||||
foreach(SOURCE_FILE IN LISTS EXAMPLE_SOURCES)
|
||||
string(FIND "${SOURCE_FILE}" "${TOP}/lib" FOUND_POS)
|
||||
if(FOUND_POS EQUAL -1)
|
||||
list(APPEND FILTERED_SOURCES ${SOURCE_FILE})
|
||||
endif()
|
||||
endforeach()
|
||||
set_source_files_properties(${FILTERED_SOURCES} PROPERTIES COMPILE_OPTIONS "${WARN_FLAGS_${CMAKE_C_COMPILER_ID}}")
|
||||
|
||||
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
||||
if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 12.0 AND NO_WARN_RWX_SEGMENTS_SUPPORTED)
|
||||
target_link_options(${TARGET} PRIVATE "LINKER:--no-warn-rwx-segments")
|
||||
endif()
|
||||
|
||||
if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 10.0)
|
||||
target_compile_options(${TARGET} PRIVATE -Wconversion)
|
||||
endif()
|
||||
|
||||
if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0)
|
||||
target_compile_options(${TARGET} PRIVATE -Wcast-function-type -Wstrict-overflow)
|
||||
endif()
|
||||
|
||||
if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 6.0)
|
||||
target_compile_options(${TARGET} PRIVATE -Wno-strict-aliasing)
|
||||
endif()
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(family_configure_target TARGET RTOS)
|
||||
if (RTOS STREQUAL noos OR RTOS STREQUAL "")
|
||||
@ -204,7 +241,7 @@ function(family_configure_target TARGET RTOS)
|
||||
pico_enable_stdio_uart(${TARGET} 1)
|
||||
target_link_libraries(${TARGET} PUBLIC pico_stdlib tinyusb_board${RTOS_SUFFIX} tinyusb_additions)
|
||||
|
||||
family_flash_openocd(${TARGET})
|
||||
family_flash_openocd(${TARGET})
|
||||
family_flash_jlink(${TARGET})
|
||||
endfunction()
|
||||
|
||||
@ -359,34 +396,9 @@ function(suppress_tinyusb_warnings)
|
||||
${PICO_TINYUSB_PATH}/src/portable/raspberrypi/rp2040/hcd_rp2040.c
|
||||
)
|
||||
foreach(SOURCE_FILE IN LISTS CONVERSION_WARNING_FILES)
|
||||
set_source_files_properties(
|
||||
${SOURCE_FILE}
|
||||
PROPERTIES
|
||||
COMPILE_FLAGS "-Wno-conversion")
|
||||
set_source_files_properties(${SOURCE_FILE} PROPERTIES COMPILE_FLAGS "-Wno-conversion")
|
||||
endforeach()
|
||||
endif()
|
||||
if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 11.0)
|
||||
set_source_files_properties(
|
||||
${PICO_TINYUSB_PATH}/lib/fatfs/source/ff.c
|
||||
COMPILE_FLAGS "-Wno-stringop-overflow -Wno-array-bounds")
|
||||
endif()
|
||||
set_source_files_properties(
|
||||
${PICO_TINYUSB_PATH}/lib/fatfs/source/ff.c
|
||||
PROPERTIES
|
||||
COMPILE_FLAGS "-Wno-conversion -Wno-cast-qual")
|
||||
|
||||
set_source_files_properties(
|
||||
${PICO_TINYUSB_PATH}/lib/lwip/src/core/tcp_in.c
|
||||
${PICO_TINYUSB_PATH}/lib/lwip/src/core/tcp_out.c
|
||||
PROPERTIES
|
||||
COMPILE_FLAGS "-Wno-conversion")
|
||||
|
||||
set_source_files_properties(
|
||||
${PICO_TINYUSB_PATH}/lib/networking/dnserver.c
|
||||
${PICO_TINYUSB_PATH}/lib/networking/dhserver.c
|
||||
${PICO_TINYUSB_PATH}/lib/networking/rndis_reports.c
|
||||
PROPERTIES
|
||||
COMPILE_FLAGS "-Wno-conversion -Wno-sign-conversion")
|
||||
|
||||
if (TARGET tinyusb_pico_pio_usb)
|
||||
set_source_files_properties(
|
||||
|
||||
@ -29,9 +29,20 @@
|
||||
#if CFG_TUH_ENABLED && (CFG_TUSB_MCU == OPT_MCU_RP2040) && CFG_TUH_RPI_PIO_USB
|
||||
|
||||
#include "pico.h"
|
||||
|
||||
#include "pio_usb.h"
|
||||
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wsign-conversion"
|
||||
#endif
|
||||
|
||||
#include "pio_usb_ll.h"
|
||||
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// INCLUDE
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user