Skip to content

Commit

Permalink
RFC: 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 tries to
enable the appropriate directories in src/app/clusters.

It's not clear if this is the right thing to do, as selecting
directories this way leads to including directories that do not compile.
This draft PR filters those back out again.

Based on #5882
  • Loading branch information
mspang committed Apr 9, 2021
1 parent fca1757 commit a16bd02
Show file tree
Hide file tree
Showing 10 changed files with 268 additions and 92 deletions.
34 changes: 7 additions & 27 deletions examples/all-clusters-app/all-clusters-common/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -17,33 +17,13 @@ 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",
"scenes",
"target-navigator-server",
"temperature-measurement-server",
"tv-channel-server",
]
zap_file = "all-clusters-app.zap"

zap_pregenerated_dir = "gen"

# These clusters are configured in the ZAP file but don't compile.
remove_cluster_sources = [
"ias-zone-client",
"scenes-client",
]
}
16 changes: 9 additions & 7 deletions examples/bridge-app/bridge-common/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ 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"

# These clusters are configured in the ZAP file but don't compile.
remove_cluster_sources = [
"color-control-server",
"groups-server",
"identify",
"scenes",
]
}
16 changes: 15 additions & 1 deletion examples/chip-tool/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,25 @@ config("includes") {
}

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

zap_pregenerated_dir = "gen"

use_default_client_callbacks = true

# These clusters are configured in the ZAP file but don't compile.
remove_cluster_sources = [
"color-control-server",
"door-lock-client",
"groups-client",
"groups-server",
"ias-zone-client",
"ias-zone-server",
"identify",
"level-control",
"scenes",
"scenes-client",
]
}

executable("chip-tool") {
Expand Down
14 changes: 8 additions & 6 deletions examples/lighting-app/lighting-common/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,14 @@ if (enable_pw_rpc) {
}

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

zap_pregenerated_dir = "gen"

# These clusters are configured in the ZAP file but don't compile.
remove_cluster_sources = [
"groups-server",
"identify",
"scenes",
]
}
13 changes: 8 additions & 5 deletions examples/lock-app/lock-common/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@ import("//build_overrides/chip.gni")
import("${chip_root}/src/app/chip_data_model.gni")

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

zap_pregenerated_dir = "gen"

# These clusters are configured in the ZAP file but don't compile.
remove_cluster_sources = [
"groups-server",
"identify",
"scenes",
]
}
29 changes: 7 additions & 22 deletions examples/tv-app/tv-common/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,13 @@ 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",
"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"

# These clusters are configured in the ZAP file but don't compile.
remove_cluster_sources = [
"ias-zone-client",
"scenes-client",
]
}
12 changes: 8 additions & 4 deletions examples/window-app/common/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,14 @@ 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"

# These clusters are configured in the ZAP file but don't compile.
remove_cluster_sources = [
"groups-server",
"identify",
"scenes",
]
}
60 changes: 43 additions & 17 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 Down Expand Up @@ -102,22 +114,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
Loading

0 comments on commit a16bd02

Please sign in to comment.