Skip to content

Commit

Permalink
Darwin: Add support for zippered builds (project-chip#35567)
Browse files Browse the repository at this point in the history
* Darwin: Add support for zippered builds

* Restyled by shellharden

* Restyled by shfmt

---------

Co-authored-by: Restyled.io <[email protected]>
  • Loading branch information
ksperling-apple and restyled-commits authored Sep 13, 2024
1 parent bba766b commit 16e4e9b
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/darwin/Framework/chip_xcode_build_connector.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash -e

#
# Copyright (c) 2020 Project CHIP Authors
# Copyright (c) 2020-2024 Project CHIP Authors
# All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -67,15 +67,23 @@ for define in "${xcode_defines[@]}"; do
done

# Forward C/C++ flags (OTHER_C*FLAGS)
declare -a target_cflags=()
read -r -a target_cflags_c <<<"$OTHER_CFLAGS"
read -r -a target_cflags_cc <<<"$OTHER_CPLUSPLUSFLAGS"

# Handle target OS and arch
declare target_arch=
declare target_cpu=
declare target_cflags=
declare -a target_cflags=()
declare current_arch="$(uname -m)"
declare deployment_target="$LLVM_TARGET_TRIPLE_OS_VERSION$LLVM_TARGET_TRIPLE_SUFFIX"
declare deployment_variant=
if [[ "$IS_ZIPPERED" == YES ]]; then
if [[ "$CLANG_TARGET_TRIPLE_VARIANTS" != *-apple-* ]]; then
echo "Unable to determine target variant for zippered build" >&2
exit 1
fi
deployment_variant="${CLANG_TARGET_TRIPLE_VARIANTS/*-apple-/}"
fi

read -r -a archs <<<"$ARCHS"
for arch in "${archs[@]}"; do
Expand All @@ -86,7 +94,8 @@ for arch in "${archs[@]}"; do
*) target_cpu="$arch" ;;
esac
fi
target_cflags+=(-arch "$arch")
[[ "${#archs[@]}" -gt 1 ]] && target_cflags+=(-arch "$arch")
[[ -n "$deployment_variant" ]] && target_cflags+=(-target-variant "$arch-apple-$deployment_variant")
done

# Translate other options
Expand All @@ -108,7 +117,7 @@ declare -a args=(
'enable_fuzz_test_targets=false'
"target_cpu=\"$target_cpu\""
"mac_target_arch=\"$target_arch\""
"mac_deployment_target=\"$LLVM_TARGET_TRIPLE_OS_VERSION$LLVM_TARGET_TRIPLE_SUFFIX\""
"mac_deployment_target=\"$deployment_target\""
"target_defines=$(format_gn_list "${target_defines[@]}")"
"target_cflags=$(format_gn_list "${target_cflags[@]}")"
"target_cflags_c=$(format_gn_list "${target_cflags_c[@]}")"
Expand Down

0 comments on commit 16e4e9b

Please sign in to comment.