Skip to content

Commit

Permalink
Decouple CommandHandler.h/cpp from the BUILD.gn build rules of app/…
Browse files Browse the repository at this point in the history
…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 <[email protected]>
  • Loading branch information
andy31415 and andreilitvin authored May 28, 2024
1 parent 5656870 commit af25f56
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 22 deletions.
1 change: 0 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ jobs:
--known-failure controller/ExamplePersistentStorage.cpp \
--known-failure controller/ExamplePersistentStorage.h \
--known-failure app/AttributeAccessToken.h \
--known-failure app/CommandHandler.h \
--known-failure app/CommandHandlerInterface.h \
--known-failure app/CommandResponseSender.h \
--known-failure app/CommandSenderLegacyCallback.h \
Expand Down
65 changes: 57 additions & 8 deletions src/app/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,6 @@ static_library("interaction-model") {
"ReadClient.h", # TODO: cpp is only included conditionally. Needs logic
# fixing
"ReadPrepareParams.h",
"RequiredPrivilege.h",
"StatusResponse.cpp",
"StatusResponse.h",
"SubscriptionResumptionStorage.h",
"TimedHandler.cpp",
"TimedHandler.h",
Expand Down Expand Up @@ -210,6 +207,7 @@ static_library("interaction-model") {

public_deps = [
":app_config",
":command-handler",
":constants",
":paths",
":subscription-info-provider",
Expand Down Expand Up @@ -248,8 +246,6 @@ static_library("interaction-model") {
"dynamic_server/AccessControl.cpp",
"dynamic_server/AccessControl.h",
"dynamic_server/DynamicDispatcher.cpp",
"util/privilege-storage.cpp",
"util/privilege-storage.h",
]

public_deps += [
Expand Down Expand Up @@ -301,6 +297,62 @@ static_library("attribute-access") {
]
}

source_set("required-privileges") {
sources = [ "RequiredPrivilege.h" ]

public_deps = [
":paths",
"${chip_root}/src/access:types",
]

if (chip_build_controller_dynamic_server) {
sources += [
"util/privilege-storage.cpp",
"util/privilege-storage.h",
]

public_deps += [
":global-attributes",
"${chip_root}/src/access",
"${chip_root}/src/app/dynamic_server:mock-codegen-includes",
]

public_configs = [ ":config-controller-dynamic-server" ]
}
}

source_set("status-response") {
sources = [
"StatusResponse.cpp",
"StatusResponse.h",
]
public_deps = [
":constants",
"${chip_root}/src/app/MessageDef",
"${chip_root}/src/messaging",
]
}

source_set("command-handler") {
sources = [
"CommandHandler.cpp",
"CommandHandler.h",
"CommandHandlerExchangeInterface.h",
]

public_deps = [
":paths",
":required-privileges",
":status-response",
"${chip_root}/src/access:types",
"${chip_root}/src/app/MessageDef",
"${chip_root}/src/app/data-model",
"${chip_root}/src/app/util:callbacks",
"${chip_root}/src/lib/support",
"${chip_root}/src/messaging",
]
}

# 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.
# 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.
static_library("app") {
Expand All @@ -312,8 +364,6 @@ static_library("app") {
"AttributePersistenceProvider.h",
"ChunkedWriteCallback.cpp",
"ChunkedWriteCallback.h",
"CommandHandler.cpp",
"CommandHandlerExchangeInterface.h",
"CommandResponseHelper.h",
"CommandResponseSender.cpp",
"DefaultAttributePersistenceProvider.cpp",
Expand All @@ -338,7 +388,6 @@ static_library("app") {
# (app depending on im and im including these headers):
# Name with _ so that linter does not recognize it
# "CommandResponseSender._h"
# "CommandHandler._h"
# "ReadHandler._h",
# "WriteHandler._h"
]
Expand Down
14 changes: 3 additions & 11 deletions src/app/CommandHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,20 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/**
* @file
* This file defines object for a CHIP IM Invoke Command Handler
*
*/

#include "CommandHandler.h"
#include "InteractionModelEngine.h"
#include "RequiredPrivilege.h"
#include "messaging/ExchangeContext.h"
#include <app/CommandHandler.h>

#include <access/AccessControl.h>
#include <app-common/zap-generated/cluster-objects.h>
#include <app/RequiredPrivilege.h>
#include <app/StatusResponse.h>
#include <app/util/MatterCallbacks.h>
#include <credentials/GroupDataProvider.h>
#include <lib/core/CHIPConfig.h>
#include <lib/core/TLVData.h>
#include <lib/core/TLVUtilities.h>
#include <lib/support/IntrusiveList.h>
#include <lib/support/TypeTraits.h>
#include <messaging/ExchangeContext.h>
#include <platform/LockTracker.h>
#include <protocols/secure_channel/Constants.h>

Expand Down
3 changes: 1 addition & 2 deletions src/app/CommandHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@

#pragma once

#include "CommandPathRegistry.h"

#include <app/CommandHandlerExchangeInterface.h>
#include <app/CommandPathRegistry.h>
#include <app/ConcreteCommandPath.h>
#include <app/data-model/Encode.h>
#include <lib/core/CHIPCore.h>
Expand Down

0 comments on commit af25f56

Please sign in to comment.