From 2fe39c4e41da63906b677dcd03e4d06641b65cbe Mon Sep 17 00:00:00 2001 From: Michael Spang Date: Tue, 9 Nov 2021 00:33:28 -0500 Subject: [PATCH] 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. --- config/ios/SystemProjectConfig.h | 26 +++++++++++++++++ .../CHIPTool.xcodeproj/project.pbxproj | 7 +++-- .../Framework/CHIP.xcodeproj/project.pbxproj | 28 ++----------------- .../Framework/chip_xcode_build_connector.sh | 20 +------------ 4 files changed, 34 insertions(+), 47 deletions(-) create mode 100644 config/ios/SystemProjectConfig.h diff --git a/config/ios/SystemProjectConfig.h b/config/ios/SystemProjectConfig.h new file mode 100644 index 00000000000000..06d9baaee59492 --- /dev/null +++ b/config/ios/SystemProjectConfig.h @@ -0,0 +1,26 @@ +/* + * + * 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/src/darwin/CHIPTool/CHIPTool.xcodeproj/project.pbxproj b/src/darwin/CHIPTool/CHIPTool.xcodeproj/project.pbxproj index 946852cb2076a5..ec119db4bb5ebf 100644 --- a/src/darwin/CHIPTool/CHIPTool.xcodeproj/project.pbxproj +++ b/src/darwin/CHIPTool/CHIPTool.xcodeproj/project.pbxproj @@ -478,7 +478,7 @@ GCC_NO_COMMON_BLOCKS = YES; GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = ( - HAVE_CONFIG_H, + CHIP_HAVE_CONFIG_H, "DEBUG=1", "$(inherited)", ); @@ -536,7 +536,10 @@ ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_C_LANGUAGE_STANDARD = gnu11; GCC_NO_COMMON_BLOCKS = YES; - GCC_PREPROCESSOR_DEFINITIONS = HAVE_CONFIG_H; + GCC_PREPROCESSOR_DEFINITIONS = ( + CHIP_HAVE_CONFIG_H, + "$(inherited)", + ); GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; GCC_WARN_UNDECLARED_SELECTOR = YES; diff --git a/src/darwin/Framework/CHIP.xcodeproj/project.pbxproj b/src/darwin/Framework/CHIP.xcodeproj/project.pbxproj index db9a78c3d7dc4f..4f66ee17dc13f5 100644 --- a/src/darwin/Framework/CHIP.xcodeproj/project.pbxproj +++ b/src/darwin/Framework/CHIP.xcodeproj/project.pbxproj @@ -624,19 +624,7 @@ DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; GCC_PREPROCESSOR_DEFINITIONS = ( - "CHIP_PROJECT_CONFIG_INCLUDE=", - "CHIP_PLATFORM_CONFIG_INCLUDE=", - "CHIP_DEVICE_PLATFORM_CONFIG_INCLUDE=", - CONFIG_NETWORK_LAYER_INET, - CONFIG_NETWORK_LAYER_BLE, - "CHIP_DEVICE_LAYER_TARGET=Darwin", - "CHIP_DEVICE_LAYER_TARGET_DARWIN=1", - "CHIP_DEVICE_LAYER_TARGET_LINUX=0", - "CHIP_DEVICE_LAYER_TARGET_NRF5=0", - "CHIP_DEVICE_LAYER_TARGET_EFR32=0", - "CHIP_SYSTEM_CONFIG_USE_SOCKETS=1", - "CHIP_SYSTEM_CONFIG_POSIX_LOCKING=0", - "CHIP_SYSTEM_CONFIG_NO_LOCKING=1", + CHIP_HAVE_CONFIG_H, "$(inherited)", ); HEADER_SEARCH_PATHS = ( @@ -769,19 +757,7 @@ DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; GCC_PREPROCESSOR_DEFINITIONS = ( - "CHIP_PROJECT_CONFIG_INCLUDE=", - "CHIP_PLATFORM_CONFIG_INCLUDE=", - "CHIP_DEVICE_PLATFORM_CONFIG_INCLUDE=", - CONFIG_NETWORK_LAYER_INET, - CONFIG_NETWORK_LAYER_BLE, - "CHIP_DEVICE_LAYER_TARGET=Darwin", - "CHIP_DEVICE_LAYER_TARGET_DARWIN=1", - "CHIP_DEVICE_LAYER_TARGET_LINUX=0", - "CHIP_DEVICE_LAYER_TARGET_NRF5=0", - "CHIP_DEVICE_LAYER_TARGET_EFR32=0", - "CHIP_SYSTEM_CONFIG_USE_SOCKETS=1", - "CHIP_SYSTEM_CONFIG_POSIX_LOCKING=0", - "CHIP_SYSTEM_CONFIG_NO_LOCKING=1", + CHIP_HAVE_CONFIG_H, "$(inherited)", ); HEADER_SEARCH_PATHS = ( diff --git a/src/darwin/Framework/chip_xcode_build_connector.sh b/src/darwin/Framework/chip_xcode_build_connector.sh index 514443fd605d4a..0b5d884f7fae33 100755 --- a/src/darwin/Framework/chip_xcode_build_connector.sh +++ b/src/darwin/Framework/chip_xcode_build_connector.sh @@ -52,19 +52,7 @@ for define in "${defines[@]}"; do # skip over those that GN does for us case "$define" in - CHIP_DEVICE_LAYER*) - continue - ;; - CHIP_*_CONFIG_INCLUDE) - continue - ;; - CHIP_SYSTEM_CONFIG_*) - continue - ;; - CONFIG_NETWORK_LAYER*) - continue - ;; - CHIP_CRYPTO_*) + CHIP_HAVE_CONFIG_H) continue ;; esac @@ -108,10 +96,6 @@ declare -a args=( 'chip_crypto="mbedtls"' 'chip_build_tools=false' 'chip_build_tests=false' - 'chip_ble_project_config_include=""' - 'chip_device_project_config_include=""' - 'chip_inet_project_config_include=""' - 'chip_system_project_config_include=""' 'target_cpu="'"$target_cpu"'"' 'target_defines='"$target_defines" 'target_cflags=['"$target_cflags"']' @@ -129,8 +113,6 @@ declare -a args=( [[ $PLATFORM_FAMILY_NAME == macOS ]] && { args+=( 'target_os="mac"' - 'import("//config/standalone/args.gni")' - 'chip_project_config_include_dirs=["'"$CHIP_ROOT"'/config/standalone"]' ) }