From 2929313da3ee2ac709d5baccb482780ded44eb07 Mon Sep 17 00:00:00 2001 From: Michael Spang Date: Mon, 21 Jun 2021 17:25:47 -0400 Subject: [PATCH] Move src/app configuration to generated header (#7789) We generate headers containing build time configuration choices for good reason: some builds use multiple build systems and writing out a header is how we ensure consistent choices are made between them (thus avoiding ODR violations that can cause catastrophic breakage). Move the command line #defines for src/app to a new generated header. This makes it safe to enable schema checking in hybrid builds if this is desired. --- src/app/BUILD.gn | 19 +++++++++---------- src/app/Command.cpp | 2 ++ src/app/MessageDef/AttributeDataElement.cpp | 2 ++ src/app/MessageDef/AttributeDataElement.h | 2 ++ src/app/MessageDef/AttributeDataList.cpp | 2 ++ src/app/MessageDef/AttributeDataList.h | 2 ++ .../MessageDef/AttributeDataVersionList.cpp | 2 ++ src/app/MessageDef/AttributeDataVersionList.h | 1 + src/app/MessageDef/AttributePath.cpp | 2 ++ src/app/MessageDef/AttributePath.h | 2 ++ src/app/MessageDef/AttributePathList.cpp | 2 ++ src/app/MessageDef/AttributePathList.h | 1 + src/app/MessageDef/AttributeStatusElement.cpp | 2 ++ src/app/MessageDef/AttributeStatusElement.h | 2 ++ src/app/MessageDef/AttributeStatusList.cpp | 2 ++ src/app/MessageDef/AttributeStatusList.h | 1 + src/app/MessageDef/CommandDataElement.cpp | 2 ++ src/app/MessageDef/CommandDataElement.h | 2 ++ src/app/MessageDef/CommandList.cpp | 2 ++ src/app/MessageDef/CommandList.h | 1 + src/app/MessageDef/CommandPath.cpp | 2 ++ src/app/MessageDef/CommandPath.h | 2 ++ src/app/MessageDef/EventDataElement.cpp | 2 ++ src/app/MessageDef/EventDataElement.h | 2 ++ src/app/MessageDef/EventList.cpp | 2 ++ src/app/MessageDef/EventList.h | 1 + src/app/MessageDef/EventPath.cpp | 2 ++ src/app/MessageDef/EventPath.h | 2 ++ src/app/MessageDef/EventPathList.cpp | 2 ++ src/app/MessageDef/EventPathList.h | 1 + src/app/MessageDef/InvokeCommand.cpp | 2 ++ src/app/MessageDef/InvokeCommand.h | 1 + src/app/MessageDef/MessageDefHelper.cpp | 2 ++ src/app/MessageDef/MessageDefHelper.h | 2 ++ src/app/MessageDef/ReadRequest.cpp | 2 ++ src/app/MessageDef/ReadRequest.h | 2 ++ src/app/MessageDef/ReportData.cpp | 2 ++ src/app/MessageDef/ReportData.h | 1 + src/app/MessageDef/StatusElement.cpp | 2 ++ src/app/MessageDef/StatusElement.h | 1 + src/app/MessageDef/WriteRequest.cpp | 2 ++ src/app/MessageDef/WriteResponse.cpp | 2 ++ src/app/ReadClient.cpp | 1 + src/app/ReadHandler.cpp | 1 + src/app/WriteClient.cpp | 1 + src/app/WriteHandler.cpp | 1 + src/app/reporting/Engine.cpp | 1 + src/app/tests/TestCommandInteraction.cpp | 1 + src/app/tests/TestMessageDef.cpp | 1 + 49 files changed, 89 insertions(+), 10 deletions(-) diff --git a/src/app/BUILD.gn b/src/app/BUILD.gn index fc914aaf386882..9fd877d4cc7c33 100644 --- a/src/app/BUILD.gn +++ b/src/app/BUILD.gn @@ -14,6 +14,8 @@ import("//build_overrides/chip.gni") import("//build_overrides/nlio.gni") + +import("${chip_root}/build/chip/buildconfig_header.gni") import("common_flags.gni") declare_args() { @@ -22,12 +24,11 @@ declare_args() { is_debug && (current_os == "linux" || current_os == "mac") } -config("app_config") { - if (chip_enable_schema_check) { - defines = [ "CHIP_CONFIG_IM_ENABLE_SCHEMA_CHECK=1" ] - } else { - defines = [ "CHIP_CONFIG_IM_ENABLE_SCHEMA_CHECK=0" ] - } +buildconfig_header("app_buildconfig") { + header = "AppBuildConfig.h" + header_dir = "app" + + defines = [ "CHIP_CONFIG_IM_ENABLE_SCHEMA_CHECK=${chip_enable_schema_check}" ] } static_library("app") { @@ -108,6 +109,7 @@ static_library("app") { } public_deps = [ + ":app_buildconfig", "${chip_root}/src/lib/support", "${chip_root}/src/messaging", "${chip_root}/src/system", @@ -116,8 +118,5 @@ static_library("app") { cflags = [ "-Wconversion" ] - public_configs = [ - ":app_config", - "${chip_root}/src:includes", - ] + public_configs = [ "${chip_root}/src:includes" ] } diff --git a/src/app/Command.cpp b/src/app/Command.cpp index 62fb6c85952533..6edab55606c8a8 100644 --- a/src/app/Command.cpp +++ b/src/app/Command.cpp @@ -26,6 +26,8 @@ #include "CommandHandler.h" #include "CommandSender.h" #include "InteractionModelEngine.h" + +#include #include namespace chip { diff --git a/src/app/MessageDef/AttributeDataElement.cpp b/src/app/MessageDef/AttributeDataElement.cpp index a8b679475ff9c8..8f8861e5833e3a 100644 --- a/src/app/MessageDef/AttributeDataElement.cpp +++ b/src/app/MessageDef/AttributeDataElement.cpp @@ -29,6 +29,8 @@ #include #include +#include + using namespace chip; using namespace chip::TLV; diff --git a/src/app/MessageDef/AttributeDataElement.h b/src/app/MessageDef/AttributeDataElement.h index 08dbe8792af95b..3430ab4a8d6895 100644 --- a/src/app/MessageDef/AttributeDataElement.h +++ b/src/app/MessageDef/AttributeDataElement.h @@ -26,6 +26,8 @@ #include "AttributePath.h" #include "Builder.h" #include "Parser.h" + +#include #include #include #include diff --git a/src/app/MessageDef/AttributeDataList.cpp b/src/app/MessageDef/AttributeDataList.cpp index e74a9ad15265e0..d350c941dfdd61 100644 --- a/src/app/MessageDef/AttributeDataList.cpp +++ b/src/app/MessageDef/AttributeDataList.cpp @@ -29,6 +29,8 @@ #include #include +#include + using namespace chip; using namespace chip::TLV; diff --git a/src/app/MessageDef/AttributeDataList.h b/src/app/MessageDef/AttributeDataList.h index c917503e5ef5c6..5ae010b16401ae 100644 --- a/src/app/MessageDef/AttributeDataList.h +++ b/src/app/MessageDef/AttributeDataList.h @@ -26,6 +26,8 @@ #include "AttributeDataElement.h" #include "ListBuilder.h" #include "ListParser.h" + +#include #include #include #include diff --git a/src/app/MessageDef/AttributeDataVersionList.cpp b/src/app/MessageDef/AttributeDataVersionList.cpp index 712a0533f3e74f..abbaca04e6eab0 100644 --- a/src/app/MessageDef/AttributeDataVersionList.cpp +++ b/src/app/MessageDef/AttributeDataVersionList.cpp @@ -29,6 +29,8 @@ #include #include +#include + using namespace chip; using namespace chip::TLV; diff --git a/src/app/MessageDef/AttributeDataVersionList.h b/src/app/MessageDef/AttributeDataVersionList.h index f927ab30fd8b1b..e67d4754eaa63b 100644 --- a/src/app/MessageDef/AttributeDataVersionList.h +++ b/src/app/MessageDef/AttributeDataVersionList.h @@ -27,6 +27,7 @@ #include "ListBuilder.h" #include "ListParser.h" +#include #include #include #include diff --git a/src/app/MessageDef/AttributePath.cpp b/src/app/MessageDef/AttributePath.cpp index 77e35dd8364014..1af8ad8f686cf7 100644 --- a/src/app/MessageDef/AttributePath.cpp +++ b/src/app/MessageDef/AttributePath.cpp @@ -28,6 +28,8 @@ #include #include +#include + using namespace chip; using namespace chip::TLV; diff --git a/src/app/MessageDef/AttributePath.h b/src/app/MessageDef/AttributePath.h index 8ed3c086e22ebf..b1512875bf0f39 100644 --- a/src/app/MessageDef/AttributePath.h +++ b/src/app/MessageDef/AttributePath.h @@ -25,6 +25,8 @@ #include "Builder.h" #include "Parser.h" + +#include #include #include #include diff --git a/src/app/MessageDef/AttributePathList.cpp b/src/app/MessageDef/AttributePathList.cpp index 43640146d1a636..0781486268ed14 100644 --- a/src/app/MessageDef/AttributePathList.cpp +++ b/src/app/MessageDef/AttributePathList.cpp @@ -29,6 +29,8 @@ #include #include +#include + using namespace chip; using namespace chip::TLV; diff --git a/src/app/MessageDef/AttributePathList.h b/src/app/MessageDef/AttributePathList.h index 63c8d3f9bde4ec..4cdd376e127a97 100644 --- a/src/app/MessageDef/AttributePathList.h +++ b/src/app/MessageDef/AttributePathList.h @@ -27,6 +27,7 @@ #include "ListBuilder.h" #include "ListParser.h" +#include #include #include #include diff --git a/src/app/MessageDef/AttributeStatusElement.cpp b/src/app/MessageDef/AttributeStatusElement.cpp index 9131ca02224d4d..0a3d6ef805d5e3 100644 --- a/src/app/MessageDef/AttributeStatusElement.cpp +++ b/src/app/MessageDef/AttributeStatusElement.cpp @@ -29,6 +29,8 @@ #include #include +#include + using namespace chip; using namespace chip::TLV; diff --git a/src/app/MessageDef/AttributeStatusElement.h b/src/app/MessageDef/AttributeStatusElement.h index 1d5e1cfa74d7ab..b0bedfdcb02be5 100644 --- a/src/app/MessageDef/AttributeStatusElement.h +++ b/src/app/MessageDef/AttributeStatusElement.h @@ -27,6 +27,8 @@ #include "Builder.h" #include "Parser.h" #include "StatusElement.h" + +#include #include #include #include diff --git a/src/app/MessageDef/AttributeStatusList.cpp b/src/app/MessageDef/AttributeStatusList.cpp index 9d4076e7272c32..14b66788c496c4 100644 --- a/src/app/MessageDef/AttributeStatusList.cpp +++ b/src/app/MessageDef/AttributeStatusList.cpp @@ -30,6 +30,8 @@ #include #include +#include + using namespace chip; using namespace chip::TLV; diff --git a/src/app/MessageDef/AttributeStatusList.h b/src/app/MessageDef/AttributeStatusList.h index 0316557f38adf8..8c7073db9e79c9 100644 --- a/src/app/MessageDef/AttributeStatusList.h +++ b/src/app/MessageDef/AttributeStatusList.h @@ -27,6 +27,7 @@ #include "ListBuilder.h" #include "ListParser.h" +#include #include #include #include diff --git a/src/app/MessageDef/CommandDataElement.cpp b/src/app/MessageDef/CommandDataElement.cpp index bd39f5ef0b2dd2..d3f1f8b44c74a2 100644 --- a/src/app/MessageDef/CommandDataElement.cpp +++ b/src/app/MessageDef/CommandDataElement.cpp @@ -29,6 +29,8 @@ #include #include +#include + using namespace chip; using namespace chip::TLV; diff --git a/src/app/MessageDef/CommandDataElement.h b/src/app/MessageDef/CommandDataElement.h index 831fa82d375740..327004501e4b7f 100644 --- a/src/app/MessageDef/CommandDataElement.h +++ b/src/app/MessageDef/CommandDataElement.h @@ -28,6 +28,8 @@ #include "Parser.h" #include "StatusElement.h" + +#include #include #include #include diff --git a/src/app/MessageDef/CommandList.cpp b/src/app/MessageDef/CommandList.cpp index 3b80820cd36966..74cb03be4d6cd3 100644 --- a/src/app/MessageDef/CommandList.cpp +++ b/src/app/MessageDef/CommandList.cpp @@ -29,6 +29,8 @@ #include #include +#include + using namespace chip; using namespace chip::TLV; diff --git a/src/app/MessageDef/CommandList.h b/src/app/MessageDef/CommandList.h index f678c9217eebb2..9bacc92f84205b 100644 --- a/src/app/MessageDef/CommandList.h +++ b/src/app/MessageDef/CommandList.h @@ -27,6 +27,7 @@ #include "ListBuilder.h" #include "ListParser.h" +#include #include #include #include diff --git a/src/app/MessageDef/CommandPath.cpp b/src/app/MessageDef/CommandPath.cpp index 10a915ceae6c5b..eadd7d93e11d5d 100644 --- a/src/app/MessageDef/CommandPath.cpp +++ b/src/app/MessageDef/CommandPath.cpp @@ -29,6 +29,8 @@ #include #include +#include + using namespace chip; using namespace chip::TLV; diff --git a/src/app/MessageDef/CommandPath.h b/src/app/MessageDef/CommandPath.h index cb2c34f8e6b9f9..21936c9978397d 100644 --- a/src/app/MessageDef/CommandPath.h +++ b/src/app/MessageDef/CommandPath.h @@ -25,6 +25,8 @@ #include "Builder.h" #include "Parser.h" + +#include #include #include #include diff --git a/src/app/MessageDef/EventDataElement.cpp b/src/app/MessageDef/EventDataElement.cpp index bc5b661a28e834..e3c45b62dab719 100644 --- a/src/app/MessageDef/EventDataElement.cpp +++ b/src/app/MessageDef/EventDataElement.cpp @@ -29,6 +29,8 @@ #include #include +#include + using namespace chip; using namespace chip::TLV; diff --git a/src/app/MessageDef/EventDataElement.h b/src/app/MessageDef/EventDataElement.h index 57988cb9f8ee77..0edaa4779fb802 100644 --- a/src/app/MessageDef/EventDataElement.h +++ b/src/app/MessageDef/EventDataElement.h @@ -27,6 +27,8 @@ #include "EventPath.h" #include "Parser.h" + +#include #include #include #include diff --git a/src/app/MessageDef/EventList.cpp b/src/app/MessageDef/EventList.cpp index 1ecf010feea99f..ec068cc507234a 100644 --- a/src/app/MessageDef/EventList.cpp +++ b/src/app/MessageDef/EventList.cpp @@ -29,6 +29,8 @@ #include #include +#include + using namespace chip; using namespace chip::TLV; diff --git a/src/app/MessageDef/EventList.h b/src/app/MessageDef/EventList.h index b39d6164561df1..ad35ee7110d007 100644 --- a/src/app/MessageDef/EventList.h +++ b/src/app/MessageDef/EventList.h @@ -27,6 +27,7 @@ #include "ListBuilder.h" #include "ListParser.h" +#include #include #include #include diff --git a/src/app/MessageDef/EventPath.cpp b/src/app/MessageDef/EventPath.cpp index 85bd28906f25ea..db98b32053de68 100644 --- a/src/app/MessageDef/EventPath.cpp +++ b/src/app/MessageDef/EventPath.cpp @@ -29,6 +29,8 @@ #include #include +#include + using namespace chip; using namespace chip::TLV; diff --git a/src/app/MessageDef/EventPath.h b/src/app/MessageDef/EventPath.h index dcb038ac130fae..2771e99f54e1d6 100644 --- a/src/app/MessageDef/EventPath.h +++ b/src/app/MessageDef/EventPath.h @@ -25,6 +25,8 @@ #include "Builder.h" #include "Parser.h" + +#include #include #include #include diff --git a/src/app/MessageDef/EventPathList.cpp b/src/app/MessageDef/EventPathList.cpp index fa3fd7bec226b2..3276da2623bd1d 100644 --- a/src/app/MessageDef/EventPathList.cpp +++ b/src/app/MessageDef/EventPathList.cpp @@ -29,6 +29,8 @@ #include #include +#include + using namespace chip; using namespace chip::TLV; diff --git a/src/app/MessageDef/EventPathList.h b/src/app/MessageDef/EventPathList.h index 7b14c586203ef9..91dda22f6c0512 100644 --- a/src/app/MessageDef/EventPathList.h +++ b/src/app/MessageDef/EventPathList.h @@ -28,6 +28,7 @@ #include "ListBuilder.h" #include "ListParser.h" +#include #include #include #include diff --git a/src/app/MessageDef/InvokeCommand.cpp b/src/app/MessageDef/InvokeCommand.cpp index 1e999068ddbf41..b7dc13f9cddad5 100644 --- a/src/app/MessageDef/InvokeCommand.cpp +++ b/src/app/MessageDef/InvokeCommand.cpp @@ -28,6 +28,8 @@ #include "InvokeCommand.h" #include "MessageDefHelper.h" +#include + using namespace chip; using namespace chip::TLV; diff --git a/src/app/MessageDef/InvokeCommand.h b/src/app/MessageDef/InvokeCommand.h index a2cb5b0ecdf60e..3b9c8eceb6ca35 100644 --- a/src/app/MessageDef/InvokeCommand.h +++ b/src/app/MessageDef/InvokeCommand.h @@ -23,6 +23,7 @@ #pragma once +#include #include #include #include diff --git a/src/app/MessageDef/MessageDefHelper.cpp b/src/app/MessageDef/MessageDefHelper.cpp index 375877800ae80f..78e48744cc6daa 100644 --- a/src/app/MessageDef/MessageDefHelper.cpp +++ b/src/app/MessageDef/MessageDefHelper.cpp @@ -26,6 +26,8 @@ #include #include #include + +#include #include namespace chip { diff --git a/src/app/MessageDef/MessageDefHelper.h b/src/app/MessageDef/MessageDefHelper.h index 7703919abded3e..625492621132e6 100644 --- a/src/app/MessageDef/MessageDefHelper.h +++ b/src/app/MessageDef/MessageDefHelper.h @@ -28,6 +28,8 @@ #include #include +#include + namespace chip { namespace app { #if CHIP_CONFIG_IM_ENABLE_SCHEMA_CHECK && CHIP_DETAIL_LOGGING diff --git a/src/app/MessageDef/ReadRequest.cpp b/src/app/MessageDef/ReadRequest.cpp index 49888960a0d5fa..3e23f39dd52fcc 100644 --- a/src/app/MessageDef/ReadRequest.cpp +++ b/src/app/MessageDef/ReadRequest.cpp @@ -26,6 +26,8 @@ #include #include +#include + using namespace chip; using namespace chip::TLV; diff --git a/src/app/MessageDef/ReadRequest.h b/src/app/MessageDef/ReadRequest.h index 8dc7b4e37666d1..9679bf5ab4153d 100644 --- a/src/app/MessageDef/ReadRequest.h +++ b/src/app/MessageDef/ReadRequest.h @@ -29,6 +29,8 @@ #include "EventPathList.h" #include "Parser.h" + +#include #include #include #include diff --git a/src/app/MessageDef/ReportData.cpp b/src/app/MessageDef/ReportData.cpp index cb8a29d04ea324..5c8ff23d1a9d4a 100644 --- a/src/app/MessageDef/ReportData.cpp +++ b/src/app/MessageDef/ReportData.cpp @@ -29,6 +29,8 @@ #include #include +#include + using namespace chip; using namespace chip::TLV; diff --git a/src/app/MessageDef/ReportData.h b/src/app/MessageDef/ReportData.h index 30ba8f702e7cb0..87d51fc13322a7 100644 --- a/src/app/MessageDef/ReportData.h +++ b/src/app/MessageDef/ReportData.h @@ -23,6 +23,7 @@ #pragma once +#include #include #include #include diff --git a/src/app/MessageDef/StatusElement.cpp b/src/app/MessageDef/StatusElement.cpp index c4981653e8b0e0..cc2357a86b54e5 100644 --- a/src/app/MessageDef/StatusElement.cpp +++ b/src/app/MessageDef/StatusElement.cpp @@ -29,6 +29,8 @@ #include #include +#include + using namespace chip; using namespace chip::TLV; diff --git a/src/app/MessageDef/StatusElement.h b/src/app/MessageDef/StatusElement.h index f10b07072e60f4..38b6cb6d646ced 100644 --- a/src/app/MessageDef/StatusElement.h +++ b/src/app/MessageDef/StatusElement.h @@ -26,6 +26,7 @@ #include "ListBuilder.h" #include "ListParser.h" +#include #include #include #include diff --git a/src/app/MessageDef/WriteRequest.cpp b/src/app/MessageDef/WriteRequest.cpp index a0463c020fd793..aeeab4d5ee8eb9 100644 --- a/src/app/MessageDef/WriteRequest.cpp +++ b/src/app/MessageDef/WriteRequest.cpp @@ -26,6 +26,8 @@ #include #include +#include + using namespace chip; using namespace chip::TLV; diff --git a/src/app/MessageDef/WriteResponse.cpp b/src/app/MessageDef/WriteResponse.cpp index 941f51ffc113d5..172d9513a034ed 100644 --- a/src/app/MessageDef/WriteResponse.cpp +++ b/src/app/MessageDef/WriteResponse.cpp @@ -26,6 +26,8 @@ #include #include +#include + using namespace chip; using namespace chip::TLV; diff --git a/src/app/ReadClient.cpp b/src/app/ReadClient.cpp index 11a4771dce9989..ecc64641ddb212 100644 --- a/src/app/ReadClient.cpp +++ b/src/app/ReadClient.cpp @@ -22,6 +22,7 @@ * */ +#include #include #include diff --git a/src/app/ReadHandler.cpp b/src/app/ReadHandler.cpp index 5e41a8b9258cd2..3e8edb5d814be0 100644 --- a/src/app/ReadHandler.cpp +++ b/src/app/ReadHandler.cpp @@ -22,6 +22,7 @@ * */ +#include #include #include #include diff --git a/src/app/WriteClient.cpp b/src/app/WriteClient.cpp index 8b85f854644483..85572131a0a20e 100644 --- a/src/app/WriteClient.cpp +++ b/src/app/WriteClient.cpp @@ -22,6 +22,7 @@ * */ +#include #include #include diff --git a/src/app/WriteHandler.cpp b/src/app/WriteHandler.cpp index d3ae02b5645855..6aadad83676f7b 100644 --- a/src/app/WriteHandler.cpp +++ b/src/app/WriteHandler.cpp @@ -16,6 +16,7 @@ * limitations under the License. */ +#include #include #include #include diff --git a/src/app/reporting/Engine.cpp b/src/app/reporting/Engine.cpp index dbd3c4e857630d..4fb3a13658e43b 100644 --- a/src/app/reporting/Engine.cpp +++ b/src/app/reporting/Engine.cpp @@ -23,6 +23,7 @@ * */ +#include #include #include diff --git a/src/app/tests/TestCommandInteraction.cpp b/src/app/tests/TestCommandInteraction.cpp index a6441f8c4ecc2a..83b60e9eba7941 100644 --- a/src/app/tests/TestCommandInteraction.cpp +++ b/src/app/tests/TestCommandInteraction.cpp @@ -24,6 +24,7 @@ #include +#include #include #include #include diff --git a/src/app/tests/TestMessageDef.cpp b/src/app/tests/TestMessageDef.cpp index fb377204ab9fff..66456bd6e58fc8 100644 --- a/src/app/tests/TestMessageDef.cpp +++ b/src/app/tests/TestMessageDef.cpp @@ -22,6 +22,7 @@ * */ +#include #include #include #include