Skip to content

Commit

Permalink
Split the targets for nullable support (#34198)
Browse files Browse the repository at this point in the history
* Split the targets for nullable support

- Fixes a prior circular dependency on nullable scalar traits
- Allows portable code to only depend on the nullable support
  without needing to also include any code-generated artifacts

* Restyled by gn

* Address review comments

* Apply review comments

* Fix dependency on tests

* Fix OpenIOT SDK unit tests

---------

Co-authored-by: Restyled.io <[email protected]>
  • Loading branch information
2 people authored and pull[bot] committed Jul 9, 2024
1 parent 9b1f8bd commit 1794004
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 14 deletions.
3 changes: 2 additions & 1 deletion docs/guides/openiotsdk_unit_tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@ The list of currently supported Matter's component tests:

```
accesstest
AppDataModelTests
AppTests
ASN1Tests
BDXTests
ChipCryptoTests
ControllerDataModelTests
CoreTests
CredentialsTest
DataModelTests
ICDServerTests
InetLayerTests
MdnsTests
Expand Down
1 change: 1 addition & 0 deletions src/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ if (chip_build_tests) {
chip_test_group("tests") {
deps = []
tests = [
"${chip_root}/src/app/data-model/tests",
"${chip_root}/src/app/data-model-interface/tests",
"${chip_root}/src/access/tests",
"${chip_root}/src/crypto/tests",
Expand Down
24 changes: 16 additions & 8 deletions src/app/data-model/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,20 @@
# limitations under the License.
import("//build_overrides/chip.gni")

source_set("nullable") {
sources = [
"NullObject.h",
"Nullable.h",
]

public_deps = [
"${chip_root}/src/app/util:nullable-primitives",
"${chip_root}/src/lib/core",
"${chip_root}/src/lib/core:error",
"${chip_root}/src/lib/support",
]
}

source_set("data-model") {
sources = [
"BasicTypes.h",
Expand All @@ -24,26 +38,20 @@ source_set("data-model") {
"FabricScopedPreEncodedValue.cpp",
"FabricScopedPreEncodedValue.h",
"List.h",
"NullObject.h",
"Nullable.h",
"PreEncodedValue.cpp",
"PreEncodedValue.h",
"WrappedStructEncoder.h",
]

deps = [
# TODO: dependencies NOT declared because they are not part of
# any GN dependency. Overall src/app seems to suffer greatly
# of this, in part due to zap-generated code dependency.
#
# - app/util/attribute-storage-null-handling.h
#
"${chip_root}/src/app:paths",
"${chip_root}/src/app/common:enums",
"${chip_root}/src/lib/core",
"${chip_root}/src/lib/support",
"${chip_root}/src/protocols/interaction_model",
]

public_deps = [ ":nullable" ]
}

# Provides extensions that use heap and should be
Expand Down
29 changes: 29 additions & 0 deletions src/app/data-model/tests/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# 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")
import("${chip_root}/build/chip/chip_test_suite.gni")

chip_test_suite("tests") {
output_name = "libAppDataModelTests"

test_sources = [ "TestNullable.cpp" ]

public_deps = [
"${chip_root}/src/app/data-model:nullable",
"${chip_root}/src/lib/core:error",
"${chip_root}/src/lib/core:string-builder-adapters",
"${chip_root}/src/lib/support/tests:pw-test-macros",
]
}
File renamed without changes.
1 change: 0 additions & 1 deletion src/app/tests/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ chip_test_suite("tests") {
"TestFabricScopedEventLogging.cpp",
"TestInteractionModelEngine.cpp",
"TestMessageDef.cpp",
"TestNullable.cpp",
"TestNumericAttributeTraits.cpp",
"TestOperationalStateClusterObjects.cpp",
"TestPendingNotificationMap.cpp",
Expand Down
17 changes: 15 additions & 2 deletions src/app/util/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,35 @@
import("//build_overrides/chip.gni")
import("${chip_root}/src/app/common_flags.gni")

source_set("nullable-primitives") {
sources = [
"attribute-storage-null-handling.h",
"odd-sized-integers.h",
]

deps = [
"${chip_root}/src/lib/core",
"${chip_root}/src/lib/core:encoding",
"${chip_root}/src/lib/core:types",
]
public_configs = [ "${chip_root}/src:includes" ]
}

# These headers/cpp only depend on core/common
source_set("types") {
sources = [
"att-storage.h",
"attribute-metadata.cpp",
"attribute-metadata.h",
"attribute-storage-null-handling.h",
"basic-types.h",
"ember-strings.cpp",
"ember-strings.h",
"endpoint-config-defines.h",
"odd-sized-integers.h",
"types_stub.h",
]

deps = [
":nullable-primitives",
"${chip_root}/src/app/common:attribute-type",
"${chip_root}/src/lib/core",
"${chip_root}/src/lib/core:encoding",
Expand Down
2 changes: 1 addition & 1 deletion src/controller/tests/data_model/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import("${chip_root}/build/chip/chip_test_suite.gni")
import("${chip_root}/src/platform/device.gni")

chip_test_suite("data_model") {
output_name = "libDataModelTests"
output_name = "libControllerDataModelTests"

sources = [
"DataModelFixtures.cpp",
Expand Down
3 changes: 2 additions & 1 deletion src/test_driver/openiotsdk/unit-tests/test_components.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ SupportTests
UserDirectedCommissioningTests
SecureChannelTests
ICDServerTests
DataModelTests
ControllerDataModelTests
AppDataModelTests
InetLayerTests
AppTests
MessagingLayerTests

0 comments on commit 1794004

Please sign in to comment.