Skip to content

Commit 1108091

Browse files
mspangpull[bot]
authored andcommitted
Use generated headers consistently on darwin (#11538)
Manually setting #defines in the xcodeproj is error prone, and mismatched defines between the two build systems can cause ODR related undefined behaviors. Use the generated headers to propagate configuration from GN to Xcode builds. This just requires setting CHIP_HAVE_CONFIG_H.
1 parent 0398f1e commit 1108091

File tree

4 files changed

+34
-47
lines changed

4 files changed

+34
-47
lines changed

config/ios/SystemProjectConfig.h

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
*
3+
* Copyright (c) 2021 Project CHIP Authors
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
/**
19+
* @file
20+
* chip::System project configuration for standalone builds on iOS
21+
*
22+
*/
23+
#ifndef SYSTEMPROJECTCONFIG_H
24+
#define SYSTEMPROJECTCONFIG_H
25+
26+
#endif /* SYSTEMPROJECTCONFIG_H */

src/darwin/CHIPTool/CHIPTool.xcodeproj/project.pbxproj

+5-2
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@
478478
GCC_NO_COMMON_BLOCKS = YES;
479479
GCC_OPTIMIZATION_LEVEL = 0;
480480
GCC_PREPROCESSOR_DEFINITIONS = (
481-
HAVE_CONFIG_H,
481+
CHIP_HAVE_CONFIG_H,
482482
"DEBUG=1",
483483
"$(inherited)",
484484
);
@@ -536,7 +536,10 @@
536536
ENABLE_STRICT_OBJC_MSGSEND = YES;
537537
GCC_C_LANGUAGE_STANDARD = gnu11;
538538
GCC_NO_COMMON_BLOCKS = YES;
539-
GCC_PREPROCESSOR_DEFINITIONS = HAVE_CONFIG_H;
539+
GCC_PREPROCESSOR_DEFINITIONS = (
540+
CHIP_HAVE_CONFIG_H,
541+
"$(inherited)",
542+
);
540543
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
541544
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
542545
GCC_WARN_UNDECLARED_SELECTOR = YES;

src/darwin/Framework/CHIP.xcodeproj/project.pbxproj

+2-26
Original file line numberDiff line numberDiff line change
@@ -624,19 +624,7 @@
624624
DYLIB_CURRENT_VERSION = 1;
625625
DYLIB_INSTALL_NAME_BASE = "@rpath";
626626
GCC_PREPROCESSOR_DEFINITIONS = (
627-
"CHIP_PROJECT_CONFIG_INCLUDE=<CHIPProjectConfig.h>",
628-
"CHIP_PLATFORM_CONFIG_INCLUDE=<platform/Darwin/CHIPPlatformConfig.h>",
629-
"CHIP_DEVICE_PLATFORM_CONFIG_INCLUDE=<platform/Darwin/CHIPDevicePlatformConfig.h>",
630-
CONFIG_NETWORK_LAYER_INET,
631-
CONFIG_NETWORK_LAYER_BLE,
632-
"CHIP_DEVICE_LAYER_TARGET=Darwin",
633-
"CHIP_DEVICE_LAYER_TARGET_DARWIN=1",
634-
"CHIP_DEVICE_LAYER_TARGET_LINUX=0",
635-
"CHIP_DEVICE_LAYER_TARGET_NRF5=0",
636-
"CHIP_DEVICE_LAYER_TARGET_EFR32=0",
637-
"CHIP_SYSTEM_CONFIG_USE_SOCKETS=1",
638-
"CHIP_SYSTEM_CONFIG_POSIX_LOCKING=0",
639-
"CHIP_SYSTEM_CONFIG_NO_LOCKING=1",
627+
CHIP_HAVE_CONFIG_H,
640628
"$(inherited)",
641629
);
642630
HEADER_SEARCH_PATHS = (
@@ -769,19 +757,7 @@
769757
DYLIB_CURRENT_VERSION = 1;
770758
DYLIB_INSTALL_NAME_BASE = "@rpath";
771759
GCC_PREPROCESSOR_DEFINITIONS = (
772-
"CHIP_PROJECT_CONFIG_INCLUDE=<CHIPProjectConfig.h>",
773-
"CHIP_PLATFORM_CONFIG_INCLUDE=<platform/Darwin/CHIPPlatformConfig.h>",
774-
"CHIP_DEVICE_PLATFORM_CONFIG_INCLUDE=<platform/Darwin/CHIPDevicePlatformConfig.h>",
775-
CONFIG_NETWORK_LAYER_INET,
776-
CONFIG_NETWORK_LAYER_BLE,
777-
"CHIP_DEVICE_LAYER_TARGET=Darwin",
778-
"CHIP_DEVICE_LAYER_TARGET_DARWIN=1",
779-
"CHIP_DEVICE_LAYER_TARGET_LINUX=0",
780-
"CHIP_DEVICE_LAYER_TARGET_NRF5=0",
781-
"CHIP_DEVICE_LAYER_TARGET_EFR32=0",
782-
"CHIP_SYSTEM_CONFIG_USE_SOCKETS=1",
783-
"CHIP_SYSTEM_CONFIG_POSIX_LOCKING=0",
784-
"CHIP_SYSTEM_CONFIG_NO_LOCKING=1",
760+
CHIP_HAVE_CONFIG_H,
785761
"$(inherited)",
786762
);
787763
HEADER_SEARCH_PATHS = (

src/darwin/Framework/chip_xcode_build_connector.sh

+1-19
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,7 @@ for define in "${defines[@]}"; do
5252

5353
# skip over those that GN does for us
5454
case "$define" in
55-
CHIP_DEVICE_LAYER*)
56-
continue
57-
;;
58-
CHIP_*_CONFIG_INCLUDE)
59-
continue
60-
;;
61-
CHIP_SYSTEM_CONFIG_*)
62-
continue
63-
;;
64-
CONFIG_NETWORK_LAYER*)
65-
continue
66-
;;
67-
CHIP_CRYPTO_*)
55+
CHIP_HAVE_CONFIG_H)
6856
continue
6957
;;
7058
esac
@@ -108,10 +96,6 @@ declare -a args=(
10896
'chip_crypto="mbedtls"'
10997
'chip_build_tools=false'
11098
'chip_build_tests=false'
111-
'chip_ble_project_config_include=""'
112-
'chip_device_project_config_include=""'
113-
'chip_inet_project_config_include=""'
114-
'chip_system_project_config_include=""'
11599
'target_cpu="'"$target_cpu"'"'
116100
'target_defines='"$target_defines"
117101
'target_cflags=['"$target_cflags"']'
@@ -129,8 +113,6 @@ declare -a args=(
129113
[[ $PLATFORM_FAMILY_NAME == macOS ]] && {
130114
args+=(
131115
'target_os="mac"'
132-
'import("//config/standalone/args.gni")'
133-
'chip_project_config_include_dirs=["'"$CHIP_ROOT"'/config/standalone"]'
134116
)
135117
}
136118

0 commit comments

Comments
 (0)