You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
290 lines
11 KiB
290 lines
11 KiB
#!/bin/sh |
|
set -e |
|
set -u |
|
set -o pipefail |
|
|
|
function on_error { |
|
echo "$(realpath -mq "${0}"):$1: error: Unexpected failure" |
|
} |
|
trap 'on_error $LINENO' ERR |
|
|
|
|
|
# This protects against multiple targets copying the same framework dependency at the same time. The solution |
|
# was originally proposed here: https://lists.samba.org/archive/rsync/2008-February/020158.html |
|
RSYNC_PROTECT_TMP_FILES=(--filter "P .*.??????") |
|
|
|
|
|
variant_for_slice() |
|
{ |
|
case "$1" in |
|
"BURelyFoundationAFN.xcframework/ios-arm64_armv7") |
|
echo "" |
|
;; |
|
"BURelyFoundationAFN.xcframework/ios-arm64_i386_x86_64-simulator") |
|
echo "simulator" |
|
;; |
|
"BURelyFoundationHeader.xcframework/ios-arm64_armv7") |
|
echo "" |
|
;; |
|
"BURelyFoundationHeader.xcframework/ios-arm64_i386_x86_64-simulator") |
|
echo "simulator" |
|
;; |
|
"CSJLottie.xcframework/ios-arm64_armv7") |
|
echo "" |
|
;; |
|
"CSJLottie.xcframework/ios-arm64_i386_x86_64-simulator") |
|
echo "simulator" |
|
;; |
|
"ELCoreTokenizer.xcframework/ios-arm64_armv7") |
|
echo "" |
|
;; |
|
"ELCoreTokenizer.xcframework/ios-arm64_i386_x86_64-simulator") |
|
echo "simulator" |
|
;; |
|
"BURelyFoundationFoundation.xcframework/ios-arm64_armv7") |
|
echo "" |
|
;; |
|
"BURelyFoundationFoundation.xcframework/ios-arm64_i386_x86_64-simulator") |
|
echo "simulator" |
|
;; |
|
"BURelyFoundationGecko.xcframework/ios-arm64_armv7") |
|
echo "" |
|
;; |
|
"BURelyFoundationGecko.xcframework/ios-arm64_i386_x86_64-simulator") |
|
echo "simulator" |
|
;; |
|
"HM.xcframework/ios-arm64_armv7") |
|
echo "" |
|
;; |
|
"HM.xcframework/ios-arm64_i386_x86_64-simulator") |
|
echo "simulator" |
|
;; |
|
"BURelyFoundationNETWork.xcframework/ios-arm64_armv7") |
|
echo "" |
|
;; |
|
"BURelyFoundationNETWork.xcframework/ios-arm64_i386_x86_64-simulator") |
|
echo "simulator" |
|
;; |
|
"BURelyFoundationSDWebImage.xcframework/ios-arm64_armv7") |
|
echo "" |
|
;; |
|
"BURelyFoundationSDWebImage.xcframework/ios-arm64_i386_x86_64-simulator") |
|
echo "simulator" |
|
;; |
|
"BUADServiceKit.xcframework/ios-arm64_armv7") |
|
echo "" |
|
;; |
|
"BUADServiceKit.xcframework/ios-arm64_i386_x86_64-simulator") |
|
echo "simulator" |
|
;; |
|
"Ugen.xcframework/ios-arm64_armv7") |
|
echo "" |
|
;; |
|
"Ugen.xcframework/ios-arm64_i386_x86_64-simulator") |
|
echo "simulator" |
|
;; |
|
"BURelyFoundationYYModel.xcframework/ios-arm64_armv7") |
|
echo "" |
|
;; |
|
"BURelyFoundationYYModel.xcframework/ios-arm64_i386_x86_64-simulator") |
|
echo "simulator" |
|
;; |
|
"BURelyFoundationZFPlayer.xcframework/ios-arm64_armv7") |
|
echo "" |
|
;; |
|
"BURelyFoundationZFPlayer.xcframework/ios-arm64_i386_x86_64-simulator") |
|
echo "simulator" |
|
;; |
|
"BURelyFoundationZip.xcframework/ios-arm64_armv7") |
|
echo "" |
|
;; |
|
"BURelyFoundationZip.xcframework/ios-arm64_i386_x86_64-simulator") |
|
echo "simulator" |
|
;; |
|
esac |
|
} |
|
|
|
archs_for_slice() |
|
{ |
|
case "$1" in |
|
"BURelyFoundationAFN.xcframework/ios-arm64_armv7") |
|
echo "arm64 armv7" |
|
;; |
|
"BURelyFoundationAFN.xcframework/ios-arm64_i386_x86_64-simulator") |
|
echo "arm64 i386 x86_64" |
|
;; |
|
"BURelyFoundationHeader.xcframework/ios-arm64_armv7") |
|
echo "arm64 armv7" |
|
;; |
|
"BURelyFoundationHeader.xcframework/ios-arm64_i386_x86_64-simulator") |
|
echo "arm64 i386 x86_64" |
|
;; |
|
"CSJLottie.xcframework/ios-arm64_armv7") |
|
echo "arm64 armv7" |
|
;; |
|
"CSJLottie.xcframework/ios-arm64_i386_x86_64-simulator") |
|
echo "arm64 i386 x86_64" |
|
;; |
|
"ELCoreTokenizer.xcframework/ios-arm64_armv7") |
|
echo "arm64 armv7" |
|
;; |
|
"ELCoreTokenizer.xcframework/ios-arm64_i386_x86_64-simulator") |
|
echo "arm64 i386 x86_64" |
|
;; |
|
"BURelyFoundationFoundation.xcframework/ios-arm64_armv7") |
|
echo "arm64 armv7" |
|
;; |
|
"BURelyFoundationFoundation.xcframework/ios-arm64_i386_x86_64-simulator") |
|
echo "arm64 i386 x86_64" |
|
;; |
|
"BURelyFoundationGecko.xcframework/ios-arm64_armv7") |
|
echo "arm64 armv7" |
|
;; |
|
"BURelyFoundationGecko.xcframework/ios-arm64_i386_x86_64-simulator") |
|
echo "arm64 i386 x86_64" |
|
;; |
|
"HM.xcframework/ios-arm64_armv7") |
|
echo "arm64 armv7" |
|
;; |
|
"HM.xcframework/ios-arm64_i386_x86_64-simulator") |
|
echo "arm64 i386 x86_64" |
|
;; |
|
"BURelyFoundationNETWork.xcframework/ios-arm64_armv7") |
|
echo "arm64 armv7" |
|
;; |
|
"BURelyFoundationNETWork.xcframework/ios-arm64_i386_x86_64-simulator") |
|
echo "arm64 i386 x86_64" |
|
;; |
|
"BURelyFoundationSDWebImage.xcframework/ios-arm64_armv7") |
|
echo "arm64 armv7" |
|
;; |
|
"BURelyFoundationSDWebImage.xcframework/ios-arm64_i386_x86_64-simulator") |
|
echo "arm64 i386 x86_64" |
|
;; |
|
"BUADServiceKit.xcframework/ios-arm64_armv7") |
|
echo "arm64 armv7" |
|
;; |
|
"BUADServiceKit.xcframework/ios-arm64_i386_x86_64-simulator") |
|
echo "arm64 i386 x86_64" |
|
;; |
|
"Ugen.xcframework/ios-arm64_armv7") |
|
echo "arm64 armv7" |
|
;; |
|
"Ugen.xcframework/ios-arm64_i386_x86_64-simulator") |
|
echo "arm64 i386 x86_64" |
|
;; |
|
"BURelyFoundationYYModel.xcframework/ios-arm64_armv7") |
|
echo "arm64 armv7" |
|
;; |
|
"BURelyFoundationYYModel.xcframework/ios-arm64_i386_x86_64-simulator") |
|
echo "arm64 i386 x86_64" |
|
;; |
|
"BURelyFoundationZFPlayer.xcframework/ios-arm64_armv7") |
|
echo "arm64 armv7" |
|
;; |
|
"BURelyFoundationZFPlayer.xcframework/ios-arm64_i386_x86_64-simulator") |
|
echo "arm64 i386 x86_64" |
|
;; |
|
"BURelyFoundationZip.xcframework/ios-arm64_armv7") |
|
echo "arm64 armv7" |
|
;; |
|
"BURelyFoundationZip.xcframework/ios-arm64_i386_x86_64-simulator") |
|
echo "arm64 i386 x86_64" |
|
;; |
|
esac |
|
} |
|
|
|
copy_dir() |
|
{ |
|
local source="$1" |
|
local destination="$2" |
|
|
|
# Use filter instead of exclude so missing patterns don't throw errors. |
|
echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --links --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" \"${source}*\" \"${destination}\"" |
|
rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --links --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" "${source}"/* "${destination}" |
|
} |
|
|
|
SELECT_SLICE_RETVAL="" |
|
|
|
select_slice() { |
|
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="" |
|
|
|
# Split archs on space so we can find a slice that has all the needed archs |
|
local target_archs=$(echo $ARCHS | tr " " "\n") |
|
|
|
local target_variant="" |
|
if [[ "$PLATFORM_NAME" == *"simulator" ]]; then |
|
target_variant="simulator" |
|
fi |
|
if [[ ! -z ${EFFECTIVE_PLATFORM_NAME+x} && "$EFFECTIVE_PLATFORM_NAME" == *"maccatalyst" ]]; then |
|
target_variant="maccatalyst" |
|
fi |
|
for i in ${!paths[@]}; do |
|
local matched_all_archs="1" |
|
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 |
|
|
|
if ! echo "${slice_archs}" | tr " " "\n" | grep -F -q -x "$target_arch"; then |
|
matched_all_archs="0" |
|
break |
|
fi |
|
done |
|
|
|
if [[ "$matched_all_archs" == "1" ]]; then |
|
# Found a matching slice |
|
echo "Selected xcframework slice ${paths[$i]}" |
|
SELECT_SLICE_RETVAL=${paths[$i]} |
|
break |
|
fi |
|
done |
|
} |
|
|
|
install_xcframework() { |
|
local basepath="$1" |
|
local name="$2" |
|
local package_type="$3" |
|
local paths=("${@:4}") |
|
|
|
# Locate the correct slice of the .xcframework for the current architectures |
|
select_slice "${basepath}" "${paths[@]}" |
|
local target_path="$SELECT_SLICE_RETVAL" |
|
if [[ -z "$target_path" ]]; then |
|
echo "warning: [CP] $(basename ${basepath}): Unable to find matching slice in '${paths[@]}' for the current build architectures ($ARCHS) and platform (${EFFECTIVE_PLATFORM_NAME-${PLATFORM_NAME}})." |
|
return |
|
fi |
|
local source="$basepath/$target_path" |
|
|
|
local destination="${PODS_XCFRAMEWORKS_BUILD_DIR}/${name}" |
|
|
|
if [ ! -d "$destination" ]; then |
|
mkdir -p "$destination" |
|
fi |
|
|
|
copy_dir "$source/" "$destination" |
|
echo "Copied $source to $destination" |
|
} |
|
|
|
install_xcframework "${PODS_ROOT}/BURelyFoundation/Frameworks/SDK/BURelyFoundationAFN/BURelyFoundationAFN.xcframework" "BURelyFoundation/AFNetworking" "library" "ios-arm64_armv7" "ios-arm64_i386_x86_64-simulator" |
|
install_xcframework "${PODS_ROOT}/BURelyFoundation/Frameworks/SDK/BURelyFoundationHeader/BURelyFoundationHeader.xcframework" "BURelyFoundation/BURelyFoundation" "library" "ios-arm64_armv7" "ios-arm64_i386_x86_64-simulator" |
|
install_xcframework "${PODS_ROOT}/BURelyFoundation/Frameworks/SDK/CSJLottie/CSJLottie.xcframework" "BURelyFoundation/CSJLottie" "library" "ios-arm64_armv7" "ios-arm64_i386_x86_64-simulator" |
|
install_xcframework "${PODS_ROOT}/BURelyFoundation/Frameworks/SDK/ELCoreTokenizer/ELCoreTokenizer.xcframework" "BURelyFoundation/ELCoreTokenizer" "library" "ios-arm64_armv7" "ios-arm64_i386_x86_64-simulator" |
|
install_xcframework "${PODS_ROOT}/BURelyFoundation/Frameworks/SDK/BURelyFoundationFoundation/BURelyFoundationFoundation.xcframework" "BURelyFoundation/Foundation" "library" "ios-arm64_armv7" "ios-arm64_i386_x86_64-simulator" |
|
install_xcframework "${PODS_ROOT}/BURelyFoundation/Frameworks/SDK/BURelyFoundationGecko/BURelyFoundationGecko.xcframework" "BURelyFoundation/Gecko" "library" "ios-arm64_armv7" "ios-arm64_i386_x86_64-simulator" |
|
install_xcframework "${PODS_ROOT}/BURelyFoundation/Frameworks/SDK/HM/HM.xcframework" "BURelyFoundation/HM" "library" "ios-arm64_armv7" "ios-arm64_i386_x86_64-simulator" |
|
install_xcframework "${PODS_ROOT}/BURelyFoundation/Frameworks/SDK/BURelyFoundationNETWork/BURelyFoundationNETWork.xcframework" "BURelyFoundation/NETWork" "library" "ios-arm64_armv7" "ios-arm64_i386_x86_64-simulator" |
|
install_xcframework "${PODS_ROOT}/BURelyFoundation/Frameworks/SDK/BURelyFoundationSDWebImage/BURelyFoundationSDWebImage.xcframework" "BURelyFoundation/SDWebImage" "library" "ios-arm64_armv7" "ios-arm64_i386_x86_64-simulator" |
|
install_xcframework "${PODS_ROOT}/BURelyFoundation/Frameworks/SDK/ServiceKit/BUADServiceKit.xcframework" "BURelyFoundation/ServiceCenter" "library" "ios-arm64_armv7" "ios-arm64_i386_x86_64-simulator" |
|
install_xcframework "${PODS_ROOT}/BURelyFoundation/Frameworks/SDK/Ugen/Ugen.xcframework" "BURelyFoundation/Ugen" "library" "ios-arm64_armv7" "ios-arm64_i386_x86_64-simulator" |
|
install_xcframework "${PODS_ROOT}/BURelyFoundation/Frameworks/SDK/BURelyFoundationYYModel/BURelyFoundationYYModel.xcframework" "BURelyFoundation/YYModel" "library" "ios-arm64_armv7" "ios-arm64_i386_x86_64-simulator" |
|
install_xcframework "${PODS_ROOT}/BURelyFoundation/Frameworks/SDK/BURelyFoundationZFPlayer/BURelyFoundationZFPlayer.xcframework" "BURelyFoundation/ZFPlayer" "library" "ios-arm64_armv7" "ios-arm64_i386_x86_64-simulator" |
|
install_xcframework "${PODS_ROOT}/BURelyFoundation/Frameworks/SDK/BURelyFoundationZip/BURelyFoundationZip.xcframework" "BURelyFoundation/Zip" "library" "ios-arm64_armv7" "ios-arm64_i386_x86_64-simulator" |
|
|
|
|