Add "orphaned" header files from src/lib/support into gn (#31807)
* Restyle
* A few comment updates
* Move testing library into nlunittest location
* Restyle
* Remove dependency from support into data-model: place CHIPListUtils into data-model and adjust the name to not use UTILS as a name
* Restyle
* Zap regen to force reformat
* zap regen again
diff --git a/examples/placeholder/templates/tests-commands.zapt b/examples/placeholder/templates/tests-commands.zapt
index c1d8741..be0474f 100644
--- a/examples/placeholder/templates/tests-commands.zapt
+++ b/examples/placeholder/templates/tests-commands.zapt
@@ -4,7 +4,7 @@
#include "TestCommand.h"
-#include <lib/support/CHIPListUtils.h>
+#include <app/data-model/ListLargeSystemExtensions.h>
{{>test_cluster tests="../linux/apps/app1/ciTests.json" credsIssuerConfigArg=false needsWaitDuration=false}}
diff --git a/examples/tv-casting-app/android/App/app/src/main/jni/cpp/TvCastingApp-JNI.cpp b/examples/tv-casting-app/android/App/app/src/main/jni/cpp/TvCastingApp-JNI.cpp
index 0d49396..0cbfab8 100644
--- a/examples/tv-casting-app/android/App/app/src/main/jni/cpp/TvCastingApp-JNI.cpp
+++ b/examples/tv-casting-app/android/App/app/src/main/jni/cpp/TvCastingApp-JNI.cpp
@@ -22,6 +22,7 @@
#include "ConversionUtils.h"
#include "JNIDACProvider.h"
+#include <app/data-model/ListLargeSystemExtensions.h>
#include <app/server/Server.h>
#include <app/server/java/AndroidAppServerWrapper.h>
#include <credentials/DeviceAttestationCredsProvider.h>
@@ -32,7 +33,6 @@
#include <lib/core/Optional.h>
#include <lib/dnssd/Resolver.h>
#include <lib/support/CHIPJNIError.h>
-#include <lib/support/CHIPListUtils.h>
#include <lib/support/JniReferences.h>
#include <lib/support/JniTypeWrappers.h>
diff --git a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/CastingServerBridge.mm b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/CastingServerBridge.mm
index b19d720..86a1976 100644
--- a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/CastingServerBridge.mm
+++ b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/CastingServerBridge.mm
@@ -25,10 +25,10 @@
#import "MatterCallbacks.h"
#import "OnboardingPayload.h"
+#include <app/data-model/ListLargeSystemExtensions.h>
#include <credentials/DeviceAttestationCredsProvider.h>
#include <credentials/attestation_verifier/DefaultDeviceAttestationVerifier.h>
#include <credentials/attestation_verifier/DeviceAttestationVerifier.h>
-#include <lib/support/CHIPListUtils.h>
#include <lib/support/CHIPMem.h>
#include <platform/PlatformManager.h>
diff --git a/scripts/tools/check_includes_config.py b/scripts/tools/check_includes_config.py
index abe2c0e..b4e933f 100644
--- a/scripts/tools/check_includes_config.py
+++ b/scripts/tools/check_includes_config.py
@@ -93,7 +93,7 @@
'vector',
# CHIP headers using STL containers.
- 'lib/support/CHIPListUtils.h', # uses std::set
+ 'app/data-model/ListLargeSystemExtensions.h', # uses std::set
'src/platform/DeviceSafeQueue.h', # uses std::deque
}
@@ -113,7 +113,7 @@
'src/lib/support/IniEscaping.h': {'string'},
# Itself in DENY.
- 'src/lib/support/CHIPListUtils.h': {'set'},
+ 'src/app/data-model/ListLargeSystemExtensions.h': {'set'},
'src/platform/DeviceSafeQueue.h': {'queue'},
# Only uses <chrono> for zero-cost types.
diff --git a/src/lib/support/CHIPListUtils.h b/src/app/data-model/ListLargeSystemExtensions.h
similarity index 89%
rename from src/lib/support/CHIPListUtils.h
rename to src/app/data-model/ListLargeSystemExtensions.h
index 95e063a..fca49dd 100644
--- a/src/lib/support/CHIPListUtils.h
+++ b/src/app/data-model/ListLargeSystemExtensions.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright (c) 2021 Project CHIP Authors
+ * 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.
@@ -15,10 +15,12 @@
* limitations under the License.
*/
-#ifndef CHIP_LISTUTILS_INTERNAL_H
-#define CHIP_LISTUTILS_INTERNAL_H
+#pragma once
+// NOTE: Functionality in this class uses HEAP and std::set. It is generally
+// intended for large systems only
#include <app/data-model/List.h>
+
#include <set>
#include <type_traits>
@@ -27,6 +29,7 @@
struct ListMemberTypeGetter
{
};
+
template <typename T>
struct ListMemberTypeGetter<chip::app::DataModel::List<T>>
{
@@ -63,5 +66,3 @@
std::set<ListHolderBase *> mListHolders;
};
-
-#endif /* CHIP_LISTUTILS_INTERNAL_H */
diff --git a/src/app/server/BUILD.gn b/src/app/server/BUILD.gn
index 690da23..7e44151 100644
--- a/src/app/server/BUILD.gn
+++ b/src/app/server/BUILD.gn
@@ -62,6 +62,11 @@
"${chip_root}/src/transport",
]
+ # TODO: Server.cpp uses TestGroupData.h. Unsure why test code would be in such a central place
+ # This dependency is split since it should probably be removed (or naming should
+ # be updated if this is not really "testing" even though headers are Test*.h)
+ public_deps += [ "${chip_root}/src/lib/support:testing" ]
+
if (chip_enable_icd_server) {
public_deps += [ "${chip_root}/src/app/icd/server:notifier" ]
}
diff --git a/src/app/tests/BUILD.gn b/src/app/tests/BUILD.gn
index 88311e2..245e939 100644
--- a/src/app/tests/BUILD.gn
+++ b/src/app/tests/BUILD.gn
@@ -213,6 +213,7 @@
"${chip_root}/src/app/util/mock:mock_ember",
"${chip_root}/src/lib/core",
"${chip_root}/src/lib/support:test_utils",
+ "${chip_root}/src/lib/support:testing",
"${chip_root}/src/lib/support:testing_nlunit",
"${nlunit_test_root}:nlunit-test",
]
diff --git a/src/controller/BUILD.gn b/src/controller/BUILD.gn
index 435e405..9742bf0 100644
--- a/src/controller/BUILD.gn
+++ b/src/controller/BUILD.gn
@@ -81,5 +81,10 @@
deps = [ "${chip_root}/src/lib/address_resolve" ]
+ if (chip_controller && chip_build_controller) {
+ # ExampleOperationalCredentialsIssuer uses TestGroupData
+ deps += [ "${chip_root}/src/lib/support:testing" ]
+ }
+
defines = []
}
diff --git a/src/controller/python/BUILD.gn b/src/controller/python/BUILD.gn
index c8d2ac3..e14b712 100644
--- a/src/controller/python/BUILD.gn
+++ b/src/controller/python/BUILD.gn
@@ -130,6 +130,7 @@
public_deps += [
"${chip_root}/src/controller/data_model",
"${chip_root}/src/credentials:file_attestation_trust_store",
+ "${chip_root}/src/lib/support:testing",
"${chip_root}/src/tracing/json",
"${chip_root}/src/tracing/perfetto",
"${chip_root}/src/tracing/perfetto:file_output",
diff --git a/src/credentials/tests/BUILD.gn b/src/credentials/tests/BUILD.gn
index 101abc3..3b04582 100644
--- a/src/credentials/tests/BUILD.gn
+++ b/src/credentials/tests/BUILD.gn
@@ -70,6 +70,7 @@
"${chip_root}/src/credentials",
"${chip_root}/src/credentials:default_attestation_verifier",
"${chip_root}/src/lib/core",
+ "${chip_root}/src/lib/support:testing",
"${chip_root}/src/lib/support:testing_nlunit",
"${nlunit_test_root}:nlunit-test",
]
diff --git a/src/crypto/tests/BUILD.gn b/src/crypto/tests/BUILD.gn
index 55fc502..1599b94 100644
--- a/src/crypto/tests/BUILD.gn
+++ b/src/crypto/tests/BUILD.gn
@@ -69,6 +69,7 @@
"${chip_root}/src/credentials/tests:cert_test_vectors",
"${chip_root}/src/crypto",
"${chip_root}/src/lib/core",
+ "${chip_root}/src/lib/support:testing",
"${chip_root}/src/lib/support:testing_nlunit",
"${chip_root}/src/platform",
"${nlunit_test_root}:nlunit-test",
diff --git a/src/darwin/Framework/CHIP/templates/MTRBaseClusters-src.zapt b/src/darwin/Framework/CHIP/templates/MTRBaseClusters-src.zapt
index de92791..9d6e786 100644
--- a/src/darwin/Framework/CHIP/templates/MTRBaseClusters-src.zapt
+++ b/src/darwin/Framework/CHIP/templates/MTRBaseClusters-src.zapt
@@ -17,7 +17,7 @@
#include <app-common/zap-generated/cluster-objects.h>
#include <app/util/im-client-callbacks.h>
#include <controller/CHIPCluster.h>
-#include <lib/support/CHIPListUtils.h>
+#include <app/data-model/ListLargeSystemExtensions.h>
#include <platform/CHIPDeviceLayer.h>
#include <type_traits>
diff --git a/src/darwin/Framework/CHIP/templates/MTRCommandPayloadsObjc-src.zapt b/src/darwin/Framework/CHIP/templates/MTRCommandPayloadsObjc-src.zapt
index c58c75f..783fe2a 100644
--- a/src/darwin/Framework/CHIP/templates/MTRCommandPayloadsObjc-src.zapt
+++ b/src/darwin/Framework/CHIP/templates/MTRCommandPayloadsObjc-src.zapt
@@ -12,7 +12,7 @@
#include <app/data-model/Decode.h>
#include <lib/core/TLV.h>
-#include <lib/support/CHIPListUtils.h>
+#include <app/data-model/ListLargeSystemExtensions.h>
#include <lib/support/CodeUtils.h>
#include <system/TLVPacketBufferBackingStore.h>
diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.mm b/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.mm
index cdb3a18..9900b52 100644
--- a/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.mm
+++ b/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.mm
@@ -30,9 +30,9 @@
#import "NSStringSpanConversion.h"
#include <app-common/zap-generated/cluster-objects.h>
+#include <app/data-model/ListLargeSystemExtensions.h>
#include <app/util/im-client-callbacks.h>
#include <controller/CHIPCluster.h>
-#include <lib/support/CHIPListUtils.h>
#include <platform/CHIPDeviceLayer.h>
#include <type_traits>
diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.mm b/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.mm
index 6e7f500..0e172b2 100644
--- a/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.mm
+++ b/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.mm
@@ -26,8 +26,8 @@
#import "NSStringSpanConversion.h"
#include <app/data-model/Decode.h>
+#include <app/data-model/ListLargeSystemExtensions.h>
#include <lib/core/TLV.h>
-#include <lib/support/CHIPListUtils.h>
#include <lib/support/CodeUtils.h>
#include <system/TLVPacketBufferBackingStore.h>
diff --git a/src/lib/core/BUILD.gn b/src/lib/core/BUILD.gn
index eb66f46..2761137 100644
--- a/src/lib/core/BUILD.gn
+++ b/src/lib/core/BUILD.gn
@@ -101,6 +101,7 @@
public_deps = [
":chip_config_header",
"${chip_root}/src/lib/support:attributes",
+ "${chip_root}/src/lib/support:type-traits",
]
}
diff --git a/src/lib/support/BUILD.gn b/src/lib/support/BUILD.gn
index 410f3be..3e42674 100644
--- a/src/lib/support/BUILD.gn
+++ b/src/lib/support/BUILD.gn
@@ -160,6 +160,17 @@
deps = [ ":gen_chip_version" ]
}
+source_set("testing") {
+ sources = [
+ "TestGroupData.h",
+ "TestPersistentStorageDelegate.h",
+ ]
+}
+
+source_set("type-traits") {
+ sources = [ "TypeTraits.h" ]
+}
+
static_library("support") {
output_name = "libSupportLayer"
@@ -179,6 +190,8 @@
"CHIPArgParser.cpp",
"CHIPCounter.h",
"CHIPMemString.h",
+ "CommonIterator.h",
+ "CommonPersistentData.h",
"DLLUtil.h",
"DefaultStorageKeyAllocator.h",
"Defer.h",
@@ -186,21 +199,31 @@
"FibonacciUtils.h",
"FixedBufferAllocator.cpp",
"FixedBufferAllocator.h",
+ "Fold.h",
+ "FunctionTraits.h",
"IniEscaping.cpp",
"IniEscaping.h",
+ "IntrusiveList.h",
"Iterators.h",
+ "LambdaBridge.h",
"LifetimePersistedCounter.h",
"ObjectLifeCycle.h",
+ "OwnerOf.h",
"PersistedCounter.h",
+ "PersistentData.h",
"PersistentStorageAudit.cpp",
"PersistentStorageAudit.h",
"PersistentStorageMacros.h",
"Pool.cpp",
"Pool.h",
+ "PoolWrapper.h",
"PrivateHeap.cpp",
"PrivateHeap.h",
"ReferenceCountedHandle.h",
+ "SafePointerCast.h",
+ "SafeString.h",
"Scoped.h",
+ "ScopedBuffer.h",
"SerializableIntegerSet.cpp",
"SerializableIntegerSet.h",
"SetupDiscriminator.h",
@@ -252,6 +275,7 @@
":safeint",
":span",
":text_only_logging",
+ ":type-traits",
":verifymacros",
":verifymacros_no_logging",
"${chip_root}/src/lib/core:chip_config_header",
@@ -335,6 +359,7 @@
output_dir = "${root_out_dir}/lib"
sources = [
+ "UnitTestContext.h",
"UnitTestExtendedAssertions.h",
"UnitTestRegistration.cpp",
"UnitTestRegistration.h",
diff --git a/src/lib/support/tests/BUILD.gn b/src/lib/support/tests/BUILD.gn
index 7a3b738..d0b91fe 100644
--- a/src/lib/support/tests/BUILD.gn
+++ b/src/lib/support/tests/BUILD.gn
@@ -79,6 +79,7 @@
public_deps = [
"${chip_root}/src/credentials",
"${chip_root}/src/lib/core",
+ "${chip_root}/src/lib/support:testing",
"${chip_root}/src/lib/support:testing_nlunit",
"${chip_root}/src/lib/support/jsontlv",
"${chip_root}/src/platform",
diff --git a/src/messaging/tests/BUILD.gn b/src/messaging/tests/BUILD.gn
index b3f41b6..b6f1dcb 100644
--- a/src/messaging/tests/BUILD.gn
+++ b/src/messaging/tests/BUILD.gn
@@ -32,6 +32,7 @@
deps = [
"${chip_root}/src/credentials/tests:cert_test_vectors",
+ "${chip_root}/src/lib/support:testing",
"${chip_root}/src/messaging",
"${chip_root}/src/protocols",
"${chip_root}/src/transport",
diff --git a/src/protocols/secure_channel/BUILD.gn b/src/protocols/secure_channel/BUILD.gn
index 2061b04..f596345 100644
--- a/src/protocols/secure_channel/BUILD.gn
+++ b/src/protocols/secure_channel/BUILD.gn
@@ -12,6 +12,7 @@
cflags = [ "-Wconversion" ]
public_deps = [
+ "${chip_root}/src/lib/support:type-traits",
"${chip_root}/src/protocols:type_definitions",
"${chip_root}/src/system",
]
@@ -55,6 +56,7 @@
"${chip_root}/src/crypto",
"${chip_root}/src/lib/core",
"${chip_root}/src/lib/support",
+ "${chip_root}/src/lib/support:type-traits",
"${chip_root}/src/messaging",
"${chip_root}/src/system",
"${chip_root}/src/tracing",
diff --git a/src/protocols/secure_channel/tests/BUILD.gn b/src/protocols/secure_channel/tests/BUILD.gn
index b77fb69..9a0ec76 100644
--- a/src/protocols/secure_channel/tests/BUILD.gn
+++ b/src/protocols/secure_channel/tests/BUILD.gn
@@ -29,6 +29,7 @@
"${chip_root}/src/lib/core",
"${chip_root}/src/lib/support",
"${chip_root}/src/lib/support:test_utils",
+ "${chip_root}/src/lib/support:testing",
"${chip_root}/src/lib/support:testing_nlunit",
"${chip_root}/src/messaging/tests:helpers",
"${chip_root}/src/protocols",
diff --git a/src/transport/raw/BUILD.gn b/src/transport/raw/BUILD.gn
index ae3aeb5..736b16c 100644
--- a/src/transport/raw/BUILD.gn
+++ b/src/transport/raw/BUILD.gn
@@ -44,6 +44,7 @@
"${chip_root}/src/inet",
"${chip_root}/src/lib/core",
"${chip_root}/src/lib/support",
+ "${chip_root}/src/lib/support:type-traits",
"${chip_root}/src/platform",
]
}
diff --git a/src/transport/tests/BUILD.gn b/src/transport/tests/BUILD.gn
index 6f454f4..057065a 100644
--- a/src/transport/tests/BUILD.gn
+++ b/src/transport/tests/BUILD.gn
@@ -54,6 +54,7 @@
"${chip_root}/src/inet/tests:helpers",
"${chip_root}/src/lib/core",
"${chip_root}/src/lib/support",
+ "${chip_root}/src/lib/support:testing",
"${chip_root}/src/lib/support:testing_nlunit",
"${chip_root}/src/protocols",
"${chip_root}/src/transport",
diff --git a/zzz_generated/placeholder/app1/zap-generated/test/Commands.h b/zzz_generated/placeholder/app1/zap-generated/test/Commands.h
index 35de801..fd7e5da 100644
--- a/zzz_generated/placeholder/app1/zap-generated/test/Commands.h
+++ b/zzz_generated/placeholder/app1/zap-generated/test/Commands.h
@@ -21,7 +21,7 @@
#include "TestCommand.h"
-#include <lib/support/CHIPListUtils.h>
+#include <app/data-model/ListLargeSystemExtensions.h>
class Test_TC_WNCV_5_1_SimulatedSuite : public TestCommand
{
diff --git a/zzz_generated/placeholder/app2/zap-generated/test/Commands.h b/zzz_generated/placeholder/app2/zap-generated/test/Commands.h
index 35de801..fd7e5da 100644
--- a/zzz_generated/placeholder/app2/zap-generated/test/Commands.h
+++ b/zzz_generated/placeholder/app2/zap-generated/test/Commands.h
@@ -21,7 +21,7 @@
#include "TestCommand.h"
-#include <lib/support/CHIPListUtils.h>
+#include <app/data-model/ListLargeSystemExtensions.h>
class Test_TC_WNCV_5_1_SimulatedSuite : public TestCommand
{