Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update fixtures for CocoaPods:#11229 #332

Merged
merged 1 commit into from
Mar 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -14,6 +14,66 @@ trap 'on_error $LINENO' ERR
RSYNC_PROTECT_TMP_FILES=(--filter "P .*.??????")


variant_for_slice()
{
case "$1" in
"CoconutLib.xcframework/ios-arm64")
echo ""
;;
"CoconutLib.xcframework/macos-x86_64")
echo ""
;;
"CoconutLib.xcframework/ios-x86_64-maccatalyst")
echo "maccatalyst"
;;
"CoconutLib.xcframework/watchos-arm64_32_armv7k")
echo ""
;;
"CoconutLib.xcframework/tvos-arm64_x86_64-simulator")
echo "simulator"
;;
"CoconutLib.xcframework/watchos-arm64_i386_x86_64-simulator")
echo "simulator"
;;
"CoconutLib.xcframework/ios-arm64_x86_64-simulator")
echo "simulator"
;;
"CoconutLib.xcframework/tvos-arm64")
echo ""
;;
esac
}

archs_for_slice()
{
case "$1" in
"CoconutLib.xcframework/ios-arm64")
echo "arm64"
;;
"CoconutLib.xcframework/macos-x86_64")
echo "x86_64"
;;
"CoconutLib.xcframework/ios-x86_64-maccatalyst")
echo "x86_64"
;;
"CoconutLib.xcframework/watchos-arm64_32_armv7k")
echo "arm64_32 armv7k"
;;
"CoconutLib.xcframework/tvos-arm64_x86_64-simulator")
echo "arm64 x86_64"
;;
"CoconutLib.xcframework/watchos-arm64_i386_x86_64-simulator")
echo "arm64 i386 x86_64"
;;
"CoconutLib.xcframework/ios-arm64_x86_64-simulator")
echo "arm64 x86_64"
;;
"CoconutLib.xcframework/tvos-arm64")
echo "arm64"
;;
esac
}

copy_dir()
{
local source="$1"
Expand All @@ -27,7 +87,9 @@ copy_dir()
SELECT_SLICE_RETVAL=""

select_slice() {
local paths=("$@")
local xcframework_name="$1"
xcframework_name="${xcframework_name##*/}"
local paths=("${@:2}")
# Locate the correct slice of the .xcframework for the current architectures
local target_path=""

Expand All @@ -43,29 +105,15 @@ select_slice() {
fi
for i in ${!paths[@]}; do
local matched_all_archs="1"
for target_arch in $target_archs
do
if ! [[ "${paths[$i]}" == *"$target_variant"* ]]; then
matched_all_archs="0"
break
fi

# Verifies that the path contains the variant string (simulator or maccatalyst) if the variant is set.
if [[ -z "$target_variant" && ("${paths[$i]}" == *"simulator"* || "${paths[$i]}" == *"maccatalyst"*) ]]; then
local slice_archs="$(archs_for_slice "${xcframework_name}/${paths[$i]}")"
local slice_variant="$(variant_for_slice "${xcframework_name}/${paths[$i]}")"
for target_arch in $target_archs; do
if ! [[ "${slice_variant}" == "$target_variant" ]]; then
matched_all_archs="0"
break
fi

# This regex matches all possible variants of the arch in the folder name:
# Let's say the folder name is: ios-armv7_armv7s_arm64_arm64e/CoconutLib.framework
# We match the following: -armv7_, _armv7s_, _arm64_ and _arm64e/.
# If we have a specific variant: ios-i386_x86_64-simulator/CoconutLib.framework
# We match the following: -i386_ and _x86_64-
# When the .xcframework wraps a static library, the folder name does not include
# any .framework. In that case, the folder name can be: ios-arm64_armv7
# We also match _armv7$ to handle that case.
local target_arch_regex="[_\-]${target_arch}([\/_\-]|$)"
if ! [[ "${paths[$i]}" =~ $target_arch_regex ]]; then
if ! echo "${slice_archs}" | tr " " "\n" | grep -F -q -x "$target_arch"; then
matched_all_archs="0"
break
fi
Expand All @@ -87,10 +135,10 @@ install_xcframework() {
local paths=("${@:4}")

# Locate the correct slice of the .xcframework for the current architectures
select_slice "${paths[@]}"
select_slice "${basepath}" "${paths[@]}"
local target_path="$SELECT_SLICE_RETVAL"
if [[ -z "$target_path" ]]; then
echo "warning: [CP] Unable to find matching .xcframework slice in '${paths[@]}' for the current build architectures ($ARCHS)."
echo "warning: [CP] $(basename ${basepath}): Unable to find matching slice in '${paths[@]}' for the current build architectures ($ARCHS) and platform ($EFFECTIVE_PLATFORM_NAME)."
return
fi
local source="$basepath/$target_path"
Expand Down
Expand Up @@ -14,6 +14,60 @@ trap 'on_error $LINENO' ERR
RSYNC_PROTECT_TMP_FILES=(--filter "P .*.??????")


variant_for_slice()
{
case "$1" in
"CoconutLib.xcframework/tvos-x86_64-simulator")
echo "simulator"
;;
"CoconutLib.xcframework/tvos-arm64")
echo ""
;;
"CoconutLib.xcframework/watchos-i386-simulator")
echo "simulator"
;;
"CoconutLib.xcframework/watchos-armv7k_arm64_32")
echo ""
;;
"CoconutLib.xcframework/macos-x86_64")
echo ""
;;
"CoconutLib.xcframework/ios-i386_x86_64-simulator")
echo "simulator"
;;
"CoconutLib.xcframework/ios-armv7_arm64")
echo ""
;;
esac
}

