Skip to content

Commit

Permalink
Centralize data model specification of examples (#5882)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mspang authored Apr 9, 2021
1 parent 3ac4592 commit e772be0
Show file tree
Hide file tree
Showing 16 changed files with 332 additions and 322 deletions.
87 changes: 28 additions & 59 deletions examples/all-clusters-app/all-clusters-common/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
44 changes: 9 additions & 35 deletions examples/bridge-app/bridge-common/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
40 changes: 3 additions & 37 deletions examples/chip-tool-darwin/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
30 changes: 10 additions & 20 deletions examples/chip-tool/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,24 @@ 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)

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",
Expand All @@ -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",
Expand Down
43 changes: 8 additions & 35 deletions examples/lighting-app/lighting-common/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand All @@ -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"
}
2 changes: 1 addition & 1 deletion examples/lighting-app/nrfconnect/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
41 changes: 7 additions & 34 deletions examples/lock-app/lock-common/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
2 changes: 1 addition & 1 deletion examples/lock-app/nrfconnect/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 0 additions & 2 deletions examples/tv-app/linux/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ config("includes") {
include_dirs = [
".",
"include",
"${chip_root}/src/app/util",
"${chip_root}/src/app/server",
]
}

Expand Down
Loading

0 comments on commit e772be0

Please sign in to comment.