Move `declare_args` sections from `data_model` into AppConfig.h (#32270)
* Move defines into buildconfig_headers rather than data_model templates
* Restyle
* Update src/app/BUILD.gn
Co-authored-by: Boris Zbarsky <bzbarsky@apple.com>
* Add minssing include
---------
Co-authored-by: Andrei Litvin <andreilitvin@google.com>
Co-authored-by: Boris Zbarsky <bzbarsky@apple.com>
diff --git a/src/app/BUILD.gn b/src/app/BUILD.gn
index 69f5926..e6754bd 100644
--- a/src/app/BUILD.gn
+++ b/src/app/BUILD.gn
@@ -43,6 +43,15 @@
enable_eventlist_attribute = false
+ # Allow building ota-requestor-app with a non-spec-compliant floor
+ # (i.e. smaller than 2 minutes) for action delays.
+ non_spec_compliant_ota_action_delay_floor = -1
+
+ # enable time sync client for use in `time-synchronization-server` (if linked)
+ # TODO: this should probably be migrated to be time-synchronization-server specific
+ # if the cluster build targets are decoupled as stand-alone units.
+ time_sync_enable_tsc_feature = 1
+
# Systems that can spare a bit of RAM for InteractionModelEngine/delegate
# pointers should do so (allows InteractionModelEngine decoupling and less usage
# of global pointers)
@@ -65,6 +74,8 @@
"CHIP_CONFIG_ENABLE_EVENTLIST_ATTRIBUTE=${enable_eventlist_attribute}",
"CHIP_CONFIG_ENABLE_READ_CLIENT=${chip_enable_read_client}",
"CHIP_CONFIG_STATIC_GLOBAL_INTERACTION_MODEL_ENGINE=${chip_im_static_global_interaction_model_engine}",
+ "TIME_SYNC_ENABLE_TSC_FEATURE=${time_sync_enable_tsc_feature}",
+ "NON_SPEC_COMPLIANT_OTA_ACTION_DELAY_FLOOR=${non_spec_compliant_ota_action_delay_floor}",
]
visibility = [ ":app_config" ]
diff --git a/src/app/chip_data_model.gni b/src/app/chip_data_model.gni
index 3763243..42bc2f9 100644
--- a/src/app/chip_data_model.gni
+++ b/src/app/chip_data_model.gni
@@ -35,13 +35,6 @@
template("chip_data_model") {
_data_model_name = target_name
- declare_args() {
- # Allow building ota-requestor-app with a non-spec-compliant floor
- # (i.e. smaller than 2 minutes) for action delays.
- non_spec_compliant_ota_action_delay_floor = -1
- time_sync_enable_tsc_feature = 1
- }
-
if (defined(invoker.idl)) {
_idl = invoker.idl
} else {
@@ -244,8 +237,6 @@
"${_app_root}/clusters/${cluster}/DefaultTimeSyncDelegate.cpp",
"${_app_root}/clusters/${cluster}/TimeSyncDataProvider.cpp",
]
- defines +=
- [ "TIME_SYNC_ENABLE_TSC_FEATURE=${time_sync_enable_tsc_feature}" ]
} else if (cluster == "scenes-server") {
sources += [
"${_app_root}/clusters/${cluster}/${cluster}.cpp",
@@ -359,9 +350,5 @@
}
cflags += [ "-Wconversion" ]
-
- if (non_spec_compliant_ota_action_delay_floor >= 0) {
- cflags += [ "-DNON_SPEC_COMPLIANT_OTA_ACTION_DELAY_FLOOR=${non_spec_compliant_ota_action_delay_floor}" ]
- }
}
}
diff --git a/src/app/clusters/ota-requestor/DefaultOTARequestorDriver.cpp b/src/app/clusters/ota-requestor/DefaultOTARequestorDriver.cpp
index 60cc542..d3efeae 100644
--- a/src/app/clusters/ota-requestor/DefaultOTARequestorDriver.cpp
+++ b/src/app/clusters/ota-requestor/DefaultOTARequestorDriver.cpp
@@ -38,6 +38,8 @@
#include "DefaultOTARequestorDriver.h"
#include "OTARequestorInterface.h"
+#include <app/AppConfig.h>
+
namespace chip {
namespace DeviceLayer {
namespace {
@@ -49,7 +51,7 @@
constexpr uint32_t kDelayQueryUponCommissioningSec = 30; // Delay before sending the initial image query after commissioning
constexpr uint32_t kImmediateStartDelaySec = 1; // Delay before sending a query in response to UrgentUpdateAvailable
-#ifdef NON_SPEC_COMPLIANT_OTA_ACTION_DELAY_FLOOR
+#if NON_SPEC_COMPLIANT_OTA_ACTION_DELAY_FLOOR >= 0
constexpr System::Clock::Seconds32 kDefaultDelayedActionTime = System::Clock::Seconds32(NON_SPEC_COMPLIANT_OTA_ACTION_DELAY_FLOOR);
#else
constexpr System::Clock::Seconds32 kDefaultDelayedActionTime = System::Clock::Seconds32(120);
diff --git a/src/app/clusters/time-synchronization-server/time-synchronization-server.cpp b/src/app/clusters/time-synchronization-server/time-synchronization-server.cpp
index cc6c3f5..a843339 100644
--- a/src/app/clusters/time-synchronization-server/time-synchronization-server.cpp
+++ b/src/app/clusters/time-synchronization-server/time-synchronization-server.cpp
@@ -18,11 +18,8 @@
#include "DefaultTimeSyncDelegate.h"
#include "time-synchronization-delegate.h"
-#if TIME_SYNC_ENABLE_TSC_FEATURE
-#include <app/InteractionModelEngine.h>
-#endif
-
#include <app-common/zap-generated/attributes/Accessors.h>
+#include <app-common/zap-generated/cluster-enums.h>
#include <app-common/zap-generated/cluster-objects.h>
#include <app-common/zap-generated/ids/Attributes.h>
#include <app-common/zap-generated/ids/Clusters.h>
@@ -37,10 +34,12 @@
#include <platform/CHIPDeviceLayer.h>
#include <platform/RuntimeOptionsProvider.h>
-#include <app-common/zap-generated/cluster-enums.h>
-
#include <system/SystemClock.h>
+#if TIME_SYNC_ENABLE_TSC_FEATURE
+#include <app/InteractionModelEngine.h>
+#endif
+
using namespace chip;
using namespace chip::app;
using namespace chip::DeviceLayer;
diff --git a/src/app/clusters/time-synchronization-server/time-synchronization-server.h b/src/app/clusters/time-synchronization-server/time-synchronization-server.h
index c6012b1..ef40eaa 100644
--- a/src/app/clusters/time-synchronization-server/time-synchronization-server.h
+++ b/src/app/clusters/time-synchronization-server/time-synchronization-server.h
@@ -21,16 +21,10 @@
#pragma once
-#ifndef TIME_SYNC_ENABLE_TSC_FEATURE
-#define TIME_SYNC_ENABLE_TSC_FEATURE 1
-#endif
-
#include "TimeSyncDataProvider.h"
#include "time-synchronization-delegate.h"
-#if TIME_SYNC_ENABLE_TSC_FEATURE
-#include <app/ReadClient.h>
-#endif
+#include <app/AppConfig.h>
#include <app/server/Server.h>
#include <app/util/af-types.h>
#include <app/util/config.h>
@@ -40,6 +34,12 @@
#include <app-common/zap-generated/cluster-objects.h>
#include <lib/support/Span.h>
+// NOTE: this is part of AppConfig, so this has to be checked for AFTER the inclusion
+// of that header
+#if TIME_SYNC_ENABLE_TSC_FEATURE
+#include <app/ReadClient.h>
+#endif
+
namespace chip {
namespace app {
namespace Clusters {