Skip to content

Commit

Permalink
Read the ZAP file to determine which directories to compile
Browse files Browse the repository at this point in the history
This parses the ZAP file, enumerates enabled clusters, and enables the
appropriate directories in src/app/clusters.

Some of the directories in src/app/clusters are dead code and do not
even compile. Remove those.

Based on #5882
  • Loading branch information
mspang committed Apr 22, 2021
1 parent 1d4726c commit 8d4751d
Show file tree
Hide file tree
Showing 15 changed files with 208 additions and 614 deletions.
30 changes: 1 addition & 29 deletions examples/all-clusters-app/all-clusters-common/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -17,35 +17,7 @@ import("//build_overrides/chip.gni")
import("${chip_root}/src/app/chip_data_model.gni")

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",
"descriptor",
"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",
"operational-credentials",
"ota-server",
"scenes",
"target-navigator-server",
"temperature-measurement-server",
"tv-channel-server",
]
zap_file = "all-clusters-app.zap"

zap_pregenerated_dir = "gen"
}
8 changes: 1 addition & 7 deletions examples/bridge-app/bridge-common/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,7 @@ import("//build_overrides/chip.gni")
import("${chip_root}/src/app/chip_data_model.gni")

chip_data_model("bridge-common") {
cluster_sources = [
"basic",
"bindings",
"level-control",
"network-commissioning",
"on-off-server",
]
zap_file = "bridge-app.zap"

zap_pregenerated_dir = "gen"
}
5 changes: 1 addition & 4 deletions examples/chip-tool/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ import("${chip_root}/src/app/chip_data_model.gni")
assert(chip_build_tools)

chip_data_model("data_model") {
cluster_sources = [
"media-playback-client",
"thermostat-client",
]
zap_file = "chip-tool.zap"

zap_pregenerated_dir = "gen"

Expand Down
8 changes: 1 addition & 7 deletions examples/lighting-app/lighting-common/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,7 @@ if (chip_enable_pw_rpc) {
}

chip_data_model("lighting-common") {
cluster_sources = [
"basic",
"bindings",
"level-control",
"network-commissioning",
"on-off-server",
]
zap_file = "lighting-app.zap"

zap_pregenerated_dir = "gen"
}
7 changes: 1 addition & 6 deletions examples/lock-app/lock-common/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,7 @@ import("//build_overrides/chip.gni")
import("${chip_root}/src/app/chip_data_model.gni")

chip_data_model("lock-common") {
cluster_sources = [
"basic",
"bindings",
"network-commissioning",
"on-off-server",
]
zap_file = "lock-app.zap"

zap_pregenerated_dir = "gen"
}
24 changes: 1 addition & 23 deletions examples/tv-app/tv-common/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,7 @@ import("//build_overrides/chip.gni")
import("${chip_root}/src/app/chip_data_model.gni")

chip_data_model("tv-common") {
cluster_sources = [
"barrier-control-server",
"basic",
"bindings",
"color-control-server",
"content-launch-server",
"door-lock-client",
"door-lock-server",
"general-commissioning-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",
]
zap_file = "tv-app.zap"

zap_pregenerated_dir = "gen"
}
5 changes: 1 addition & 4 deletions examples/window-app/common/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ import("//build_overrides/chip.gni")
import("${chip_root}/src/app/chip_data_model.gni")

chip_data_model("window-common") {
cluster_sources = [
"bindings",
"network-commissioning",
]
zap_file = "window-app.zap"

zap_pregenerated_dir = "gen"
}
61 changes: 43 additions & 18 deletions src/app/chip_data_model.gni
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,24 @@ import("${chip_root}/src/lib/core/core.gni")

_app_root = get_path_info(".", "abspath")

_zap_cluster_list_script = get_path_info("zap_cluster_list.py", "abspath")

# Defines a source_set for CHIP data model.
#
# Arguments:
# zap_pregenerated_dir
# Path to the ZAP "gen" dir.
#
# zap_file
# Path to the ZAP input file.
#
# cluster_sources
# Names of the clusters to compile.
# Names of the clusters directories to compile.
# Deprecated, specify zap_file instead.
#
# remove_cluster_sources
# Names of the cluster directories to remove.
# TODO - Remove this option once everything compiles.
#
# use_default_client_callbacks
# Include CHIPClientCallbacks.cpp.
Expand Down Expand Up @@ -53,6 +63,8 @@ template("chip_data_model") {
[
"zap_pregenerated_dir",
"cluster_sources",
"remove_cluster_sources",
"zap_file",
"use_default_client_callbacks",
])

Expand All @@ -75,7 +87,6 @@ template("chip_data_model") {
"${_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",
Expand All @@ -102,22 +113,36 @@ template("chip_data_model") {
]

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" ]
}
_cluster_sources = invoker.cluster_sources
} else if (defined(invoker.zap_file)) {
_zap_path = rebase_path(invoker.zap_file, root_build_dir)
_script_args = [ "--zap_file=" + _zap_path ]

_cluster_sources = exec_script(_zap_cluster_list_script,
_script_args,
"list lines",
[ invoker.zap_file ])
}

if (defined(invoker.remove_cluster_sources)) {
_cluster_sources -= invoker.remove_cluster_sources
}

foreach(cluster, _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" ]
}
}

Expand Down
42 changes: 0 additions & 42 deletions src/app/clusters/door-lock-client/door-lock-client.cpp

This file was deleted.

89 changes: 0 additions & 89 deletions src/app/clusters/groups-client/groups-client.cpp

This file was deleted.

Loading

0 comments on commit 8d4751d

Please sign in to comment.