archs_for_slice()
{
case "$1" in
"CoconutLib.xcframework/tvos-x86_64-simulator")
echo "x86_64"
;;
"CoconutLib.xcframework/tvos-arm64")
echo "arm64"
;;
"CoconutLib.xcframework/watchos-i386-simulator")
echo "i386"
;;
"CoconutLib.xcframework/watchos-armv7k_arm64_32")
echo "arm64_32 armv7k"
;;
"CoconutLib.xcframework/macos-x86_64")
echo "x86_64"
;;
"CoconutLib.xcframework/ios-i386_x86_64-simulator")
echo "i386 x86_64"
;;
"CoconutLib.xcframework/ios-armv7_arm64")
echo "arm64 armv7"
;;
esac
}

copy_dir()
{
local source="$1"
Expand All @@ -27,7 +81,9 @@ copy_dir()
SELECT_SLICE_RETVAL=""

select_slice() {
local paths=("$@")
local xcframework_name="$1"
xcframework_name="${xcframework_name##*/}"
local paths=("${@:2}")
# Locate the correct slice of the .xcframework for the current architectures
local target_path=""

Expand All @@ -43,29 +99,15 @@ select_slice() {
fi
for i in ${!paths[@]}; do
local matched_all_archs="1"
for target_arch in $target_archs
do
if ! [[ "${paths[$i]}" == *"$target_variant"* ]]; then
matched_all_archs="0"
break
fi

# Verifies that the path contains the variant string (simulator or maccatalyst) if the variant is set.
if [[ -z "$target_variant" && ("${paths[$i]}" == *"simulator"* || "${paths[$i]}" == *"maccatalyst"*) ]]; then
local slice_archs="$(archs_for_slice "${xcframework_name}/${paths[$i]}")"
local slice_variant="$(variant_for_slice "${xcframework_name}/${paths[$i]}")"
for target_arch in $target_archs; do
if ! [[ "${slice_variant}" == "$target_variant" ]]; then
matched_all_archs="0"
break
fi

# This regex matches all possible variants of the arch in the folder name:
# Let's say the folder name is: ios-armv7_armv7s_arm64_arm64e/CoconutLib.framework
# We match the following: -armv7_, _armv7s_, _arm64_ and _arm64e/.
# If we have a specific variant: ios-i386_x86_64-simulator/CoconutLib.framework
# We match the following: -i386_ and _x86_64-
# When the .xcframework wraps a static library, the folder name does not include
# any .framework. In that case, the folder name can be: ios-arm64_armv7
# We also match _armv7$ to handle that case.
local target_arch_regex="[_\-]${target_arch}([\/_\-]|$)"
if ! [[ "${paths[$i]}" =~ $target_arch_regex ]]; then
if ! echo "${slice_archs}" | tr " " "\n" | grep -F -q -x "$target_arch"; then
matched_all_archs="0"
break
fi
Expand All @@ -87,10 +129,10 @@ install_xcframework() {
local paths=("${@:4}")

# Locate the correct slice of the .xcframework for the current architectures
select_slice "${paths[@]}"
select_slice "${basepath}" "${paths[@]}"
local target_path="$SELECT_SLICE_RETVAL"
if [[ -z "$target_path" ]]; then
echo "warning: [CP] Unable to find matching .xcframework slice in '${paths[@]}' for the current build architectures ($ARCHS)."
echo "warning: [CP] $(basename ${basepath}): Unable to find matching slice in '${paths[@]}' for the current build architectures ($ARCHS) and platform ($EFFECTIVE_PLATFORM_NAME)."
return
fi
local source="$basepath/$target_path"
Expand Down
Expand Up @@ -14,6 +14,66 @@ trap 'on_error $LINENO' ERR
RSYNC_PROTECT_TMP_FILES=(--filter "P .*.??????")


variant_for_slice()
{
case "$1" in
"CoconutLib.xcframework/tvos-arm64")
echo ""
;;
"CoconutLib.xcframework/ios-x86_64-maccatalyst")
echo "maccatalyst"
;;
"CoconutLib.xcframework/ios-i386_x86_64-simulator")
echo "simulator"
;;
"CoconutLib.xcframework/macos-x86_64")
echo ""
;;
"CoconutLib.xcframework/ios-armv7_arm64")
echo ""
;;
"CoconutLib.xcframework/tvos-x86_64-simulator")
echo "simulator"
;;
"CoconutLib.xcframework/watchos-i386-simulator")
echo "simulator"
;;
"CoconutLib.xcframework/watchos-armv7k_arm64_32")
echo ""
;;
esac
}

