Skip to content

Commit

Permalink
Use generated headers consistently on darwin (#11538)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mspang authored and pull[bot] committed Jan 6, 2022
1 parent f3d0e54 commit 2612034
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 47 deletions.
26 changes: 26 additions & 0 deletions config/ios/SystemProjectConfig.h
Original file line number Diff line number Diff line change
@@ -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 */
7 changes: 5 additions & 2 deletions src/darwin/CHIPTool/CHIPTool.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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)",
);
Expand Down Expand Up @@ -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;
Expand Down
28 changes: 2 additions & 26 deletions src/darwin/Framework/CHIP.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -624,19 +624,7 @@
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
GCC_PREPROCESSOR_DEFINITIONS = (
"CHIP_PROJECT_CONFIG_INCLUDE=<CHIPProjectConfig.h>",
"CHIP_PLATFORM_CONFIG_INCLUDE=<platform/Darwin/CHIPPlatformConfig.h>",
"CHIP_DEVICE_PLATFORM_CONFIG_INCLUDE=<platform/Darwin/CHIPDevicePlatformConfig.h>",
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 = (
Expand Down Expand Up @@ -769,19 +757,7 @@
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
GCC_PREPROCESSOR_DEFINITIONS = (
"CHIP_PROJECT_CONFIG_INCLUDE=<CHIPProjectConfig.h>",
"CHIP_PLATFORM_CONFIG_INCLUDE=<platform/Darwin/CHIPPlatformConfig.h>",
"CHIP_DEVICE_PLATFORM_CONFIG_INCLUDE=<platform/Darwin/CHIPDevicePlatformConfig.h>",
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 = (
Expand Down
20 changes: 1 addition & 19 deletions src/darwin/Framework/chip_xcode_build_connector.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"']'
Expand All @@ -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"]'
)
}

Expand Down

0 comments on commit 2612034

Please sign in to comment.