feat(tool): Adds idf_build_remove_options_from_property func

This commit is contained in:
Konstantin Kondrashov 2024-06-06 22:24:20 +03:00 committed by BOT
parent 9456c157ff
commit e596cb5527
2 changed files with 30 additions and 6 deletions

View File

@ -202,14 +202,9 @@ if(CONFIG_COMPILER_DISABLE_GCC13_WARNINGS)
endif()
if(CONFIG_COMPILER_DISABLE_DEFAULT_ERRORS)
set(compiler_flags "-Wno-error")
if(NOT CMAKE_C_COMPILER_ID MATCHES "Clang")
list(APPEND compiler_flags "-Werror=all")
idf_build_replace_option_from_property(COMPILE_OPTIONS "-Werror" "-Werror=all")
endif()
list(APPEND compile_options ${compiler_flags})
list(APPEND c_compile_options ${compiler_flags})
list(APPEND cxx_compile_options ${compiler_flags})
endif()
# GCC-specific options

View File

@ -61,6 +61,35 @@ function(idf_build_unset_property property)
idf_build_set_property(__BUILD_PROPERTIES "${build_properties}")
endfunction()
# idf_build_replace_option_from_property
#
# @brief Replace specified option with new one in a given property.
#
# @param[in] property_name the property in which to replace the options (ex.: COMPILE_OPTIONS, C_COMPILE_OPTIONS,..)
#
# @param[in] option_to_remove the option to be replaced
# @param[in] new_option the option to replace with (if empty, the old option will be removed)
#
# Example usage:
# idf_build_replace_options_from_property(COMPILE_OPTIONS "-Werror" "-Werror=all")
# idf_build_replace_options_from_property(COMPILE_OPTIONS "-Wno-error=extra" "")
#
function(idf_build_replace_option_from_property property_name option_to_remove new_option)
idf_build_get_property(current_list_of_options ${property_name})
set(new_list_of_options)
foreach(option ${current_list_of_options})
if(option STREQUAL option_to_remove)
list(APPEND new_list_of_options "${new_option}")
else()
list(APPEND new_list_of_options "${option}")
endif()
endforeach()
# Set the updated list back
idf_build_set_property(${property_name} "${new_list_of_options}")
endfunction()
#
# Retrieve the IDF_PATH repository's version, either using a version
# file or Git revision. Sets the IDF_VER build property.