Skip to content

Commit

Permalink
[Matter.framework] Move various #define to src/platform/Darwin/CHIPPl…
Browse files Browse the repository at this point in the history
…atformConfig.h by defautl instead of relying on CHIPProjectAppConfig.h
  • Loading branch information
vivien-apple committed Oct 21, 2024
1 parent 605e3f5 commit d5ca4ab
Show file tree
Hide file tree
Showing 9 changed files with 82 additions and 57 deletions.
24 changes: 0 additions & 24 deletions config/ios/CHIPProjectConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,4 @@
*/
#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 */
5 changes: 0 additions & 5 deletions config/ios/args.gni
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,4 @@

import("//build_overrides/chip.gni")

chip_system_config_clock = "gettimeofday"
chip_device_platform = "darwin"

chip_project_config_include_dirs = [ "${chip_root}/config/ios" ]

pw_build_PIP_CONSTRAINTS = [ "${chip_root}/scripts/setup/constraints.txt" ]
11 changes: 0 additions & 11 deletions examples/darwin-framework-tool/args.gni
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,3 @@
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" ]
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2023 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.
Expand All @@ -16,16 +17,9 @@

/**
* @file
* Project configuration for Darwin Framework Tool.
* CHIP project configuration for standalone builds.
*
*/
#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 */
25 changes: 25 additions & 0 deletions src/darwin/Framework/CHIP/include/SystemProjectConfig.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
*
* 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.
*/

