Skip to content

Commit af25f56

Browse files
Decouple CommandHandler.h/cpp from the BUILD.gn build rules of app/interaction-model (#33595)
* Initial version of splitting out command handler dependencies * Restyle * move privilege-storage based on dynamic server build rules...this is somewhat messy * More dynamic server fixes * Another gn fix for android/dynamic-server builds --------- Co-authored-by: Andrei Litvin <andreilitvin@google.com>
1 parent 5656870 commit af25f56

File tree

4 files changed

+61
-22
lines changed

4 files changed

+61
-22
lines changed

.github/workflows/lint.yml

-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ jobs:
9898
--known-failure controller/ExamplePersistentStorage.cpp \
9999
--known-failure controller/ExamplePersistentStorage.h \
100100
--known-failure app/AttributeAccessToken.h \
101-
--known-failure app/CommandHandler.h \
102101
--known-failure app/CommandHandlerInterface.h \
103102
--known-failure app/CommandResponseSender.h \
104103
--known-failure app/CommandSenderLegacyCallback.h \

src/app/BUILD.gn

+57-8
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,6 @@ static_library("interaction-model") {
179179
"ReadClient.h", # TODO: cpp is only included conditionally. Needs logic
180180
# fixing
181181
"ReadPrepareParams.h",
182-
"RequiredPrivilege.h",
183-
"StatusResponse.cpp",
184-
"StatusResponse.h",
185182
"SubscriptionResumptionStorage.h",
186183
"TimedHandler.cpp",
187184
"TimedHandler.h",
@@ -210,6 +207,7 @@ static_library("interaction-model") {
210207

211208
public_deps = [
212209
":app_config",
210+
":command-handler",
213211
":constants",
214212
":paths",
215213
":subscription-info-provider",
@@ -248,8 +246,6 @@ static_library("interaction-model") {
248246
"dynamic_server/AccessControl.cpp",
249247
"dynamic_server/AccessControl.h",
250248
"dynamic_server/DynamicDispatcher.cpp",
251-
"util/privilege-storage.cpp",
252-
"util/privilege-storage.h",
253249
]
254250

255251
public_deps += [
@@ -301,6 +297,62 @@ static_library("attribute-access") {
301297
]
302298
}
303299

300+
source_set("required-privileges") {
301+
sources = [ "RequiredPrivilege.h" ]
302+
303+
public_deps = [
304+
":paths",
305+
"${chip_root}/src/access:types",
306+
]
307+
308+
if (chip_build_controller_dynamic_server) {
309+
sources += [
310+
"util/privilege-storage.cpp",
311+
"util/privilege-storage.h",
312+
]
313+
314+
public_deps += [
315+
":global-attributes",
316+
"${chip_root}/src/access",
317+
"${chip_root}/src/app/dynamic_server:mock-codegen-includes",
318+
]
319+
320+
public_configs = [ ":config-controller-dynamic-server" ]
321+
}
322+
}
323+
324+
source_set("status-response") {
325+
sources = [
326+
"StatusResponse.cpp",
327+
"StatusResponse.h",
328+
]
329+
public_deps = [
330+
":constants",
331+
"${chip_root}/src/app/MessageDef",
332+
"${chip_root}/src/messaging",
333+
]
334+
}
335+
336+
source_set("command-handler") {
337+
sources = [
338+
"CommandHandler.cpp",
339+
"CommandHandler.h",
340+
"CommandHandlerExchangeInterface.h",
341+
]
342+
343+
public_deps = [
344+
":paths",
345+
":required-privileges",
346+
":status-response",
347+
"${chip_root}/src/access:types",
348+
"${chip_root}/src/app/MessageDef",
349+
"${chip_root}/src/app/data-model",
350+
"${chip_root}/src/app/util:callbacks",
351+
"${chip_root}/src/lib/support",
352+
"${chip_root}/src/messaging",
353+
]
354+
}
355+
304356
# Note to developpers, instead of continuously adding files in the app librabry, it is recommand to create smaller source_sets that app can depend on.
305357
# This way, we can have a better understanding of dependencies and other componenets can depend on the different source_sets without needing to depend on the entire app library.
306358
static_library("app") {
@@ -312,8 +364,6 @@ static_library("app") {
312364
"AttributePersistenceProvider.h",
313365
"ChunkedWriteCallback.cpp",
314366
"ChunkedWriteCallback.h",
315-
"CommandHandler.cpp",
316-
"CommandHandlerExchangeInterface.h",
317367
"CommandResponseHelper.h",
318368
"CommandResponseSender.cpp",
319369
"DefaultAttributePersistenceProvider.cpp",
@@ -338,7 +388,6 @@ static_library("app") {
338388
# (app depending on im and im including these headers):
339389
# Name with _ so that linter does not recognize it
340390
# "CommandResponseSender._h"
341-
# "CommandHandler._h"
342391
# "ReadHandler._h",
343392
# "WriteHandler._h"
344393
]

src/app/CommandHandler.cpp

+3-11
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,20 @@
1515
* See the License for the specific language governing permissions and
1616
* limitations under the License.
1717
*/
18-
19-
/**
20-
* @file
21-
* This file defines object for a CHIP IM Invoke Command Handler
22-
*
23-
*/
24-
25-
#include "CommandHandler.h"
26-
#include "InteractionModelEngine.h"
27-
#include "RequiredPrivilege.h"
28-
#include "messaging/ExchangeContext.h"
18+
#include <app/CommandHandler.h>
2919

3020
#include <access/AccessControl.h>
3121
#include <app-common/zap-generated/cluster-objects.h>
3222
#include <app/RequiredPrivilege.h>
23+
#include <app/StatusResponse.h>
3324
#include <app/util/MatterCallbacks.h>
3425
#include <credentials/GroupDataProvider.h>
3526
#include <lib/core/CHIPConfig.h>
3627
#include <lib/core/TLVData.h>
3728
#include <lib/core/TLVUtilities.h>
3829
#include <lib/support/IntrusiveList.h>
3930
#include <lib/support/TypeTraits.h>
31+
#include <messaging/ExchangeContext.h>
4032
#include <platform/LockTracker.h>
4133
#include <protocols/secure_channel/Constants.h>
4234

src/app/CommandHandler.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,8 @@
3030

3131
#pragma once
3232

33-
#include "CommandPathRegistry.h"
34-
3533
#include <app/CommandHandlerExchangeInterface.h>
34+
#include <app/CommandPathRegistry.h>
3635
#include <app/ConcreteCommandPath.h>
3736
#include <app/data-model/Encode.h>
3837
#include <lib/core/CHIPCore.h>

0 commit comments

Comments
 (0)