diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn index fd50779710a66d..9514db60332582 100644 --- a/build/config/compiler/BUILD.gn +++ b/build/config/compiler/BUILD.gn @@ -161,9 +161,27 @@ config("disabled_warnings") { } } +config("warnings_common") { + cflags = [ "-Wall" ] + + ldflags = [] + if (treat_warnings_as_errors) { + cflags += [ "-Werror" ] + ldflags += [ "-Werror" ] + } + + if (current_os != "mac" && current_os != "ios") { + ldflags += [ "-Wl,--fatal-warnings" ] + } + + if (current_os != "mac" && current_os != "ios" && current_os != "linux" && + current_os != "win") { + cflags += [ "-Wstack-usage=8192" ] + } +} + config("strict_warnings") { cflags = [ - "-Wall", "-Wextra", "-Wshadow", "-Wunreachable-code", @@ -173,11 +191,6 @@ config("strict_warnings") { ldflags = [] - if (treat_warnings_as_errors) { - cflags += [ "-Werror" ] - ldflags += [ "-Werror" ] - } - if (is_clang) { cflags += [ "-Wimplicit-fallthrough", @@ -193,18 +206,27 @@ config("strict_warnings") { config("warnings_default") { configs = [ + ":warnings_common", ":strict_warnings", ":disabled_warnings", ] +} - if (current_os != "mac" && current_os != "ios") { - ldflags = [ "-Wl,--fatal-warnings" ] - } +config("disabled_warnings_third_party") { + cflags = [ + "-Wno-unused", + "-Wno-format", + "-Wno-maybe-uninitialized", + "-Wno-address", + ] +} - if (current_os != "mac" && current_os != "ios" && current_os != "linux" && - current_os != "win") { - cflags = [ "-Wstack-usage=8192" ] - } +config("warnings_third_party") { + configs = [ + ":warnings_common", + ":disabled_warnings", + ":disabled_warnings_third_party", + ] } config("symbols_default") { diff --git a/build_overrides/lwip.gni b/build_overrides/lwip.gni index a0a68d95a11dee..6e6452dbee029a 100644 --- a/build_overrides/lwip.gni +++ b/build_overrides/lwip.gni @@ -12,7 +12,12 @@ # See the License for the specific language governing permissions and # limitations under the License. +import("//build_overrides/build.gni") + declare_args() { # Root directory for lwIP. lwip_root = "//third_party/lwip" } + +lwip_remove_configs = [ "${build_root}/config/compiler:warnings_default" ] +lwip_add_configs = [ "${build_root}/config/compiler:warnings_third_party" ] diff --git a/examples/build_overrides/lwip.gni b/examples/build_overrides/lwip.gni index 9a50a46bae6a8b..9faa77ce8472c0 100644 --- a/examples/build_overrides/lwip.gni +++ b/examples/build_overrides/lwip.gni @@ -12,7 +12,12 @@ # See the License for the specific language governing permissions and # limitations under the License. +import("//build_overrides/build.gni") + declare_args() { # Root directory for lwIP. lwip_root = "//third_party/connectedhomeip/third_party/lwip" } + +lwip_remove_configs = [ "${build_root}/config/compiler:warnings_default" ] +lwip_add_configs = [ "${build_root}/config/compiler:warnings_third_party" ] diff --git a/third_party/lwip/lwip.gni b/third_party/lwip/lwip.gni index 0c821cf8f2eb11..68d776be47472f 100644 --- a/third_party/lwip/lwip.gni +++ b/third_party/lwip/lwip.gni @@ -53,17 +53,6 @@ template("lwip_target") { lwip_6lowpan = false } - config("${lwip_target_name}_warnings") { - cflags = [ - "-Wno-address", - "-Wno-format", - "-Wno-type-limits", - "-Wno-unused-variable", - "-Wno-maybe-uninitialized", - "-Wno-format-type-confusion", - ] - } - config("${lwip_target_name}_base_config") { include_dirs = [ "${lwip_root}/repo/lwip/src/include" ] } @@ -212,8 +201,12 @@ template("lwip_target") { sources += [ "${_lwip_root}/src/netif/lowpan6.c" ] } - # Relax warnings for third_party code. - configs += [ ":${lwip_target_name}_warnings" ] + if (defined(lwip_remove_configs)) { + configs -= lwip_remove_configs + } + if (defined(lwip_add_configs)) { + configs += lwip_add_configs + } public_configs += [ ":${lwip_target_name}_base_config" ] }