From f5afaa93f5e787586bf9e3c018af6ca4b4fa2863 Mon Sep 17 00:00:00 2001 From: Michael Spang Date: Thu, 8 Apr 2021 17:49:27 -0400 Subject: [PATCH] Centralize data model specification of examples Currently different samples repeat the same sources for ZAP generated & common cluster files. Reduce duplication by centralizing these in a template that is parameterized by the clusters to enable. --- .../all-clusters-common/BUILD.gn | 87 ++++------ examples/bridge-app/bridge-common/BUILD.gn | 44 +---- examples/chip-tool-darwin/BUILD.gn | 40 +---- examples/chip-tool/BUILD.gn | 30 ++-- .../lighting-app/lighting-common/BUILD.gn | 43 +---- .../lighting-app/nrfconnect/CMakeLists.txt | 2 +- examples/lock-app/lock-common/BUILD.gn | 41 +---- examples/lock-app/nrfconnect/CMakeLists.txt | 2 +- examples/tv-app/linux/BUILD.gn | 2 - examples/tv-app/tv-common/BUILD.gn | 79 +++------ examples/window-app/common/BUILD.gn | 47 +----- src/app/chip_data_model.gni | 156 ++++++++++++++++++ .../clusters/level-control/level-control.cpp | 2 +- .../{on-off.cpp => on-off-server.cpp} | 2 +- .../{on-off.h => on-off-server.h} | 0 src/darwin/Framework/CHIP/BUILD.gn | 77 +++++++++ 16 files changed, 332 insertions(+), 322 deletions(-) create mode 100644 src/app/chip_data_model.gni rename src/app/clusters/on-off-server/{on-off.cpp => on-off-server.cpp} (99%) rename src/app/clusters/on-off-server/{on-off.h => on-off-server.h} (100%) create mode 100644 src/darwin/Framework/CHIP/BUILD.gn diff --git a/examples/all-clusters-app/all-clusters-common/BUILD.gn b/examples/all-clusters-app/all-clusters-common/BUILD.gn index b0fdf86d8cf87e..bcccf42a007521 100644 --- a/examples/all-clusters-app/all-clusters-common/BUILD.gn +++ b/examples/all-clusters-app/all-clusters-common/BUILD.gn @@ -14,66 +14,35 @@ import("//build_overrides/chip.gni") -config("includes") { - include_dirs = [ - ".", - "include", - ] -} +import("${chip_root}/src/app/chip_data_model.gni") -source_set("all-clusters-common") { - sources = [ - "${chip_root}/src/app/clusters/account-login-server/account-login-server.cpp", - "${chip_root}/src/app/clusters/application-launcher-server/application-launcher-server.cpp", - "${chip_root}/src/app/clusters/audio-output-server/audio-output-server.cpp", - "${chip_root}/src/app/clusters/barrier-control-server/barrier-control-server.cpp", - "${chip_root}/src/app/clusters/basic/basic.cpp", - "${chip_root}/src/app/clusters/bindings/bindings.cpp", - "${chip_root}/src/app/clusters/color-control-server/color-control-server.cpp", - "${chip_root}/src/app/clusters/content-launch-server/content-launch-server.cpp", - "${chip_root}/src/app/clusters/door-lock-server/door-lock-server-core.cpp", - "${chip_root}/src/app/clusters/door-lock-server/door-lock-server-logging.cpp", - "${chip_root}/src/app/clusters/door-lock-server/door-lock-server-schedule.cpp", - "${chip_root}/src/app/clusters/door-lock-server/door-lock-server-user.cpp", - "${chip_root}/src/app/clusters/general-commissioning-server/general-commissioning-server.cpp", - "${chip_root}/src/app/clusters/groups-server/groups-server.cpp", - "${chip_root}/src/app/clusters/ias-zone-server/ias-zone-server.cpp", - "${chip_root}/src/app/clusters/identify/identify.cpp", - "${chip_root}/src/app/clusters/keypad-input-server/keypad-input-server.cpp", - "${chip_root}/src/app/clusters/level-control/level-control.cpp", - "${chip_root}/src/app/clusters/low-power-server/low-power-server.cpp", - "${chip_root}/src/app/clusters/media-input-server/media-input-server.cpp", - "${chip_root}/src/app/clusters/media-playback-server/media-playback-server.cpp", - "${chip_root}/src/app/clusters/network-commissioning/network-commissioning-ember.cpp", - "${chip_root}/src/app/clusters/network-commissioning/network-commissioning.cpp", - "${chip_root}/src/app/clusters/on-off-server/on-off.cpp", - "${chip_root}/src/app/clusters/scenes/scenes.cpp", - "${chip_root}/src/app/clusters/target-navigator-server/target-navigator-server.cpp", - "${chip_root}/src/app/clusters/temperature-measurement-server/temperature-measurement-server.cpp", - "${chip_root}/src/app/clusters/tv-channel-server/tv-channel-server.cpp", - "${chip_root}/src/app/reporting/reporting-default-configuration.cpp", - "${chip_root}/src/app/reporting/reporting.cpp", - "${chip_root}/src/app/server/DataModelHandler.cpp", - "${chip_root}/src/app/util/af-event.cpp", - "${chip_root}/src/app/util/af-main-common.cpp", - "${chip_root}/src/app/util/attribute-size.cpp", - "${chip_root}/src/app/util/attribute-storage.cpp", - "${chip_root}/src/app/util/attribute-table.cpp", - "${chip_root}/src/app/util/binding-table.cpp", - "${chip_root}/src/app/util/chip-message-send.cpp", - "${chip_root}/src/app/util/client-api.cpp", - "${chip_root}/src/app/util/ember-print.cpp", - "${chip_root}/src/app/util/message.cpp", - "${chip_root}/src/app/util/process-cluster-message.cpp", - "${chip_root}/src/app/util/process-global-message.cpp", - "${chip_root}/src/app/util/util.cpp", - "gen/call-command-handler.cpp", - "gen/callback-stub.cpp", +chip_data_model("all-clusters-common") { + cluster_sources = [ + "account-login-server", + "application-launcher-server", + "audio-output-server", + "barrier-control-server", + "basic", + "bindings", + "color-control-server", + "content-launch-server", + "door-lock-server", + "general-commissioning-server", + "groups-server", + "ias-zone-server", + "identify", + "keypad-input-server", + "level-control", + "low-power-server", + "media-input-server", + "media-playback-server", + "network-commissioning", + "on-off-server", + "scenes", + "target-navigator-server", + "temperature-measurement-server", + "tv-channel-server", ] - cflags = [ "-Wconversion" ] - - deps = [ "${chip_root}/src/lib" ] - - public_configs = [ ":includes" ] + zap_pregenerated_dir = "gen" } diff --git a/examples/bridge-app/bridge-common/BUILD.gn b/examples/bridge-app/bridge-common/BUILD.gn index 90d5518ea01665..4c19d980516fe9 100644 --- a/examples/bridge-app/bridge-common/BUILD.gn +++ b/examples/bridge-app/bridge-common/BUILD.gn @@ -14,42 +14,16 @@ import("//build_overrides/chip.gni") -config("includes") { - include_dirs = [ - ".", - "include", - ] -} +import("${chip_root}/src/app/chip_data_model.gni") -source_set("bridge-common") { - sources = [ - "${chip_root}/src/app/clusters/basic/basic.cpp", - "${chip_root}/src/app/clusters/bindings/bindings.cpp", - "${chip_root}/src/app/clusters/level-control/level-control.cpp", - "${chip_root}/src/app/clusters/network-commissioning/network-commissioning-ember.cpp", - "${chip_root}/src/app/clusters/network-commissioning/network-commissioning.cpp", - "${chip_root}/src/app/clusters/on-off-server/on-off.cpp", - "${chip_root}/src/app/reporting/reporting-default-configuration.cpp", - "${chip_root}/src/app/reporting/reporting.cpp", - "${chip_root}/src/app/server/DataModelHandler.cpp", - "${chip_root}/src/app/util/af-event.cpp", - "${chip_root}/src/app/util/af-main-common.cpp", - "${chip_root}/src/app/util/attribute-size.cpp", - "${chip_root}/src/app/util/attribute-storage.cpp", - "${chip_root}/src/app/util/attribute-table.cpp", - "${chip_root}/src/app/util/binding-table.cpp", - "${chip_root}/src/app/util/chip-message-send.cpp", - "${chip_root}/src/app/util/client-api.cpp", - "${chip_root}/src/app/util/ember-print.cpp", - "${chip_root}/src/app/util/message.cpp", - "${chip_root}/src/app/util/process-cluster-message.cpp", - "${chip_root}/src/app/util/process-global-message.cpp", - "${chip_root}/src/app/util/util.cpp", - "gen/call-command-handler.cpp", - "gen/callback-stub.cpp", +chip_data_model("bridge-common") { + cluster_sources = [ + "basic", + "bindings", + "level-control", + "network-commissioning", + "on-off-server", ] - deps = [ "${chip_root}/src/lib" ] - - public_configs = [ ":includes" ] + zap_pregenerated_dir = "gen" } diff --git a/examples/chip-tool-darwin/BUILD.gn b/examples/chip-tool-darwin/BUILD.gn index 6bb03ed0d69c7a..e710aca9c6fe82 100644 --- a/examples/chip-tool-darwin/BUILD.gn +++ b/examples/chip-tool-darwin/BUILD.gn @@ -20,46 +20,11 @@ import("${chip_root}/build/chip/tools.gni") assert(chip_build_tools) config("includes") { - include_dirs = [ - ".", - "${chip_root}/src/darwin/Framework", - "${chip_root}/src/darwin/Framework/CHIP", - ] + include_dirs = [ "." ] } executable("chip-tool-darwin") { - sources = [ - "${chip_root}/src/app/clusters/media-playback-client/media-playback-client.cpp", - "${chip_root}/src/app/reporting/reporting-default-configuration.cpp", - "${chip_root}/src/app/reporting/reporting.cpp", - "${chip_root}/src/app/server/DataModelHandler.cpp", - "${chip_root}/src/app/util/af-event.cpp", - "${chip_root}/src/app/util/af-main-common.cpp", - "${chip_root}/src/app/util/attribute-size.cpp", - "${chip_root}/src/app/util/attribute-storage.cpp", - "${chip_root}/src/app/util/attribute-table.cpp", - "${chip_root}/src/app/util/binding-table.cpp", - "${chip_root}/src/app/util/chip-message-send.cpp", - "${chip_root}/src/app/util/client-api.cpp", - "${chip_root}/src/app/util/ember-print.cpp", - "${chip_root}/src/app/util/message.cpp", - "${chip_root}/src/app/util/process-cluster-message.cpp", - "${chip_root}/src/app/util/process-global-message.cpp", - "${chip_root}/src/app/util/util.cpp", - "${chip_root}/src/darwin/Framework/CHIP/CHIPDevice.mm", - "${chip_root}/src/darwin/Framework/CHIP/CHIPDeviceController.mm", - "${chip_root}/src/darwin/Framework/CHIP/CHIPDevicePairingDelegateBridge.mm", - "${chip_root}/src/darwin/Framework/CHIP/CHIPError.mm", - "${chip_root}/src/darwin/Framework/CHIP/CHIPManualSetupPayloadParser.mm", - "${chip_root}/src/darwin/Framework/CHIP/CHIPPersistentStorageDelegateBridge.mm", - "${chip_root}/src/darwin/Framework/CHIP/CHIPQRCodeSetupPayloadParser.mm", - "${chip_root}/src/darwin/Framework/CHIP/CHIPSetupPayload.mm", - "${chip_root}/src/darwin/Framework/CHIP/gen/CHIPClientCallbacks.cpp", - "${chip_root}/src/darwin/Framework/CHIP/gen/CHIPClustersObjc.mm", - "${chip_root}/src/darwin/Framework/CHIP/gen/call-command-handler.cpp", - "${chip_root}/src/darwin/Framework/CHIP/gen/callback-stub.cpp", - "main.m", - ] + sources = [ "main.m" ] cflags = [ "-Wconversion", @@ -68,6 +33,7 @@ executable("chip-tool-darwin") { public_deps = [ "${chip_root}/src/app/server", + "${chip_root}/src/darwin/Framework/CHIP", "${chip_root}/src/lib", "${chip_root}/src/platform", "${chip_root}/third_party/inipp", diff --git a/examples/chip-tool/BUILD.gn b/examples/chip-tool/BUILD.gn index c83a641953a3ac..c9b7d8f58a3e71 100644 --- a/examples/chip-tool/BUILD.gn +++ b/examples/chip-tool/BUILD.gn @@ -16,6 +16,7 @@ import("//build_overrides/build.gni") import("//build_overrides/chip.gni") import("${chip_root}/build/chip/tools.gni") +import("${chip_root}/src/app/chip_data_model.gni") assert(chip_build_tools) @@ -23,25 +24,16 @@ config("includes") { include_dirs = [ "." ] } +chip_data_model("data_model") { + cluster_sources = [ "media-playback-client" ] + + zap_pregenerated_dir = "gen" + + use_default_client_callbacks = true +} + executable("chip-tool") { sources = [ - "${chip_root}/src/app/clusters/media-playback-client/media-playback-client.cpp", - "${chip_root}/src/app/reporting/reporting-default-configuration.cpp", - "${chip_root}/src/app/reporting/reporting.cpp", - "${chip_root}/src/app/server/DataModelHandler.cpp", - "${chip_root}/src/app/util/af-event.cpp", - "${chip_root}/src/app/util/af-main-common.cpp", - "${chip_root}/src/app/util/attribute-size.cpp", - "${chip_root}/src/app/util/attribute-storage.cpp", - "${chip_root}/src/app/util/attribute-table.cpp", - "${chip_root}/src/app/util/binding-table.cpp", - "${chip_root}/src/app/util/chip-message-send.cpp", - "${chip_root}/src/app/util/client-api.cpp", - "${chip_root}/src/app/util/ember-print.cpp", - "${chip_root}/src/app/util/message.cpp", - "${chip_root}/src/app/util/process-cluster-message.cpp", - "${chip_root}/src/app/util/process-global-message.cpp", - "${chip_root}/src/app/util/util.cpp", "commands/clusters/ModelCommand.cpp", "commands/common/Command.cpp", "commands/common/Commands.cpp", @@ -50,15 +42,13 @@ executable("chip-tool") { "commands/payload/SetupPayloadParseCommand.cpp", "commands/reporting/ReportingCommand.cpp", "config/PersistentStorage.cpp", - "gen/CHIPClientCallbacks.cpp", - "gen/call-command-handler.cpp", - "gen/callback-stub.cpp", "main.cpp", ] cflags = [ "-Wconversion" ] public_deps = [ + ":data_model", "${chip_root}/src/app/server", "${chip_root}/src/lib", "${chip_root}/src/platform", diff --git a/examples/lighting-app/lighting-common/BUILD.gn b/examples/lighting-app/lighting-common/BUILD.gn index 7080d33c57eabd..004618e12a94ac 100644 --- a/examples/lighting-app/lighting-common/BUILD.gn +++ b/examples/lighting-app/lighting-common/BUILD.gn @@ -14,6 +14,7 @@ import("//build_overrides/chip.gni") import("${chip_root}/examples/lighting-app/lighting-common/lighting.gni") +import("${chip_root}/src/app/chip_data_model.gni") import("${chip_root}/src/app/common_flags.gni") import("${chip_root}/src/lib/core/core.gni") @@ -36,41 +37,13 @@ if (enable_pw_rpc) { } } -source_set("lighting-common") { - sources = [ - "${chip_root}/src/app/clusters/bindings/bindings.cpp", - "${chip_root}/src/app/clusters/level-control/level-control.cpp", - "${chip_root}/src/app/clusters/network-commissioning/network-commissioning-ember.cpp", - "${chip_root}/src/app/clusters/network-commissioning/network-commissioning.cpp", - "${chip_root}/src/app/clusters/on-off-server/on-off.cpp", - "${chip_root}/src/app/reporting/reporting-default-configuration.cpp", - "${chip_root}/src/app/reporting/reporting.cpp", - "${chip_root}/src/app/server/DataModelHandler.cpp", - "${chip_root}/src/app/util/af-event.cpp", - "${chip_root}/src/app/util/af-main-common.cpp", - "${chip_root}/src/app/util/attribute-size.cpp", - "${chip_root}/src/app/util/attribute-storage.cpp", - "${chip_root}/src/app/util/attribute-table.cpp", - "${chip_root}/src/app/util/binding-table.cpp", - "${chip_root}/src/app/util/chip-message-send.cpp", - "${chip_root}/src/app/util/client-api.cpp", - "${chip_root}/src/app/util/ember-print.cpp", - "${chip_root}/src/app/util/message.cpp", - "${chip_root}/src/app/util/process-cluster-message.cpp", - "${chip_root}/src/app/util/process-global-message.cpp", - "${chip_root}/src/app/util/util.cpp", - "gen/call-command-handler.cpp", - "gen/callback-stub.cpp", +chip_data_model("lighting-common") { + cluster_sources = [ + "bindings", + "level-control", + "network-commissioning", + "on-off-server", ] - if (chip_enable_interaction_model) { - sources += [ - "${chip_root}/src/app/util/ember-compatibility-functions.cpp", - "gen/IMClusterCommandHandler.cpp", - ] - } - - deps = [ "${chip_root}/src/lib" ] - - public_configs = [ ":includes" ] + zap_pregenerated_dir = "gen" } diff --git a/examples/lighting-app/nrfconnect/CMakeLists.txt b/examples/lighting-app/nrfconnect/CMakeLists.txt index 5ef1900a3e7809..cbd847dfb5e3dd 100644 --- a/examples/lighting-app/nrfconnect/CMakeLists.txt +++ b/examples/lighting-app/nrfconnect/CMakeLists.txt @@ -64,7 +64,7 @@ target_sources(app PRIVATE ${CHIP_ROOT}/src/app/util/process-global-message.cpp ${CHIP_ROOT}/src/app/util/util.cpp ${CHIP_ROOT}/src/app/clusters/bindings/bindings.cpp - ${CHIP_ROOT}/src/app/clusters/on-off-server/on-off.cpp + ${CHIP_ROOT}/src/app/clusters/on-off-server/on-off-server.cpp ${CHIP_ROOT}/src/app/clusters/level-control/level-control.cpp ${CHIP_ROOT}/src/app/clusters/network-commissioning/network-commissioning-ember.cpp ${CHIP_ROOT}/src/app/clusters/network-commissioning/network-commissioning.cpp diff --git a/examples/lock-app/lock-common/BUILD.gn b/examples/lock-app/lock-common/BUILD.gn index e58c95d399a506..61d7675bc5cadf 100644 --- a/examples/lock-app/lock-common/BUILD.gn +++ b/examples/lock-app/lock-common/BUILD.gn @@ -14,41 +14,14 @@ import("//build_overrides/chip.gni") -config("includes") { - include_dirs = [ - ".", - "include", - "${chip_root}/src", - ] -} +import("${chip_root}/src/app/chip_data_model.gni") -source_set("lock-common") { - sources = [ - "${chip_root}/src/app/clusters/bindings/bindings.cpp", - "${chip_root}/src/app/clusters/network-commissioning/network-commissioning-ember.cpp", - "${chip_root}/src/app/clusters/network-commissioning/network-commissioning.cpp", - "${chip_root}/src/app/clusters/on-off-server/on-off.cpp", - "${chip_root}/src/app/reporting/reporting-default-configuration.cpp", - "${chip_root}/src/app/reporting/reporting.cpp", - "${chip_root}/src/app/server/DataModelHandler.cpp", - "${chip_root}/src/app/util/af-event.cpp", - "${chip_root}/src/app/util/af-main-common.cpp", - "${chip_root}/src/app/util/attribute-size.cpp", - "${chip_root}/src/app/util/attribute-storage.cpp", - "${chip_root}/src/app/util/attribute-table.cpp", - "${chip_root}/src/app/util/binding-table.cpp", - "${chip_root}/src/app/util/chip-message-send.cpp", - "${chip_root}/src/app/util/client-api.cpp", - "${chip_root}/src/app/util/ember-print.cpp", - "${chip_root}/src/app/util/message.cpp", - "${chip_root}/src/app/util/process-cluster-message.cpp", - "${chip_root}/src/app/util/process-global-message.cpp", - "${chip_root}/src/app/util/util.cpp", - "gen/call-command-handler.cpp", - "gen/callback-stub.cpp", +chip_data_model("lock-common") { + cluster_sources = [ + "bindings", + "network-commissioning", + "on-off-server", ] - deps = [ "${chip_root}/src/lib" ] - - public_configs = [ ":includes" ] + zap_pregenerated_dir = "gen" } diff --git a/examples/lock-app/nrfconnect/CMakeLists.txt b/examples/lock-app/nrfconnect/CMakeLists.txt index 0f402264e42747..d7295e2ff23aa8 100644 --- a/examples/lock-app/nrfconnect/CMakeLists.txt +++ b/examples/lock-app/nrfconnect/CMakeLists.txt @@ -66,4 +66,4 @@ target_sources(app PRIVATE ${CHIP_ROOT}/src/app/clusters/bindings/bindings.cpp ${CHIP_ROOT}/src/app/clusters/network-commissioning/network-commissioning-ember.cpp ${CHIP_ROOT}/src/app/clusters/network-commissioning/network-commissioning.cpp - ${CHIP_ROOT}/src/app/clusters/on-off-server/on-off.cpp) + ${CHIP_ROOT}/src/app/clusters/on-off-server/on-off-server.cpp) diff --git a/examples/tv-app/linux/BUILD.gn b/examples/tv-app/linux/BUILD.gn index f479d3fee32663..20cae28df67569 100644 --- a/examples/tv-app/linux/BUILD.gn +++ b/examples/tv-app/linux/BUILD.gn @@ -23,8 +23,6 @@ config("includes") { include_dirs = [ ".", "include", - "${chip_root}/src/app/util", - "${chip_root}/src/app/server", ] } diff --git a/examples/tv-app/tv-common/BUILD.gn b/examples/tv-app/tv-common/BUILD.gn index d9931cad4f1bc6..38b85bab65d8a7 100644 --- a/examples/tv-app/tv-common/BUILD.gn +++ b/examples/tv-app/tv-common/BUILD.gn @@ -14,62 +14,31 @@ import("//build_overrides/chip.gni") -config("includes") { - include_dirs = [ - ".", - "include", - ] -} +import("${chip_root}/src/app/chip_data_model.gni") -source_set("tv-common") { - sources = [ - "${chip_root}/src/app/clusters/barrier-control-server/barrier-control-server.cpp", - "${chip_root}/src/app/clusters/basic/basic.cpp", - "${chip_root}/src/app/clusters/bindings/bindings.cpp", - "${chip_root}/src/app/clusters/color-control-server/color-control-server.cpp", - "${chip_root}/src/app/clusters/content-launch-server/content-launch-server.cpp", - "${chip_root}/src/app/clusters/door-lock-client/door-lock-client.cpp", - "${chip_root}/src/app/clusters/door-lock-server/door-lock-server-core.cpp", - "${chip_root}/src/app/clusters/door-lock-server/door-lock-server-logging.cpp", - "${chip_root}/src/app/clusters/door-lock-server/door-lock-server-schedule.cpp", - "${chip_root}/src/app/clusters/door-lock-server/door-lock-server-user.cpp", - "${chip_root}/src/app/clusters/groups-client/groups-client.cpp", - "${chip_root}/src/app/clusters/groups-server/groups-server.cpp", - "${chip_root}/src/app/clusters/ias-zone-server/ias-zone-server.cpp", - "${chip_root}/src/app/clusters/identify-client/identify-client.cpp", - "${chip_root}/src/app/clusters/identify/identify.cpp", - "${chip_root}/src/app/clusters/level-control/level-control.cpp", - "${chip_root}/src/app/clusters/low-power-server/low-power-server.cpp", - "${chip_root}/src/app/clusters/media-playback-server/media-playback-server.cpp", - "${chip_root}/src/app/clusters/network-commissioning/network-commissioning-ember.cpp", - "${chip_root}/src/app/clusters/network-commissioning/network-commissioning.cpp", - "${chip_root}/src/app/clusters/on-off-server/on-off.cpp", - "${chip_root}/src/app/clusters/scenes-client/scenes-client.cpp", - "${chip_root}/src/app/clusters/scenes/scenes.cpp", - "${chip_root}/src/app/clusters/temperature-measurement-server/temperature-measurement-server.cpp", - "${chip_root}/src/app/reporting/reporting-default-configuration.cpp", - "${chip_root}/src/app/reporting/reporting.cpp", - "${chip_root}/src/app/server/DataModelHandler.cpp", - "${chip_root}/src/app/util/af-event.cpp", - "${chip_root}/src/app/util/af-main-common.cpp", - "${chip_root}/src/app/util/attribute-size.cpp", - "${chip_root}/src/app/util/attribute-storage.cpp", - "${chip_root}/src/app/util/attribute-table.cpp", - "${chip_root}/src/app/util/binding-table.cpp", - "${chip_root}/src/app/util/chip-message-send.cpp", - "${chip_root}/src/app/util/client-api.cpp", - "${chip_root}/src/app/util/ember-print.cpp", - "${chip_root}/src/app/util/message.cpp", - "${chip_root}/src/app/util/process-cluster-message.cpp", - "${chip_root}/src/app/util/process-global-message.cpp", - "${chip_root}/src/app/util/util.cpp", - "gen/call-command-handler.cpp", - "gen/callback-stub.cpp", +chip_data_model("tv-common") { + cluster_sources = [ + "barrier-control-server", + "basic", + "bindings", + "color-control-server", + "content-launch-server", + "door-lock-client", + "door-lock-server", + "groups-client", + "groups-server", + "ias-zone-server", + "identify", + "identify-client", + "level-control", + "low-power-server", + "media-playback-server", + "network-commissioning", + "on-off-server", + "scenes", + "scenes-client", + "temperature-measurement-server", ] - cflags = [ "-Wconversion" ] - - deps = [ "${chip_root}/src/lib" ] - - public_configs = [ ":includes" ] + zap_pregenerated_dir = "gen" } diff --git a/examples/window-app/common/BUILD.gn b/examples/window-app/common/BUILD.gn index 366b86a9cb076e..cae03951f43359 100644 --- a/examples/window-app/common/BUILD.gn +++ b/examples/window-app/common/BUILD.gn @@ -13,49 +13,14 @@ # limitations under the License. import("//build_overrides/chip.gni") -import("${chip_root}/src/app/common_flags.gni") -import("${chip_root}/src/lib/core/core.gni") -config("includes") { - include_dirs = [ - ".", - "include", - ] -} +import("${chip_root}/src/app/chip_data_model.gni") -source_set("window-common") { - sources = [ - "${chip_root}/src/app/clusters/bindings/bindings.cpp", - "${chip_root}/src/app/clusters/network-commissioning/network-commissioning-ember.cpp", - "${chip_root}/src/app/clusters/network-commissioning/network-commissioning.cpp", - "${chip_root}/src/app/reporting/reporting-default-configuration.cpp", - "${chip_root}/src/app/reporting/reporting.cpp", - "${chip_root}/src/app/server/DataModelHandler.cpp", - "${chip_root}/src/app/util/af-event.cpp", - "${chip_root}/src/app/util/af-main-common.cpp", - "${chip_root}/src/app/util/attribute-size.cpp", - "${chip_root}/src/app/util/attribute-storage.cpp", - "${chip_root}/src/app/util/attribute-table.cpp", - "${chip_root}/src/app/util/binding-table.cpp", - "${chip_root}/src/app/util/chip-message-send.cpp", - "${chip_root}/src/app/util/client-api.cpp", - "${chip_root}/src/app/util/ember-print.cpp", - "${chip_root}/src/app/util/message.cpp", - "${chip_root}/src/app/util/process-cluster-message.cpp", - "${chip_root}/src/app/util/process-global-message.cpp", - "${chip_root}/src/app/util/util.cpp", - "gen/call-command-handler.cpp", - "gen/callback-stub.cpp", +chip_data_model("window-common") { + cluster_sources = [ + "bindings", + "network-commissioning", ] - if (chip_enable_interaction_model) { - sources += [ - "${chip_root}/src/app/util/ember-compatibility-functions.cpp", - "gen/IMClusterCommandHandler.cpp", - ] - } - - deps = [ "${chip_root}/src/lib" ] - - public_configs = [ ":includes" ] + zap_pregenerated_dir = "gen" } diff --git a/src/app/chip_data_model.gni b/src/app/chip_data_model.gni new file mode 100644 index 00000000000000..f2468ba61f7ead --- /dev/null +++ b/src/app/chip_data_model.gni @@ -0,0 +1,156 @@ +# Copyright (c) 2021 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build_overrides/chip.gni") + +import("${chip_root}/src/lib/core/core.gni") + +_app_root = get_path_info(".", "abspath") + +# Defines a source_set for CHIP data model. +# +# Arguments: +# zap_pregenerated_dir +# Path to the ZAP "gen" dir. +# +# cluster_sources +# Names of the clusters to compile. +# +# use_default_client_callbacks +# Include CHIPClientCallbacks.cpp. +# +# Forwards all the remaining variables to the source_set. +# +template("chip_data_model") { + _data_model_name = target_name + + config("${_data_model_name}_config") { + include_dirs = [] + + if (defined(invoker.zap_pregenerated_dir)) { + include_dirs += [ "${invoker.zap_pregenerated_dir}/.." ] + } + } + + _use_default_client_callbacks = + defined(invoker.use_default_client_callbacks) && + invoker.use_default_client_callbacks + + source_set(_data_model_name) { + forward_variables_from(invoker, + "*", + [ + "zap_pregenerated_dir", + "cluster_sources", + "use_default_client_callbacks", + ]) + + if (!defined(sources)) { + sources = [] + } + + sources += [ + "${_app_root}/clusters/barrier-control-server/barrier-control-server.h", + "${_app_root}/clusters/basic/basic.h", + "${_app_root}/clusters/color-control-server/color-control-server.h", + "${_app_root}/clusters/door-lock-server/door-lock-server.h", + "${_app_root}/clusters/groups-server/groups-server.h", + "${_app_root}/clusters/ias-zone-client/ias-zone-client.h", + "${_app_root}/clusters/ias-zone-server/ias-zone-server-tokens.h", + "${_app_root}/clusters/ias-zone-server/ias-zone-server.h", + "${_app_root}/clusters/identify/identify.h", + "${_app_root}/clusters/level-control/level-control.h", + "${_app_root}/clusters/messaging-client/messaging-client.h", + "${_app_root}/clusters/messaging-server/messaging-server.h", + "${_app_root}/clusters/network-commissioning/network-commissioning.h", + "${_app_root}/clusters/on-off-server/on-off-server.h", + "${_app_root}/clusters/scenes-client/scenes-client.h", + "${_app_root}/clusters/scenes/scenes-tokens.h", + "${_app_root}/clusters/scenes/scenes.h", + "${_app_root}/clusters/temperature-measurement-server/temperature-measurement-server.h", + "${_app_root}/clusters/zll-level-control-server/zll-level-control-server.h", + "${_app_root}/clusters/zll-on-off-server/zll-on-off-server.h", + "${_app_root}/clusters/zll-scenes-server/zll-scenes-server.h", + "${_app_root}/reporting/reporting-default-configuration.cpp", + "${_app_root}/reporting/reporting.cpp", + "${_app_root}/server/DataModelHandler.cpp", + "${_app_root}/util/af-event.cpp", + "${_app_root}/util/af-main-common.cpp", + "${_app_root}/util/attribute-size.cpp", + "${_app_root}/util/attribute-storage.cpp", + "${_app_root}/util/attribute-table.cpp", + "${_app_root}/util/binding-table.cpp", + "${_app_root}/util/chip-message-send.cpp", + "${_app_root}/util/client-api.cpp", + "${_app_root}/util/ember-compatibility-functions.cpp", + "${_app_root}/util/ember-print.cpp", + "${_app_root}/util/message.cpp", + "${_app_root}/util/process-cluster-message.cpp", + "${_app_root}/util/process-global-message.cpp", + "${_app_root}/util/util.cpp", + ] + + if (defined(invoker.cluster_sources)) { + foreach(cluster, invoker.cluster_sources) { + if (cluster == "door-lock-server") { + sources += [ + "${_app_root}/clusters/${cluster}/door-lock-server-core.cpp", + "${_app_root}/clusters/${cluster}/door-lock-server-logging.cpp", + "${_app_root}/clusters/${cluster}/door-lock-server-schedule.cpp", + "${_app_root}/clusters/${cluster}/door-lock-server-user.cpp", + ] + } else if (cluster == "network-commissioning") { + sources += [ + "${_app_root}/clusters/${cluster}/${cluster}-ember.cpp", + "${_app_root}/clusters/${cluster}/${cluster}.cpp", + ] + } else { + sources += [ "${_app_root}/clusters/${cluster}/${cluster}.cpp" ] + } + } + } + + if (defined(invoker.zap_pregenerated_dir)) { + sources += [ + "${invoker.zap_pregenerated_dir}/call-command-handler.cpp", + "${invoker.zap_pregenerated_dir}/callback-stub.cpp", + ] + + if (_use_default_client_callbacks) { + sources += [ "${invoker.zap_pregenerated_dir}/CHIPClientCallbacks.cpp" ] + } + + if (chip_enable_interaction_model) { + sources += + [ "${invoker.zap_pregenerated_dir}/IMClusterCommandHandler.cpp" ] + } + } + + if (!defined(public_deps)) { + public_deps = [] + } + + public_deps += [ + "${chip_root}/src/app", + "${chip_root}/src/lib/core", + "${chip_root}/src/lib/support", + ] + + if (!defined(public_configs)) { + public_configs = [] + } + + public_configs += [ ":${_data_model_name}_config" ] + } +} diff --git a/src/app/clusters/level-control/level-control.cpp b/src/app/clusters/level-control/level-control.cpp index 7ba20dea6c1ecd..df43112f1158bf 100644 --- a/src/app/clusters/level-control/level-control.cpp +++ b/src/app/clusters/level-control/level-control.cpp @@ -57,7 +57,7 @@ #endif // EMBER_AF_PLUGIN_SCENES #ifdef EMBER_AF_PLUGIN_ON_OFF -#include +#include #endif // EMBER_AF_PLUGIN_ON_OFF #ifdef EMBER_AF_PLUGIN_ZLL_LEVEL_CONTROL_SERVER diff --git a/src/app/clusters/on-off-server/on-off.cpp b/src/app/clusters/on-off-server/on-off-server.cpp similarity index 99% rename from src/app/clusters/on-off-server/on-off.cpp rename to src/app/clusters/on-off-server/on-off-server.cpp index ade2784ffeb703..3ab529d73d85b5 100644 --- a/src/app/clusters/on-off-server/on-off.cpp +++ b/src/app/clusters/on-off-server/on-off-server.cpp @@ -38,7 +38,7 @@ *implements the On-Off server cluster. ******************************************************************************* ******************************************************************************/ -#include "on-off.h" +#include "on-off-server.h" #include "af.h" diff --git a/src/app/clusters/on-off-server/on-off.h b/src/app/clusters/on-off-server/on-off-server.h similarity index 100% rename from src/app/clusters/on-off-server/on-off.h rename to src/app/clusters/on-off-server/on-off-server.h diff --git a/src/darwin/Framework/CHIP/BUILD.gn b/src/darwin/Framework/CHIP/BUILD.gn new file mode 100644 index 00000000000000..6ed64ec916ed86 --- /dev/null +++ b/src/darwin/Framework/CHIP/BUILD.gn @@ -0,0 +1,77 @@ +# Copyright (c) 2021 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build_overrides/chip.gni") + +import("${chip_root}/src/app/chip_data_model.gni") + +config("darwin_config") { + include_dirs = [ ".." ] + + cflags = [ + "-Wconversion", + "-fobjc-arc", + ] +} + +static_library("framework") { + sources = [ + "CHIP.h", + "CHIPDevice.h", + "CHIPDevice.mm", + "CHIPDeviceController.h", + "CHIPDeviceController.mm", + "CHIPDevicePairingDelegate.h", + "CHIPDevicePairingDelegateBridge.h", + "CHIPDevicePairingDelegateBridge.mm", + "CHIPDevice_Internal.h", + "CHIPError.h", + "CHIPError.mm", + "CHIPLogging.h", + "CHIPManualSetupPayloadParser.h", + "CHIPManualSetupPayloadParser.mm", + "CHIPPersistentStorageDelegate.h", + "CHIPPersistentStorageDelegateBridge.h", + "CHIPPersistentStorageDelegateBridge.mm", + "CHIPQRCodeSetupPayloadParser.h", + "CHIPQRCodeSetupPayloadParser.mm", + "CHIPSetupPayload.h", + "CHIPSetupPayload.mm", + ] + + public_deps = [ + "${chip_root}/src/controller", + "${chip_root}/src/lib/core", + "${chip_root}/src/lib/support", + ] + + public_configs = [ ":darwin_config" ] +} + +chip_data_model("darwin_data_model") { + cluster_sources = [ "media-playback-client" ] + + zap_pregenerated_dir = "gen" + + public_configs = [ ":darwin_config" ] + + use_default_client_callbacks = true +} + +group("CHIP") { + public_deps = [ + ":darwin_data_model", + ":framework", + ] +}