Skip to content

Commit 395a613

Browse files
Split the targets for nullable support (#34198)
* 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 <commits@restyled.io>
1 parent 76d68c1 commit 395a613

File tree

9 files changed

+66
-14
lines changed

9 files changed

+66
-14
lines changed

docs/guides/openiotsdk_unit_tests.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,14 @@ The list of currently supported Matter's component tests:
2020

2121
```
2222
accesstest
23+
AppDataModelTests
2324
AppTests
2425
ASN1Tests
2526
BDXTests
2627
ChipCryptoTests
28+
ControllerDataModelTests
2729
CoreTests
2830
CredentialsTest
29-
DataModelTests
3031
ICDServerTests
3132
InetLayerTests
3233
MdnsTests

src/BUILD.gn

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ if (chip_build_tests) {
5050
chip_test_group("tests") {
5151
deps = []
5252
tests = [
53+
"${chip_root}/src/app/data-model/tests",
5354
"${chip_root}/src/app/data-model-interface/tests",
5455
"${chip_root}/src/access/tests",
5556
"${chip_root}/src/crypto/tests",

src/app/data-model/BUILD.gn

+16-8
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,20 @@
1313
# limitations under the License.
1414
import("//build_overrides/chip.gni")
1515

16+
source_set("nullable") {
17+
sources = [
18+
"NullObject.h",
19+
"Nullable.h",
20+
]
21+
22+
public_deps = [
23+
"${chip_root}/src/app/util:nullable-primitives",
24+
"${chip_root}/src/lib/core",
25+
"${chip_root}/src/lib/core:error",
26+
"${chip_root}/src/lib/support",
27+
]
28+
}
29+
1630
source_set("data-model") {
1731
sources = [
1832
"BasicTypes.h",
@@ -24,26 +38,20 @@ source_set("data-model") {
2438
"FabricScopedPreEncodedValue.cpp",
2539
"FabricScopedPreEncodedValue.h",
2640
"List.h",
27-
"NullObject.h",
28-
"Nullable.h",
2941
"PreEncodedValue.cpp",
3042
"PreEncodedValue.h",
3143
"WrappedStructEncoder.h",
3244
]
3345

3446
deps = [
35-
# TODO: dependencies NOT declared because they are not part of
36-
# any GN dependency. Overall src/app seems to suffer greatly
37-
# of this, in part due to zap-generated code dependency.
38-
#
39-
# - app/util/attribute-storage-null-handling.h
40-
#
4147
"${chip_root}/src/app:paths",
4248
"${chip_root}/src/app/common:enums",
4349
"${chip_root}/src/lib/core",
4450
"${chip_root}/src/lib/support",
4551
"${chip_root}/src/protocols/interaction_model",
4652
]
53+
54+
public_deps = [ ":nullable" ]
4755
}
4856

4957
# Provides extensions that use heap and should be

src/app/data-model/tests/BUILD.gn

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Copyright (c) 2024 Project CHIP Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import("//build_overrides/chip.gni")
16+
import("${chip_root}/build/chip/chip_test_suite.gni")
17+
18+
chip_test_suite("tests") {
19+
output_name = "libAppDataModelTests"
20+
21+
test_sources = [ "TestNullable.cpp" ]
22+
23+
public_deps = [
24+
"${chip_root}/src/app/data-model:nullable",
25+
"${chip_root}/src/lib/core:error",
26+
"${chip_root}/src/lib/core:string-builder-adapters",
27+
"${chip_root}/src/lib/support/tests:pw-test-macros",
28+
]
29+
}
File renamed without changes.

src/app/tests/BUILD.gn

-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,6 @@ chip_test_suite("tests") {
162162
"TestFabricScopedEventLogging.cpp",
163163
"TestInteractionModelEngine.cpp",
164164
"TestMessageDef.cpp",
165-
"TestNullable.cpp",
166165
"TestNumericAttributeTraits.cpp",
167166
"TestOperationalStateClusterObjects.cpp",
168167
"TestPendingNotificationMap.cpp",

src/app/util/BUILD.gn

+15-2
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,35 @@
1515
import("//build_overrides/chip.gni")
1616
import("${chip_root}/src/app/common_flags.gni")
1717

18+
source_set("nullable-primitives") {
19+
sources = [
20+
"attribute-storage-null-handling.h",
21+
"odd-sized-integers.h",
22+
]
23+
24+
deps = [
25+
"${chip_root}/src/lib/core",
26+
"${chip_root}/src/lib/core:encoding",
27+
"${chip_root}/src/lib/core:types",
28+
]
29+
public_configs = [ "${chip_root}/src:includes" ]
30+
}
31+
1832
# These headers/cpp only depend on core/common
1933
source_set("types") {
2034
sources = [
2135
"att-storage.h",
2236
"attribute-metadata.cpp",
2337
"attribute-metadata.h",
24-
"attribute-storage-null-handling.h",
2538
"basic-types.h",
2639
"ember-strings.cpp",
2740
"ember-strings.h",
2841
"endpoint-config-defines.h",
29-
"odd-sized-integers.h",
3042
"types_stub.h",
3143
]
3244

3345
deps = [
46+
":nullable-primitives",
3447
"${chip_root}/src/app/common:attribute-type",
3548
"${chip_root}/src/lib/core",
3649
"${chip_root}/src/lib/core:encoding",

src/controller/tests/data_model/BUILD.gn

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import("${chip_root}/build/chip/chip_test_suite.gni")
2020
import("${chip_root}/src/platform/device.gni")
2121

2222
chip_test_suite("data_model") {
23-
output_name = "libDataModelTests"
23+
output_name = "libControllerDataModelTests"
2424

2525
sources = [
2626
"DataModelFixtures.cpp",

src/test_driver/openiotsdk/unit-tests/test_components.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ SupportTests
1818
UserDirectedCommissioningTests
1919
SecureChannelTests
2020
ICDServerTests
21-
DataModelTests
21+
ControllerDataModelTests
22+
AppDataModelTests
2223
InetLayerTests
2324
AppTests
2425
MessagingLayerTests

0 commit comments

Comments
 (0)