Skip to content

Commit

Permalink
Move src/app configuration to generated header (project-chip#7789)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mspang authored Jun 21, 2021
1 parent f9550e1 commit e00eac3
Show file tree
Hide file tree
Showing 49 changed files with 89 additions and 10 deletions.
19 changes: 9 additions & 10 deletions src/app/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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") {
Expand Down Expand Up @@ -108,6 +109,7 @@ static_library("app") {
}

public_deps = [
":app_buildconfig",
"${chip_root}/src/lib/support",
"${chip_root}/src/messaging",
"${chip_root}/src/system",
Expand All @@ -116,8 +118,5 @@ static_library("app") {

cflags = [ "-Wconversion" ]

public_configs = [
":app_config",
"${chip_root}/src:includes",
]
public_configs = [ "${chip_root}/src:includes" ]
}
2 changes: 2 additions & 0 deletions src/app/Command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#include "CommandHandler.h"
#include "CommandSender.h"
#include "InteractionModelEngine.h"

#include <app/AppBuildConfig.h>
#include <core/CHIPTLVDebug.hpp>

namespace chip {
Expand Down
2 changes: 2 additions & 0 deletions src/app/MessageDef/AttributeDataElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
#include <stdarg.h>
#include <stdio.h>

#include <app/AppBuildConfig.h>

using namespace chip;
using namespace chip::TLV;

Expand Down
2 changes: 2 additions & 0 deletions src/app/MessageDef/AttributeDataElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#include "AttributePath.h"
#include "Builder.h"
#include "Parser.h"

#include <app/AppBuildConfig.h>
#include <app/util/basic-types.h>
#include <core/CHIPCore.h>
#include <core/CHIPTLV.h>
Expand Down
2 changes: 2 additions & 0 deletions src/app/MessageDef/AttributeDataList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
#include <stdarg.h>
#include <stdio.h>

#include <app/AppBuildConfig.h>

using namespace chip;
using namespace chip::TLV;

Expand Down
2 changes: 2 additions & 0 deletions src/app/MessageDef/AttributeDataList.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#include "AttributeDataElement.h"
#include "ListBuilder.h"
#include "ListParser.h"

#include <app/AppBuildConfig.h>
#include <app/util/basic-types.h>
#include <core/CHIPCore.h>
#include <core/CHIPTLV.h>
Expand Down
2 changes: 2 additions & 0 deletions src/app/MessageDef/AttributeDataVersionList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
#include <stdarg.h>
#include <stdio.h>

#include <app/AppBuildConfig.h>

using namespace chip;
using namespace chip::TLV;

Expand Down
1 change: 1 addition & 0 deletions src/app/MessageDef/AttributeDataVersionList.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "ListBuilder.h"
#include "ListParser.h"

#include <app/AppBuildConfig.h>
#include <app/util/basic-types.h>
#include <core/CHIPCore.h>
#include <core/CHIPTLV.h>
Expand Down
2 changes: 2 additions & 0 deletions src/app/MessageDef/AttributePath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
#include <stdarg.h>
#include <stdio.h>

#include <app/AppBuildConfig.h>

using namespace chip;
using namespace chip::TLV;

Expand Down
2 changes: 2 additions & 0 deletions src/app/MessageDef/AttributePath.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

#include "Builder.h"
#include "Parser.h"

#include <app/AppBuildConfig.h>
#include <app/util/basic-types.h>
#include <core/CHIPCore.h>
#include <core/CHIPTLV.h>
Expand Down
2 changes: 2 additions & 0 deletions src/app/MessageDef/AttributePathList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
#include <stdarg.h>
#include <stdio.h>

#include <app/AppBuildConfig.h>

using namespace chip;
using namespace chip::TLV;

Expand Down
1 change: 1 addition & 0 deletions src/app/MessageDef/AttributePathList.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "ListBuilder.h"
#include "ListParser.h"

#include <app/AppBuildConfig.h>
#include <app/util/basic-types.h>
#include <core/CHIPCore.h>
#include <core/CHIPTLV.h>
Expand Down
2 changes: 2 additions & 0 deletions src/app/MessageDef/AttributeStatusElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
#include <stdarg.h>
#include <stdio.h>

#include <app/AppBuildConfig.h>

using namespace chip;
using namespace chip::TLV;

Expand Down
2 changes: 2 additions & 0 deletions src/app/MessageDef/AttributeStatusElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
#include "Builder.h"
#include "Parser.h"
#include "StatusElement.h"

#include <app/AppBuildConfig.h>
#include <app/util/basic-types.h>
#include <core/CHIPCore.h>
#include <core/CHIPTLV.h>
Expand Down
2 changes: 2 additions & 0 deletions src/app/MessageDef/AttributeStatusList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
#include <stdarg.h>
#include <stdio.h>

#include <app/AppBuildConfig.h>

using namespace chip;
using namespace chip::TLV;

Expand Down
1 change: 1 addition & 0 deletions src/app/MessageDef/AttributeStatusList.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "ListBuilder.h"
#include "ListParser.h"

#include <app/AppBuildConfig.h>
#include <app/util/basic-types.h>
#include <core/CHIPCore.h>
#include <core/CHIPTLV.h>
Expand Down
2 changes: 2 additions & 0 deletions src/app/MessageDef/CommandDataElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
#include <stdarg.h>
#include <stdio.h>

#include <app/AppBuildConfig.h>

using namespace chip;
using namespace chip::TLV;

Expand Down
2 changes: 2 additions & 0 deletions src/app/MessageDef/CommandDataElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@

#include "Parser.h"
#include "StatusElement.h"

#include <app/AppBuildConfig.h>
#include <app/util/basic-types.h>
#include <core/CHIPCore.h>
#include <core/CHIPTLV.h>
Expand Down
2 changes: 2 additions & 0 deletions src/app/MessageDef/CommandList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
#include <stdarg.h>
#include <stdio.h>

#include <app/AppBuildConfig.h>

using namespace chip;
using namespace chip::TLV;

Expand Down
1 change: 1 addition & 0 deletions src/app/MessageDef/CommandList.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "ListBuilder.h"
#include "ListParser.h"

#include <app/AppBuildConfig.h>
#include <app/util/basic-types.h>
#include <core/CHIPCore.h>
#include <core/CHIPTLV.h>
Expand Down
2 changes: 2 additions & 0 deletions src/app/MessageDef/CommandPath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
#include <stdarg.h>
#include <stdio.h>

#include <app/AppBuildConfig.h>

using namespace chip;
using namespace chip::TLV;

Expand Down
2 changes: 2 additions & 0 deletions src/app/MessageDef/CommandPath.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

#include "Builder.h"
#include "Parser.h"

#include <app/AppBuildConfig.h>
#include <app/util/basic-types.h>
#include <core/CHIPCore.h>
#include <core/CHIPTLV.h>
Expand Down
2 changes: 2 additions & 0 deletions src/app/MessageDef/EventDataElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
#include <stdarg.h>
#include <stdio.h>

#include <app/AppBuildConfig.h>

using namespace chip;
using namespace chip::TLV;

Expand Down
2 changes: 2 additions & 0 deletions src/app/MessageDef/EventDataElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
#include "EventPath.h"

#include "Parser.h"

#include <app/AppBuildConfig.h>
#include <app/util/basic-types.h>
#include <core/CHIPCore.h>
#include <core/CHIPTLV.h>
Expand Down
2 changes: 2 additions & 0 deletions src/app/MessageDef/EventList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
#include <stdarg.h>
#include <stdio.h>

#include <app/AppBuildConfig.h>

using namespace chip;
using namespace chip::TLV;

Expand Down
1 change: 1 addition & 0 deletions src/app/MessageDef/EventList.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "ListBuilder.h"
#include "ListParser.h"

#include <app/AppBuildConfig.h>
#include <app/util/basic-types.h>
#include <core/CHIPCore.h>
#include <core/CHIPTLV.h>
Expand Down
2 changes: 2 additions & 0 deletions src/app/MessageDef/EventPath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
#include <stdarg.h>
#include <stdio.h>

#include <app/AppBuildConfig.h>

using namespace chip;
using namespace chip::TLV;

Expand Down
2 changes: 2 additions & 0 deletions src/app/MessageDef/EventPath.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

#include "Builder.h"
#include "Parser.h"

#include <app/AppBuildConfig.h>
#include <app/util/basic-types.h>
#include <core/CHIPCore.h>
#include <core/CHIPTLV.h>
Expand Down
2 changes: 2 additions & 0 deletions src/app/MessageDef/EventPathList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
#include <stdarg.h>
#include <stdio.h>

#include <app/AppBuildConfig.h>

using namespace chip;
using namespace chip::TLV;

Expand Down
1 change: 1 addition & 0 deletions src/app/MessageDef/EventPathList.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "ListBuilder.h"
#include "ListParser.h"

#include <app/AppBuildConfig.h>
#include <app/util/basic-types.h>
#include <core/CHIPCore.h>
#include <core/CHIPTLV.h>
Expand Down
2 changes: 2 additions & 0 deletions src/app/MessageDef/InvokeCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
#include "InvokeCommand.h"
#include "MessageDefHelper.h"

#include <app/AppBuildConfig.h>

using namespace chip;
using namespace chip::TLV;

Expand Down
1 change: 1 addition & 0 deletions src/app/MessageDef/InvokeCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

#pragma once

#include <app/AppBuildConfig.h>
#include <app/util/basic-types.h>
#include <core/CHIPCore.h>
#include <core/CHIPTLV.h>
Expand Down
2 changes: 2 additions & 0 deletions src/app/MessageDef/MessageDefHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#include <inttypes.h>
#include <stdarg.h>
#include <stdio.h>

#include <app/AppBuildConfig.h>
#include <support/logging/CHIPLogging.h>

namespace chip {
Expand Down
2 changes: 2 additions & 0 deletions src/app/MessageDef/MessageDefHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
#include <stdarg.h>
#include <stdio.h>

#include <app/AppBuildConfig.h>

namespace chip {
namespace app {
#if CHIP_CONFIG_IM_ENABLE_SCHEMA_CHECK && CHIP_DETAIL_LOGGING
Expand Down
2 changes: 2 additions & 0 deletions src/app/MessageDef/ReadRequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#include <stdarg.h>
#include <stdio.h>

#include <app/AppBuildConfig.h>

using namespace chip;
using namespace chip::TLV;

Expand Down
2 changes: 2 additions & 0 deletions src/app/MessageDef/ReadRequest.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
#include "EventPathList.h"

#include "Parser.h"

#include <app/AppBuildConfig.h>
#include <app/util/basic-types.h>
#include <core/CHIPCore.h>
#include <core/CHIPTLV.h>
Expand Down
2 changes: 2 additions & 0 deletions src/app/MessageDef/ReportData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
#include <stdarg.h>
#include <stdio.h>

#include <app/AppBuildConfig.h>

using namespace chip;
using namespace chip::TLV;

Expand Down
1 change: 1 addition & 0 deletions src/app/MessageDef/ReportData.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

#pragma once

#include <app/AppBuildConfig.h>
#include <app/util/basic-types.h>
#include <core/CHIPCore.h>
#include <core/CHIPTLV.h>
Expand Down
2 changes: 2 additions & 0 deletions src/app/MessageDef/StatusElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
#include <stdarg.h>
#include <stdio.h>

#include <app/AppBuildConfig.h>

using namespace chip;
using namespace chip::TLV;

Expand Down
1 change: 1 addition & 0 deletions src/app/MessageDef/StatusElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "ListBuilder.h"
#include "ListParser.h"

#include <app/AppBuildConfig.h>
#include <app/util/basic-types.h>
#include <core/CHIPCore.h>
#include <core/CHIPTLV.h>
Expand Down
2 changes: 2 additions & 0 deletions src/app/MessageDef/WriteRequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#include <stdarg.h>
#include <stdio.h>

#include <app/AppBuildConfig.h>

using namespace chip;
using namespace chip::TLV;

Expand Down
Loading

0 comments on commit e00eac3

Please sign in to comment.