From 050d4ab2d822658c1a8adb4cbd7cde477711b8cb Mon Sep 17 00:00:00 2001 From: Karsten Sperling Date: Thu, 20 Oct 2022 13:42:44 +1300 Subject: [PATCH 1/2] Set target_cpu and mac_target_arch based on first arch in ARCHS. This makes Xcode builds for "My Mac" work on M1 Macs. Also set is_debug correctly and tweak some project / scheme settings. --- .../Matter.xcodeproj/project.pbxproj | 9 ++-- .../xcschemes/Matter Framework.xcscheme | 10 ++++ .../Framework/chip_xcode_build_connector.sh | 49 +++++++------------ 3 files changed, 34 insertions(+), 34 deletions(-) diff --git a/src/darwin/Framework/Matter.xcodeproj/project.pbxproj b/src/darwin/Framework/Matter.xcodeproj/project.pbxproj index 6e56afa28f948c..5b8ee4a0bb523a 100644 --- a/src/darwin/Framework/Matter.xcodeproj/project.pbxproj +++ b/src/darwin/Framework/Matter.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 53; + objectVersion = 54; objects = { /* Begin PBXBuildFile section */ @@ -571,7 +571,7 @@ isa = PBXNativeTarget; buildConfigurationList = B20252A12459E34F00F97062 /* Build configuration list for PBXNativeTarget "Matter" */; buildPhases = ( - 0C40A67D246C9AC700885C81 /* Run Script */, + 0C40A67D246C9AC700885C81 /* Run GN Build (chip_xcode_build_connector) */, B20252882459E34F00F97062 /* Headers */, B20252892459E34F00F97062 /* Sources */, B202528A2459E34F00F97062 /* Frameworks */, @@ -659,8 +659,9 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ - 0C40A67D246C9AC700885C81 /* Run Script */ = { + 0C40A67D246C9AC700885C81 /* Run GN Build (chip_xcode_build_connector) */ = { isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; buildActionMask = 2147483647; files = ( ); @@ -668,7 +669,7 @@ ); inputPaths = ( ); - name = "Run Script"; + name = "Run GN Build (chip_xcode_build_connector)"; outputFileListPaths = ( ); outputPaths = ( diff --git a/src/darwin/Framework/Matter.xcodeproj/xcshareddata/xcschemes/Matter Framework.xcscheme b/src/darwin/Framework/Matter.xcodeproj/xcshareddata/xcschemes/Matter Framework.xcscheme index daea75f7e7e690..83717233f5a54a 100644 --- a/src/darwin/Framework/Matter.xcodeproj/xcshareddata/xcschemes/Matter Framework.xcscheme +++ b/src/darwin/Framework/Matter.xcodeproj/xcshareddata/xcschemes/Matter Framework.xcscheme @@ -28,6 +28,16 @@ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" shouldUseLaunchSchemeArgsEnv = "YES"> + + + + &2 - ;; -esac - -declare target_cflags="" +declare target_cflags= read -r -a archs <<<"$ARCHS" - for arch in "${archs[@]}"; do + if [ -z "$target_arch"] ]; then + target_arch="$arch" + case "$arch" in + x86_64) target_cpu="x64";; + *) target_cpu="$arch";; + esac + fi if [ -n "$target_cflags" ]; then target_cflags+=',' fi @@ -102,14 +91,14 @@ declare -a args=( 'chip_enable_wifi=false' 'chip_log_message_max_size=4096' # might as well allow nice long log messages 'chip_disable_platform_kvs=true' - 'target_cpu="'"$target_cpu"'"' - 'target_defines='"$target_defines" - 'target_cflags=['"$target_cflags"']' - 'mac_target_arch="'"$PLATFORM_PREFERRED_ARCH"'"' - 'mac_deployment_target="'"$LLVM_TARGET_TRIPLE_OS_VERSION"''"$LLVM_TARGET_TRIPLE_SUFFIX"'"' + "target_cpu=\"$target_cpu\"" + "target_defines=$target_defines" + "target_cflags=[$target_cflags]" + "mac_target_arch=\"$target_arch\"" + "mac_deployment_target=\"$LLVM_TARGET_TRIPLE_OS_VERSION$LLVM_TARGET_TRIPLE_SUFFIX\"" ) -[[ $CONFIGURATION != Debug* ]] && args+='is_debug=true' +[[ $CONFIGURATION == Debug ]] && args+=('is_debug=true') [[ $PLATFORM_FAMILY_NAME != macOS ]] && { args+=( @@ -142,7 +131,7 @@ find_in_ancestors() { } # actual build stuff -( +{ cd "$CHIP_ROOT" # pushd and popd because we need the env vars from activate if ENV=$(find_in_ancestors chip_xcode_build_connector_env.sh 2>/dev/null); then @@ -163,7 +152,7 @@ find_in_ancestors() { # put build intermediates in TEMP_DIR cd "$TEMP_DIR" - # gnerate and build + # generate and build gn --root="$CHIP_ROOT" gen --check out --args="${args[*]}" - ninja -v -C out -) + exec ninja -v -C out +} From 8a6d6554b7b02ec0f1417852029e06ed3d046b14 Mon Sep 17 00:00:00 2001 From: Karsten Sperling Date: Tue, 25 Oct 2022 11:03:26 +1300 Subject: [PATCH 2/2] restyle --- src/darwin/Framework/chip_xcode_build_connector.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/darwin/Framework/chip_xcode_build_connector.sh b/src/darwin/Framework/chip_xcode_build_connector.sh index b80d61a14b3363..0357064c6c626c 100755 --- a/src/darwin/Framework/chip_xcode_build_connector.sh +++ b/src/darwin/Framework/chip_xcode_build_connector.sh @@ -69,8 +69,8 @@ for arch in "${archs[@]}"; do if [ -z "$target_arch"] ]; then target_arch="$arch" case "$arch" in - x86_64) target_cpu="x64";; - *) target_cpu="$arch";; + x86_64) target_cpu="x64" ;; + *) target_cpu="$arch" ;; esac fi if [ -n "$target_cflags" ]; then