/**
* @file
* chip::System project configuration for standalone builds.
*
*/
#ifndef SYSTEMPROJECTCONFIG_H
#define SYSTEMPROJECTCONFIG_H
#endif /* SYSTEMPROJECTCONFIG_H */
26 changes: 22 additions & 4 deletions src/darwin/Framework/Matter.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,8 @@
B2E0D7B7245B0B5C003C5B48 /* MTRQRCodeSetupPayloadParser.mm in Sources */ = {isa = PBXBuildFile; fileRef = B2E0D7AE245B0B5C003C5B48 /* MTRQRCodeSetupPayloadParser.mm */; };
B2E0D7B8245B0B5C003C5B48 /* MTRSetupPayload.h in Headers */ = {isa = PBXBuildFile; fileRef = B2E0D7AF245B0B5C003C5B48 /* MTRSetupPayload.h */; settings = {ATTRIBUTES = (Public, ); }; };
B2E0D7B9245B0B5C003C5B48 /* MTRSetupPayload.mm in Sources */ = {isa = PBXBuildFile; fileRef = B2E0D7B0245B0B5C003C5B48 /* MTRSetupPayload.mm */; };
B409D0A82CC6B23F00A7ED5A /* CHIPProjectConfig.h in Headers */ = {isa = PBXBuildFile; fileRef = B409D0A52CC6B23F00A7ED5A /* CHIPProjectConfig.h */; };
B409D0A92CC6B23F00A7ED5A /* SystemProjectConfig.h in Headers */ = {isa = PBXBuildFile; fileRef = B409D0A62CC6B23F00A7ED5A /* SystemProjectConfig.h */; };
B43B39EA2CB859A5006AA284 /* DumpMemoryGraphCommand.mm in Sources */ = {isa = PBXBuildFile; fileRef = B43B39E62CB859A5006AA284 /* DumpMemoryGraphCommand.mm */; };
B43B39EB2CB859A5006AA284 /* LeaksTool.mm in Sources */ = {isa = PBXBuildFile; fileRef = B43B39E82CB859A5006AA284 /* LeaksTool.mm */; };
B43B39EC2CB859A5006AA284 /* DumpMemoryGraphCommand.h in Headers */ = {isa = PBXBuildFile; fileRef = B43B39E52CB859A5006AA284 /* DumpMemoryGraphCommand.h */; };
Expand Down Expand Up @@ -798,6 +800,8 @@
B2E0D7AE245B0B5C003C5B48 /* MTRQRCodeSetupPayloadParser.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MTRQRCodeSetupPayloadParser.mm; sourceTree = "<group>"; };
B2E0D7AF245B0B5C003C5B48 /* MTRSetupPayload.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MTRSetupPayload.h; sourceTree = "<group>"; };
B2E0D7B0245B0B5C003C5B48 /* MTRSetupPayload.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MTRSetupPayload.mm; sourceTree = "<group>"; };
B409D0A52CC6B23F00A7ED5A /* CHIPProjectConfig.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CHIPProjectConfig.h; sourceTree = "<group>"; };
B409D0A62CC6B23F00A7ED5A /* SystemProjectConfig.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SystemProjectConfig.h; sourceTree = "<group>"; };
B43B39E42CB859A5006AA284 /* Commands.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Commands.h; sourceTree = "<group>"; };
B43B39E52CB859A5006AA284 /* DumpMemoryGraphCommand.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DumpMemoryGraphCommand.h; sourceTree = "<group>"; };
B43B39E62CB859A5006AA284 /* DumpMemoryGraphCommand.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = DumpMemoryGraphCommand.mm; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1313,6 +1317,7 @@
B202528F2459E34F00F97062 /* CHIP */ = {
isa = PBXGroup;
children = (
B409D0A72CC6B23F00A7ED5A /* include */,
D444F9A12C6E8058007761E5 /* XPC Protocol */,
9B231B032C62EF650030EB37 /* MTRDeviceController_Concrete.mm */,
9B0484F42C701154006C2D5F /* MTRDeviceController_Concrete.h */,
Expand Down Expand Up @@ -1531,6 +1536,15 @@
path = CHIPTests;
sourceTree = "<group>";
};
B409D0A72CC6B23F00A7ED5A /* include */ = {
isa = PBXGroup;
children = (
B409D0A52CC6B23F00A7ED5A /* CHIPProjectConfig.h */,
B409D0A62CC6B23F00A7ED5A /* SystemProjectConfig.h */,
);
path = include;
sourceTree = "<group>";
};
B43B39E92CB859A5006AA284 /* memory */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -1769,6 +1783,8 @@
B2E0D7B2245B0B5C003C5B48 /* MTRManualSetupPayloadParser.h in Headers */,
3CF134A7289D8ADA0017A19E /* MTRCSRInfo.h in Headers */,
88E07D612B9A89A4005FD53E /* MTRMetricKeys.h in Headers */,
B409D0A82CC6B23F00A7ED5A /* CHIPProjectConfig.h in Headers */,
B409D0A92CC6B23F00A7ED5A /* SystemProjectConfig.h in Headers */,
3D4733B32BE2D1DA003DC19B /* MTRUtilities.h in Headers */,
B2E0D7B1245B0B5C003C5B48 /* Matter.h in Headers */,
7596A84428762729004DAE0E /* MTRDevice.h in Headers */,
Expand Down Expand Up @@ -2252,12 +2268,12 @@
"HEADER_SEARCH_PATHS[arch=*]" = (
"$(CHIP_ROOT)/examples/darwin-framework-tool",
"$(CHIP_ROOT)/src",
"$(CHIP_ROOT)/src/darwin/Framework/CHIP/include",
"$(CHIP_ROOT)/third_party/nlassert/repo/include",
"$(CHIP_ROOT)/zzz_generated/app-common",
"$(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",
Expand Down Expand Up @@ -2329,12 +2345,12 @@
"HEADER_SEARCH_PATHS[arch=*]" = (
"$(CHIP_ROOT)/examples//darwin-framework-tool",
"$(CHIP_ROOT)/src",
"$(CHIP_ROOT)/src/darwin/Framework/CHIP/include",
"$(CHIP_ROOT)/third_party/nlassert/repo/include",
"$(CHIP_ROOT)/zzz_generated/darwin-framework-tool",
"$(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",
Expand Down Expand Up @@ -2431,6 +2447,8 @@
"MTR_NO_AVAILABILITY=1",
"MTR_ENABLE_PROVISIONAL=1",
"MTR_ENABLE_UNSTABLE_API=1",
"CONFIG_BUILD_FOR_HOST_UNIT_TEST=1",
"CHIP_DEVICE_CONFIG_ENABLE_TEST_SETUP_PARAMS=1",
);
GCC_SYMBOLS_PRIVATE_EXTERN = YES;
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
Expand Down Expand Up @@ -2526,7 +2544,7 @@
SYSTEM_HEADER_SEARCH_PATHS = (
"$(TEMP_DIR)/out/gen/include",
"$(CHIP_ROOT)/src/darwin/Framework/CHIP/",
"$(CHIP_ROOT)/config/ios",
"$(CHIP_ROOT)/src/darwin/Framework/CHIP/include",
"$(CHIP_ROOT)/src",
"$(CHIP_ROOT)/src/include",
"$(CHIP_ROOT)/zzz_generated/",
Expand Down Expand Up @@ -2698,7 +2716,7 @@
SYSTEM_HEADER_SEARCH_PATHS = (
"$(TEMP_DIR)/out/gen/include",
"$(CHIP_ROOT)/src/darwin/Framework/CHIP/",
"$(CHIP_ROOT)/config/ios",
"$(CHIP_ROOT)/src/darwin/Framework/CHIP/include",
"$(CHIP_ROOT)/src",
"$(CHIP_ROOT)/src/include",
"$(CHIP_ROOT)/zzz_generated/",
Expand Down
4 changes: 3 additions & 1 deletion src/darwin/Framework/chip_xcode_build_connector.sh
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ declare -a args=(
"target_cflags=$(format_gn_list "${target_cflags[@]}")"
"target_cflags_c=$(format_gn_list "${target_cflags_c[@]}")"
"target_cflags_cc=$(format_gn_list "${target_cflags_cc[@]}")"
'chip_project_config_include="<CHIPProjectConfig.h>"'
'chip_system_project_config_include="<SystemProjectConfig.h>"'
"chip_project_config_include_dirs=[\"$PWD/CHIP/include\"]"
)

case "$CONFIGURATION" in
Expand All @@ -132,7 +135,6 @@ esac
[[ $PLATFORM_FAMILY_NAME != macOS ]] && {
args+=(
'target_os="ios"'
'import("//config/ios/args.gni")'
)
}

Expand Down
28 changes: 25 additions & 3 deletions src/platform/Darwin/CHIPPlatformConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

#pragma once

#include <TargetConditionals.h>

// ==================== General Platform Adaptations ====================

#define CHIP_CONFIG_ABORT() abort()
Expand Down Expand Up @@ -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
Expand All @@ -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
4 changes: 4 additions & 0 deletions src/system/system.gni
Original file line number Diff line number Diff line change
Expand Up @@ -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" ||
Expand Down

0 comments on commit d5ca4ab

Please sign in to comment.