From baee8a3f0432f5010cacfdb680c129356044e2b8 Mon Sep 17 00:00:00 2001 From: Vivien Nicolas Date: Mon, 21 Oct 2024 18:46:55 +0200 Subject: [PATCH] [Matter.framework] Move various #define to src/platform/Darwin/CHIPPlatformConfig.h by defautl instead of relying on CHIPProjectAppConfig.h --- config/{ios => darwin}/args.gni | 6 +-- config/ios/CHIPProjectConfig.h | 52 ------------------- config/ios/SystemProjectConfig.h | 26 ---------- examples/darwin-framework-tool/args.gni | 13 +---- .../include/CHIPProjectAppConfig.h | 31 ----------- .../project.pbxproj | 2 - examples/tv-casting-app/darwin/args.gni | 7 +-- .../include/CHIPProjectAppConfig.h | 2 + .../Matter.xcodeproj/project.pbxproj | 4 -- .../Framework/chip_xcode_build_connector.sh | 2 +- src/platform/Darwin/CHIPPlatformConfig.h | 28 ++++++++-- src/system/system.gni | 4 ++ 12 files changed, 38 insertions(+), 139 deletions(-) rename config/{ios => darwin}/args.gni (82%) delete mode 100644 config/ios/CHIPProjectConfig.h delete mode 100644 config/ios/SystemProjectConfig.h delete mode 100644 examples/darwin-framework-tool/include/CHIPProjectAppConfig.h diff --git a/config/ios/args.gni b/config/darwin/args.gni similarity index 82% rename from config/ios/args.gni rename to config/darwin/args.gni index b4426a61a43647..0e9731884040ea 100644 --- a/config/ios/args.gni +++ b/config/darwin/args.gni @@ -1,4 +1,4 @@ -# Copyright (c) 2020 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. @@ -14,9 +14,9 @@ import("//build_overrides/chip.gni") -chip_system_config_clock = "gettimeofday" chip_device_platform = "darwin" -chip_project_config_include_dirs = [ "${chip_root}/config/ios" ] +chip_project_config_include = "" +chip_system_project_config_include = "" pw_build_PIP_CONSTRAINTS = [ "${chip_root}/scripts/setup/constraints.txt" ] diff --git a/config/ios/CHIPProjectConfig.h b/config/ios/CHIPProjectConfig.h deleted file mode 100644 index dfa35f7cfd5254..00000000000000 --- a/config/ios/CHIPProjectConfig.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * - * Copyright (c) 2020-2022 Project CHIP Authors - * Copyright (c) 2016-2017 Nest Labs, Inc. - * Copyright (c) 2019-2020 Google LLC. - * All rights reserved. - * - * 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. - */ - -/** - * @file - * Project-specific configuration file for iOS builds. - * - */ -#ifndef CHIPPROJECTCONFIG_H -#define CHIPPROJECTCONFIG_H - -// Enable UDP listening on demand in the CHIPDeviceController -#define CHIP_CONFIG_DEVICE_CONTROLLER_DEMAND_ENABLE_UDP 1 - -#define INET_CONFIG_OVERRIDE_SYSTEM_TCP_USER_TIMEOUT 0 - -// Uncomment this for a large Tunnel MTU. -//#define CHIP_CONFIG_TUNNEL_INTERFACE_MTU (9000) - -#define CHIP_SYSTEM_CONFIG_PACKETBUFFER_POOL_SIZE 0 - -#define CHIP_CONFIG_DATA_MANAGEMENT_CLIENT_EXPERIMENTAL 1 - -#define CHIP_CONFIG_MAX_SOFTWARE_VERSION_LENGTH 128 - -#ifndef CHIP_CONFIG_KVS_PATH -#define CHIP_CONFIG_KVS_PATH "chip.store" -#endif - -// The session pool size limits how many subscriptions we can have live at -// once. Home supports up to 1000 accessories, and we subscribe to all of them, -// so we need to make sure the pool is big enough for that. -#define CHIP_CONFIG_SECURE_SESSION_POOL_SIZE 1000 - -#endif /* CHIPPROJECTCONFIG_H */ diff --git a/config/ios/SystemProjectConfig.h b/config/ios/SystemProjectConfig.h deleted file mode 100644 index 06d9baaee59492..00000000000000 --- a/config/ios/SystemProjectConfig.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * - * Copyright (c) 2021 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. - */ - -/** - * @file - * chip::System project configuration for standalone builds on iOS - * - */ -#ifndef SYSTEMPROJECTCONFIG_H -#define SYSTEMPROJECTCONFIG_H - -#endif /* SYSTEMPROJECTCONFIG_H */ diff --git a/examples/darwin-framework-tool/args.gni b/examples/darwin-framework-tool/args.gni index 6f0f1010a05f5d..4af7d4a7d19138 100644 --- a/examples/darwin-framework-tool/args.gni +++ b/examples/darwin-framework-tool/args.gni @@ -14,15 +14,4 @@ import("//build_overrides/chip.gni") -import("${chip_root}/config/standalone/args.gni") - -chip_crypto = "boringssl" - -chip_device_project_config_include = - "${chip_root}/examples/darwin-framework-tool/include/CHIPProjectAppConfig.h" -chip_project_config_include = - "${chip_root}/examples/darwin-framework-tool/include/CHIPProjectAppConfig.h" - -chip_project_config_include_dirs = - [ "${chip_root}/examples/darwin-framework-tool/include" ] -chip_project_config_include_dirs += [ "${chip_root}/config/standalone" ] +import("${chip_root}/config/darwin/args.gni") diff --git a/examples/darwin-framework-tool/include/CHIPProjectAppConfig.h b/examples/darwin-framework-tool/include/CHIPProjectAppConfig.h deleted file mode 100644 index 6f1764a52df56b..00000000000000 --- a/examples/darwin-framework-tool/include/CHIPProjectAppConfig.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2023 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. - */ - -/** - * @file - * Project configuration for Darwin Framework Tool. - * - */ -#ifndef CHIPPROJECTCONFIG_H -#define CHIPPROJECTCONFIG_H - -// Enable some test-only interaction model APIs. -#define CONFIG_BUILD_FOR_HOST_UNIT_TEST 1 - -// Allow us, for test purposes, to encode invalid enum values. -#define CHIP_CONFIG_IM_ENABLE_ENCODING_SENTINEL_ENUM_VALUES 1 - -#endif /* CHIPPROJECTCONFIG_H */ diff --git a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge.xcodeproj/project.pbxproj b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge.xcodeproj/project.pbxproj index 28793f5f60b8e7..882961ed913b3d 100644 --- a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge.xcodeproj/project.pbxproj +++ b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge.xcodeproj/project.pbxproj @@ -678,7 +678,6 @@ "$(CHIP_ROOT)/src/include", "$(CHIP_ROOT)/src/lib", "$(CHIP_ROOT)/src/app", - "$(CHIP_ROOT)/config/ios", "$(CHIP_ROOT)/src/app/util", "$(CHIP_ROOT)/third_party/nlassert/repo/include", "$(CHIP_ROOT)/third_party/nlio/repo/include", @@ -759,7 +758,6 @@ "$(CHIP_ROOT)/src/include", "$(CHIP_ROOT)/src/lib", "$(CHIP_ROOT)/src/app", - "$(CHIP_ROOT)/config/ios", "$(CHIP_ROOT)/src/app/util", "$(CHIP_ROOT)/third_party/nlassert/repo/include", "$(CHIP_ROOT)/third_party/nlio/repo/include", diff --git a/examples/tv-casting-app/darwin/args.gni b/examples/tv-casting-app/darwin/args.gni index 1158e98e5f2d99..10b02842ff4764 100644 --- a/examples/tv-casting-app/darwin/args.gni +++ b/examples/tv-casting-app/darwin/args.gni @@ -14,17 +14,14 @@ import("//build_overrides/chip.gni") -import("${chip_root}/config/ios/args.gni") +import("${chip_root}/config/darwin/args.gni") chip_device_project_config_include = "" -chip_project_config_include = "" -chip_system_project_config_include = "" -chip_project_config_include_dirs += [ +chip_project_config_include_dirs = [ "${chip_root}/examples/tv-casting-app/tv-casting-common/include", "${chip_root}/examples/tv-casting-app/tv-casting-common", ] -chip_project_config_include_dirs += [ "${chip_root}/config/ios" ] chip_build_libshell = true diff --git a/examples/tv-casting-app/tv-casting-common/include/CHIPProjectAppConfig.h b/examples/tv-casting-app/tv-casting-common/include/CHIPProjectAppConfig.h index f5887bc3828b08..0e9ccf7d67df19 100644 --- a/examples/tv-casting-app/tv-casting-common/include/CHIPProjectAppConfig.h +++ b/examples/tv-casting-app/tv-casting-common/include/CHIPProjectAppConfig.h @@ -92,4 +92,6 @@ // Include the CHIPProjectConfig from config/standalone // Add this at the end so that we can hit our #defines first +#ifndef CHIP_DEVICE_LAYER_TARGET_DARWIN #include +#endif // CHIP_DEVICE_LAYER_TARGET_DARWIN diff --git a/src/darwin/Framework/Matter.xcodeproj/project.pbxproj b/src/darwin/Framework/Matter.xcodeproj/project.pbxproj index bd05397c05c67e..a08a406778458e 100644 --- a/src/darwin/Framework/Matter.xcodeproj/project.pbxproj +++ b/src/darwin/Framework/Matter.xcodeproj/project.pbxproj @@ -2257,7 +2257,6 @@ "$(CHIP_ROOT)/third_party/nlio/repo/include", "$(CHIP_ROOT)/third_party/jsoncpp/repo/include", "$(CHIP_ROOT)/zzz_generated/darwin-framework-tool", - "$(CHIP_ROOT)/config/ios", "$(CHIP_ROOT)/third_party/editline/repo/include", "$(CHIP_ROOT)/src/include", "$(CONFIGURATION_TEMP_DIR)/Matter.build/out/gen/include", @@ -2334,7 +2333,6 @@ "$(CHIP_ROOT)/zzz_generated/app-common", "$(CHIP_ROOT)/third_party/nlio/repo/include", "$(CHIP_ROOT)/third_party/jsoncpp/repo/include", - "$(CHIP_ROOT)/config/ios", "$(CHIP_ROOT)/third_party/editline/repo/include", "$(CHIP_ROOT)/third_party/libwebsockets", "$(CHIP_ROOT)/third_party/libwebsockets/repo/include", @@ -2526,7 +2524,6 @@ SYSTEM_HEADER_SEARCH_PATHS = ( "$(TEMP_DIR)/out/gen/include", "$(CHIP_ROOT)/src/darwin/Framework/CHIP/", - "$(CHIP_ROOT)/config/ios", "$(CHIP_ROOT)/src", "$(CHIP_ROOT)/src/include", "$(CHIP_ROOT)/zzz_generated/", @@ -2698,7 +2695,6 @@ SYSTEM_HEADER_SEARCH_PATHS = ( "$(TEMP_DIR)/out/gen/include", "$(CHIP_ROOT)/src/darwin/Framework/CHIP/", - "$(CHIP_ROOT)/config/ios", "$(CHIP_ROOT)/src", "$(CHIP_ROOT)/src/include", "$(CHIP_ROOT)/zzz_generated/", diff --git a/src/darwin/Framework/chip_xcode_build_connector.sh b/src/darwin/Framework/chip_xcode_build_connector.sh index 5947ae7dd36490..0c08ab381b32f4 100755 --- a/src/darwin/Framework/chip_xcode_build_connector.sh +++ b/src/darwin/Framework/chip_xcode_build_connector.sh @@ -103,6 +103,7 @@ done [[ $ENABLE_BITCODE == YES ]] && target_cflags+=("-flto") declare -a args=( + 'import("//config/darwin/args.gni")' 'default_configs_cosmetic=[]' # suppress colorization 'chip_crypto="boringssl"' 'chip_build_controller_dynamic_server=false' @@ -132,7 +133,6 @@ esac [[ $PLATFORM_FAMILY_NAME != macOS ]] && { args+=( 'target_os="ios"' - 'import("//config/ios/args.gni")' ) } diff --git a/src/platform/Darwin/CHIPPlatformConfig.h b/src/platform/Darwin/CHIPPlatformConfig.h index d85194aaecb61e..72de356f2d00ee 100644 --- a/src/platform/Darwin/CHIPPlatformConfig.h +++ b/src/platform/Darwin/CHIPPlatformConfig.h @@ -23,6 +23,8 @@ #pragma once +#include + // ==================== General Platform Adaptations ==================== #define CHIP_CONFIG_ABORT() abort() @@ -53,9 +55,16 @@ extern "C" int __cxa_atexit(void (*f)(void *), void * p, void * d); #define CHIP_CONFIG_MAX_UNSOLICITED_MESSAGE_HANDLERS 8 #endif // CHIP_CONFIG_MAX_UNSOLICITED_MESSAGE_HANDLERS -#ifndef CHIP_CONFIG_MAX_EXCHANGE_CONTEXTS -#define CHIP_CONFIG_MAX_EXCHANGE_CONTEXTS 8 -#endif // CHIP_CONFIG_MAX_EXCHANGE_CONTEXTS +// +// Default of 8 ECs is not sufficient for some of the unit tests +// that try to validate multiple simultaneous interactions. +// In tests like TestReadHandler_MultipleSubscriptions, we are trying to issue as many read / subscription requests as possible in +// parallel. Since the default config says we support 16 fabrics, and we will have 4 read handlers for each fabric (3 subscriptions +// + 1 reserved for read) that is read transactions in parallel. Since the report handlers are allocated on the heap, we will issue +// 65 requests (the TestReadHandler_MultipleSubscriptions will issue CHIP_IM_MAX_NUM_READ_HANDLER + 1 subscriptions to verify heap +// allocation logic) in total and that is 130 ECs. Round this up to 150 ECs +// +#define CHIP_CONFIG_MAX_EXCHANGE_CONTEXTS 150 #ifndef CHIP_LOG_FILTERING #define CHIP_LOG_FILTERING 1 @@ -66,5 +75,18 @@ extern "C" int __cxa_atexit(void (*f)(void *), void * p, void * d); #endif // CHIP_CONFIG_BDX_MAX_NUM_TRANSFERS #ifndef CHIP_CONFIG_KVS_PATH +#if TARGET_OS_IPHONE +#define CHIP_CONFIG_KVS_PATH "chip.store" +#else #define CHIP_CONFIG_KVS_PATH "/tmp/chip_kvs" +#endif // TARGET_OS_IPHONE #endif // CHIP_CONFIG_KVS_PATH + +#define CHIP_SYSTEM_CONFIG_PACKETBUFFER_POOL_SIZE 0 + +// The session pool size limits how many subscriptions we can have live at +// once. Home supports up to 1000 accessories, and we subscribe to all of them, +// so we need to make sure the pool is big enough for that. +#define CHIP_CONFIG_SECURE_SESSION_POOL_SIZE 1000 + +#define INET_CONFIG_OVERRIDE_SYSTEM_TCP_USER_TIMEOUT 0 diff --git a/src/system/system.gni b/src/system/system.gni index 61efb846d89839..61cd52fa320245 100644 --- a/src/system/system.gni +++ b/src/system/system.gni @@ -71,6 +71,10 @@ if (chip_system_config_locking == "") { } } +if (target_os == "mac" || target_os == "ios") { + chip_system_config_clock = "gettimeofday" +} + assert( chip_system_config_locking == "posix" || chip_system_config_locking == "freertos" ||