Skip to content

Commit

Permalink
Define per-cluster server and client targets in GN
Browse files Browse the repository at this point in the history
Have chip_data_model targets depend on these, instead of making up a source set on the fly.
  • Loading branch information
ksperling-apple committed Dec 20, 2024
1 parent 75ab4c9 commit 5728f01
Show file tree
Hide file tree
Showing 21 changed files with 553 additions and 377 deletions.
4 changes: 2 additions & 2 deletions examples/network-manager-app/linux/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
*/

#include <AppMain.h>
#include <app/clusters/thread-network-directory-server/thread-network-directory-server.h>
#include <app/clusters/wifi-network-management-server/wifi-network-management-server.h>
#include <app/clusters/thread-network-directory/thread-network-directory-server.h>
#include <app/clusters/wifi-network-management/wifi-network-management-server.h>
#include <lib/core/CHIPSafeCasts.h>
#include <lib/support/CodeUtils.h>
#include <lib/support/Span.h>
Expand Down
86 changes: 68 additions & 18 deletions src/app/chip_data_model.gni
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,12 @@ template("chip_data_model") {
defines = []
}

foreach(cluster, _cluster_sources) {
foreach(cluster_target, _cluster_sources) {
# Work out the legacy ${cluster} directory name
cluster_target_parts = []
cluster_target_parts = string_split(cluster_target, ":")
cluster = cluster_target_parts[0]

if (cluster == "door-lock-server") {
sources += [
"${_app_root}/clusters/${cluster}/door-lock-server-callback.cpp",
Expand Down Expand Up @@ -299,14 +304,6 @@ template("chip_data_model") {
# TODO: DefaultOTARequestor depends on controller, however the cluster server itself does not.
# Maybe DefaultOTARequestor and related code should have its own source set.
deps += [ "${chip_root}/src/controller:interactions" ]
} else if (cluster == "bindings") {
sources += [
"${_app_root}/clusters/${cluster}/${cluster}.cpp",
"${_app_root}/clusters/${cluster}/BindingManager.cpp",
"${_app_root}/clusters/${cluster}/BindingManager.h",
"${_app_root}/clusters/${cluster}/PendingNotificationMap.cpp",
"${_app_root}/clusters/${cluster}/PendingNotificationMap.h",
]
} else if (cluster == "time-synchronization-server") {
sources += [
"${_app_root}/clusters/${cluster}/${cluster}.cpp",
Expand Down Expand Up @@ -428,14 +425,6 @@ template("chip_data_model") {
"${_app_root}/clusters/${cluster}/${cluster}.h",
"${_app_root}/clusters/${cluster}/WaterHeaterManagementTestEventTriggerHandler.h",
]
} else if (cluster == "thread-network-directory-server") {
sources += [
"${_app_root}/clusters/${cluster}/${cluster}.cpp",
"${_app_root}/clusters/${cluster}/${cluster}.h",
"${_app_root}/clusters/${cluster}/DefaultThreadNetworkDirectoryStorage.cpp",
"${_app_root}/clusters/${cluster}/DefaultThreadNetworkDirectoryStorage.h",
"${_app_root}/clusters/${cluster}/ThreadNetworkDirectoryStorage.h",
]
} else if (cluster == "thermostat-server") {
sources += [
"${_app_root}/clusters/${cluster}/${cluster}-atomic.cpp",
Expand All @@ -452,8 +441,68 @@ template("chip_data_model") {
"${_app_root}/clusters/${cluster}/ArlEncoder.cpp",
"${_app_root}/clusters/${cluster}/ArlEncoder.h",
]
} else {
} else if (cluster == "account-login-server" ||
cluster == "administrator-commissioning-server" ||
cluster == "application-basic-server" ||
cluster == "audio-output-server" ||
cluster == "basic-information" ||
cluster == "bridged-device-basic-information-server" ||
cluster == "channel-server" || cluster == "chime-server" ||
cluster == "color-control-server" ||
cluster == "commissioner-control-server" ||
cluster == "content-app-observer" ||
cluster == "content-control-server" ||
cluster == "content-launch-server" ||
cluster == "ecosystem-information-server" ||
cluster == "electrical-power-measurement-server" ||
cluster == "energy-preference-server" ||
cluster == "ethernet-network-diagnostics-server" ||
cluster == "fan-control-server" ||
cluster == "fault-injection-server" ||
cluster == "fixed-label-server" ||
cluster == "general-commissioning-server" ||
cluster == "general-diagnostics-server" ||
cluster == "group-key-mgmt-server" ||
cluster == "groups-server" || cluster == "identify-server" ||
cluster == "keypad-input-server" ||
cluster == "laundry-dryer-controls-server" ||
cluster == "laundry-washer-controls-server" ||
cluster == "level-control" ||
cluster == "localization-configuration-server" ||
cluster == "low-power-server" ||
cluster == "media-input-server" ||
cluster == "media-playback-server" ||
cluster == "messages-server" ||
cluster == "microwave-oven-control-server" ||
cluster == "network-commissioning" ||
cluster == "occupancy-sensor-server" ||
cluster == "on-off-server" ||
cluster == "operational-credentials-server" ||
cluster == "ota-provider" ||
cluster == "power-source-configuration-server" ||
cluster == "power-source-server" ||
cluster == "power-topology-server" ||
cluster == "pump-configuration-and-control-server" ||
cluster == "pump-configuration-and-control-client" ||
cluster == "refrigerator-alarm-server" ||
cluster == "sample-mei-server" ||
cluster == "software-diagnostics-server" ||
cluster == "switch-server" ||
cluster == "target-navigator-server" ||
cluster == "test-cluster-server" ||
cluster == "thermostat-user-interface-configuration-server" ||
cluster == "thermostat-client" ||
cluster == "time-format-localization-server" ||
cluster == "timer-server" || cluster == "user-label-server" ||
cluster == "valve-configuration-and-control-server" ||
cluster == "wake-on-lan-server" ||
cluster == "wifi-network-diagnostics-server" ||
cluster == "window-covering-server") {
# Fallback for clusters not yet migrated, do not add to this list
sources += [ "${_app_root}/clusters/${cluster}/${cluster}.cpp" ]
} else {
# New clusters should follow this pattern and provide a BUILD.gn with a "server" or "client" target as appropriate
public_deps += [ "${_app_root}/clusters/${cluster_target}" ]
}
}

Expand All @@ -470,6 +519,7 @@ template("chip_data_model") {
"${chip_root}/src/app/common:cluster-objects",
"${chip_root}/src/app/common:enums",
"${chip_root}/src/app/server",
"${chip_root}/src/app/util:binding-table-headers",
"${chip_root}/src/app/util:types",
"${chip_root}/src/app/util/persistence",
"${chip_root}/src/lib/core",
Expand Down
31 changes: 31 additions & 0 deletions src/app/clusters/bindings/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Copyright (c) 2024 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")

source_set("server") {
deps = [
"${chip_root}/src/app",
"${chip_root}/src/app/server",
"${chip_root}/src/app/util:binding-table-headers",
]
sources = [
"BindingManager.cpp",
"BindingManager.h",
"PendingNotificationMap.cpp",
"PendingNotificationMap.h",
"bindings.cpp",
"bindings.h",
]
}
26 changes: 26 additions & 0 deletions src/app/clusters/descriptor/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copyright (c) 2024 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")

source_set("server") {
deps = [
"${chip_root}/src/app",
"${chip_root}/src/app/util:ember-api-headers",
]
sources = [
"descriptor.cpp",
"descriptor.h",
]
}
2 changes: 1 addition & 1 deletion src/app/clusters/descriptor/descriptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include <app/AttributeAccessInterfaceRegistry.h>
#include <app/InteractionModelEngine.h>
#include <app/data-model-provider/MetadataTypes.h>
#include <app/util/attribute-storage.h>
#include <app/util/ember-api.h>
#include <app/util/endpoint-config-api.h>
#include <lib/support/CodeUtils.h>
#include <lib/support/logging/CHIPLogging.h>
Expand Down
31 changes: 31 additions & 0 deletions src/app/clusters/thread-network-directory/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Copyright (c) 2024 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")

source_set("server") {
deps = [
"${chip_root}/src/app",
"${chip_root}/src/app/server", # Only DefaultThreadNetworkDirectoryServer
# depends on this, could split into a
# separate target
]
sources = [
"DefaultThreadNetworkDirectoryStorage.cpp",
"DefaultThreadNetworkDirectoryStorage.h",
"ThreadNetworkDirectoryStorage.h",
"thread-network-directory-server.cpp",
"thread-network-directory-server.h",
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

#include "DefaultThreadNetworkDirectoryStorage.h"
#include <app/clusters/thread-network-directory-server/DefaultThreadNetworkDirectoryStorage.h>
#include <app/clusters/thread-network-directory/DefaultThreadNetworkDirectoryStorage.h>
#include <lib/support/DefaultStorageKeyAllocator.h>
#include <lib/support/SafeInt.h>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

#pragma once

#include <app/clusters/thread-network-directory-server/ThreadNetworkDirectoryStorage.h>
#include <app/clusters/thread-network-directory/ThreadNetworkDirectoryStorage.h>
#include <lib/core/CHIPPersistentStorageDelegate.h>
#include <lib/support/Pool.h>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
#include <app-common/zap-generated/cluster-objects.h>
#include <app/AttributeAccessInterface.h>
#include <app/CommandHandlerInterface.h>
#include <app/clusters/thread-network-directory-server/DefaultThreadNetworkDirectoryStorage.h>
#include <app/clusters/thread-network-directory-server/ThreadNetworkDirectoryStorage.h>
#include <app/clusters/thread-network-directory/DefaultThreadNetworkDirectoryStorage.h>
#include <app/clusters/thread-network-directory/ThreadNetworkDirectoryStorage.h>
#include <app/server/Server.h>
#include <lib/core/CHIPError.h>

Expand Down
23 changes: 23 additions & 0 deletions src/app/clusters/wifi-network-management/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright (c) 2024 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")

source_set("server") {
deps = [ "${chip_root}/src/app" ]
sources = [
"wifi-network-management-server.cpp",
"wifi-network-management-server.h",
]
}
15 changes: 1 addition & 14 deletions src/app/tests/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -74,19 +74,6 @@ source_set("ota-requestor-test-srcs") {
]
}

source_set("thread-network-directory-test-srcs") {
sources = [
"${chip_root}/src/app/clusters/thread-network-directory-server/DefaultThreadNetworkDirectoryStorage.cpp",
"${chip_root}/src/app/clusters/thread-network-directory-server/DefaultThreadNetworkDirectoryStorage.h",
"${chip_root}/src/app/clusters/thread-network-directory-server/ThreadNetworkDirectoryStorage.h",
]

public_deps = [
"${chip_root}/src/app/common:cluster-objects",
"${chip_root}/src/lib/core",
]
}

source_set("time-sync-data-provider-test-srcs") {
sources = [ "${chip_root}/src/app/clusters/time-synchronization-server/TimeSyncDataProvider.cpp" ]

Expand Down Expand Up @@ -244,10 +231,10 @@ chip_test_suite("tests") {
":operational-state-test-srcs",
":ota-requestor-test-srcs",
":power-cluster-test-srcs",
":thread-network-directory-test-srcs",
":time-sync-data-provider-test-srcs",
"${chip_root}/src/app",
"${chip_root}/src/app:attribute-persistence",
"${chip_root}/src/app/clusters/thread-network-directory:server",
"${chip_root}/src/app/common:cluster-objects",
"${chip_root}/src/app/data-model-provider/tests:encode-decode",
"${chip_root}/src/app/icd/client:handler",
Expand Down
2 changes: 1 addition & 1 deletion src/app/tests/TestDefaultThreadNetworkDirectoryStorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

#include <app/clusters/thread-network-directory-server/DefaultThreadNetworkDirectoryStorage.h>
#include <app/clusters/thread-network-directory/DefaultThreadNetworkDirectoryStorage.h>
#include <lib/core/CHIPPersistentStorageDelegate.h>
#include <lib/support/DefaultStorageKeyAllocator.h>
#include <lib/support/TestPersistentStorageDelegate.h>
Expand Down
8 changes: 8 additions & 0 deletions src/app/util/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,11 @@ source_set("callbacks") {
"${chip_root}/src/app:paths",
]
}

source_set("binding-table-headers") {
sources = [ "binding-table.h" ]
}

source_set("ember-api-headers") {
sources = [ "ember-api.h" ]
}
Loading

0 comments on commit 5728f01

Please sign in to comment.