archs_for_slice()
{
case "$1" in
"CoconutLib.xcframework/tvos-arm64")
echo "arm64"
;;
"CoconutLib.xcframework/ios-x86_64-maccatalyst")
echo "x86_64"
;;
"CoconutLib.xcframework/ios-i386_x86_64-simulator")
echo "i386 x86_64"
;;
"CoconutLib.xcframework/macos-x86_64")
echo "x86_64"
;;
"CoconutLib.xcframework/ios-armv7_arm64")
echo "arm64 armv7"
;;
"CoconutLib.xcframework/tvos-x86_64-simulator")
echo "x86_64"
;;
"CoconutLib.xcframework/watchos-i386-simulator")
echo "i386"
;;
"CoconutLib.xcframework/watchos-armv7k_arm64_32")
echo "arm64_32 armv7k"
;;
esac
}

copy_dir()
{
local source="$1"
Expand All @@ -27,7 +87,9 @@ copy_dir()
SELECT_SLICE_RETVAL=""

select_slice() {
local paths=("$@")
local xcframework_name="$1"
xcframework_name="${xcframework_name##*/}"
local paths=("${@:2}")
# Locate the correct slice of the .xcframework for the current architectures
local target_path=""

Expand All @@ -43,29 +105,15 @@ select_slice() {
fi
for i in ${!paths[@]}; do
local matched_all_archs="1"
for target_arch in $target_archs
do
if ! [[ "${paths[$i]}" == *"$target_variant"* ]]; then
matched_all_archs="0"
break
fi

# Verifies that the path contains the variant string (simulator or maccatalyst) if the variant is set.
if [[ -z "$target_variant" && ("${paths[$i]}" == *"simulator"* || "${paths[$i]}" == *"maccatalyst"*) ]]; then
local slice_archs="$(archs_for_slice "${xcframework_name}/${paths[$i]}")"
local slice_variant="$(variant_for_slice "${xcframework_name}/${paths[$i]}")"
for target_arch in $target_archs; do
if ! [[ "${slice_variant}" == "$target_variant" ]]; then
matched_all_archs="0"
break
fi

# This regex matches all possible variants of the arch in the folder name:
# Let's say the folder name is: ios-armv7_armv7s_arm64_arm64e/CoconutLib.framework
# We match the following: -armv7_, _armv7s_, _arm64_ and _arm64e/.
# If we have a specific variant: ios-i386_x86_64-simulator/CoconutLib.framework
# We match the following: -i386_ and _x86_64-
# When the .xcframework wraps a static library, the folder name does not include
# any .framework. In that case, the folder name can be: ios-arm64_armv7
# We also match _armv7$ to handle that case.
local target_arch_regex="[_\-]${target_arch}([\/_\-]|$)"
if ! [[ "${paths[$i]}" =~ $target_arch_regex ]]; then
if ! echo "${slice_archs}" | tr " " "\n" | grep -F -q -x "$target_arch"; then
matched_all_archs="0"
break
fi
Expand All @@ -87,10 +135,10 @@ install_xcframework() {
local paths=("${@:4}")

# Locate the correct slice of the .xcframework for the current architectures
select_slice "${paths[@]}"
select_slice "${basepath}" "${paths[@]}"
local target_path="$SELECT_SLICE_RETVAL"
if [[ -z "$target_path" ]]; then
echo "warning: [CP] Unable to find matching .xcframework slice in '${paths[@]}' for the current build architectures ($ARCHS)."
echo "warning: [CP] $(basename ${basepath}): Unable to find matching slice in '${paths[@]}' for the current build architectures ($ARCHS) and platform ($EFFECTIVE_PLATFORM_NAME)."
return
fi
local source="$basepath/$target_path"
Expand Down