"#!/bin/sh\nset -e\nset -u\nset -o pipefail\n\nfunction on_error {\n echo \"$(realpath -mq \"${0}\"):$1: error: Unexpected failure\"\n}\ntrap 'on_error $LINENO' ERR\n".strip_heredoc.freeze
- RSYNC_PROTECT_TMP_FILES =
"# This protects against multiple targets copying the same framework dependency at the same time. The solution\n# was originally proposed here: https://lists.samba.org/archive/rsync/2008-February/020158.html\nRSYNC_PROTECT_TMP_FILES=(--filter \"P .*.??????\")\n".strip_heredoc.freeze
- STRIP_INVALID_ARCHITECTURES_METHOD =
"# Used as a return value for each invocation of `strip_invalid_archs` function.\nSTRIP_BINARY_RETVAL=0\n\n# Strip invalid architectures\nstrip_invalid_archs() {\n binary=\"$1\"\n warn_missing_arch=${2:-true}\n # Get architectures for current target binary\n binary_archs=\"$(lipo -info \"$binary\" | rev | cut -d ':' -f1 | awk '{$1=$1;print}' | rev)\"\n # Intersect them with the architectures we are building for\n intersected_archs=\"$(echo ${ARCHS[@]} ${binary_archs[@]} | tr ' ' '\\\\n' | sort | uniq -d)\"\n # If there are no archs supported by this binary then warn the user\n if [[ -z \"$intersected_archs\" ]]; then\n if [[ \"$warn_missing_arch\" == \"true\" ]]; then\necho \"warning: [CP] Vendored binary '$binary' contains architectures ($binary_archs) none of which match the current build architectures ($ARCHS).\"\n fi\n STRIP_BINARY_RETVAL=1\n return\n fi\n stripped=\"\"\n for arch in $binary_archs; do\n if ! [[ \"${ARCHS}\" == *\"$arch\"* ]]; then\n# Strip non-valid architectures in-place\nlipo -remove \"$arch\" -output \"$binary\" \"$binary\"\nstripped=\"$stripped $arch\"\n fi\n done\n if [[ \"$stripped\" ]]; then\n echo \"Stripped $binary of architectures:$stripped\"\n fi\n STRIP_BINARY_RETVAL=0\n}\n".strip_heredoc.freeze
- INSTALL_DSYM_METHOD =
"# Copies and strips a vendored dSYM\ninstall_dsym() {\n local source=\"$1\"\n warn_missing_arch=${2:-true}\n if [ -r \"$source\" ]; then\n # Copy the dSYM into the targets temp dir.\n echo \"rsync --delete -av \"${RSYNC_PROTECT_TMP_FILES[@]}\" --filter \\\\\"- CVS/\\\\\" --filter \\\\\"- .svn/\\\\\" --filter \\\\\"- .git/\\\\\" --filter \\\\\"- .hg/\\\\\" --filter \\\\\"- Headers\\\\\" --filter \\\\\"- PrivateHeaders\\\\\" --filter \\\\\"- Modules\\\\\" \\\\\"${source}\\\\\" \\\\\"${DERIVED_FILES_DIR}\\\\\"\"\n rsync --delete -av \"${RSYNC_PROTECT_TMP_FILES[@]}\" --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${DERIVED_FILES_DIR}\"\n\n local basename\n basename=\"$(basename -s .dSYM \"$source\")\"\n binary_name=\"$(ls \"$source/Contents/Resources/DWARF\")\"\n binary=\"${DERIVED_FILES_DIR}/${basename}.dSYM/Contents/Resources/DWARF/${binary_name}\"\n\n # Strip invalid architectures from the dSYM.\n if [[ \"$(file \"$binary\")\" == *\"Mach-O \"*\"dSYM companion\"* ]]; then\nstrip_invalid_archs \"$binary\" \"$warn_missing_arch\"\n fi\n if [[ $STRIP_BINARY_RETVAL == 0 ]]; then\n# Move the stripped file into its final destination.\necho \"rsync --delete -av \"${RSYNC_PROTECT_TMP_FILES[@]}\" --links --filter \\\\\"- CVS/\\\\\" --filter \\\\\"- .svn/\\\\\" --filter \\\\\"- .git/\\\\\" --filter \\\\\"- .hg/\\\\\" --filter \\\\\"- Headers\\\\\" --filter \\\\\"- PrivateHeaders\\\\\" --filter \\\\\"- Modules\\\\\" \\\\\"${DERIVED_FILES_DIR}/${basename}.framework.dSYM\\\\\" \\\\\"${DWARF_DSYM_FOLDER_PATH}\\\\\"\"\nrsync --delete -av \"${RSYNC_PROTECT_TMP_FILES[@]}\" --links --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${DERIVED_FILES_DIR}/${basename}.dSYM\" \"${DWARF_DSYM_FOLDER_PATH}\"\n else\n# The dSYM was not stripped at all, in this case touch a fake folder so the input/output paths from Xcode do not reexecute this script because the file is missing.\nmkdir -p \"${DWARF_DSYM_FOLDER_PATH}\"\ntouch \"${DWARF_DSYM_FOLDER_PATH}/${basename}.dSYM\"\n fi\n fi\n}\n".strip_heredoc.freeze
- INSTALL_BCSYMBOLMAP_METHOD =
"# Copies the bcsymbolmap files of a vendored framework\ninstall_bcsymbolmap() {\n local bcsymbolmap_path=\"$1\"\n local destination=\"${BUILT_PRODUCTS_DIR}\"\n echo \"rsync --delete -av \"${RSYNC_PROTECT_TMP_FILES[@]}\" --filter \\\"- CVS/\\\" --filter \\\"- .svn/\\\" --filter \\\"- .git/\\\" --filter \\\"- .hg/\\\" --filter \\\"- Headers\\\" --filter \\\"- PrivateHeaders\\\" --filter \\\"- Modules\\\" \\\"${bcsymbolmap_path}\\\" \\\"${destination}\\\"\"\n rsync --delete -av \"${RSYNC_PROTECT_TMP_FILES[@]}\" --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${bcsymbolmap_path}\" \"${destination}\"\n}\n".strip_heredoc.freeze