Module: Pod::Generator::ScriptPhaseConstants

Defined in:
lib/cocoapods/generator/script_phase_constants.rb

Constant Summary collapse

DEFAULT_SCRIPT_PHASE_HEADER =
"#!/bin/sh\nset -e\nset -u\nset -o pipefail\n\nfunction on_error {\necho \"$(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() {\nbinary=\"$1\"\nwarn_missing_arch=${2:-true}\n# Get architectures for current target binary\nbinary_archs=\"$(lipo -info \"$binary\" | rev | cut -d ':' -f1 | awk '{$1=$1;print}' | rev)\"\n# Intersect them with the architectures we are building for\nintersected_archs=\"$(echo ${ARCHS[@]} ${binary_archs[@]} | tr ' ' '\\\\n' | sort | uniq -d)\"\n# If there are no archs supported by this binary then warn the user\nif [[ -z \"$intersected_archs\" ]]; then\nif [[ \"$warn_missing_arch\" == \"true\" ]]; then\necho \"warning: [CP] Vendored binary '$binary' contains architectures ($binary_archs) none of which match the current build architectures ($ARCHS).\"\nfi\nSTRIP_BINARY_RETVAL=1\nreturn\nfi\nstripped=\"\"\nfor arch in $binary_archs; do\nif ! [[ \"${ARCHS}\" == *\"$arch\"* ]]; then\n# Strip non-valid architectures in-place\nlipo -remove \"$arch\" -output \"$binary\" \"$binary\"\nstripped=\"$stripped $arch\"\nfi\ndone\nif [[ \"$stripped\" ]]; then\necho \"Stripped $binary of architectures:$stripped\"\nfi\nSTRIP_BINARY_RETVAL=0\n}\n".strip_heredoc.freeze
INSTALL_DSYM_METHOD =
"# Copies and strips a vendored dSYM\ninstall_dsym() {\nlocal source=\"$1\"\nwarn_missing_arch=${2:-true}\nif [ -r \"$source\" ]; then\n# Copy the dSYM into the targets temp dir.\necho \"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}\\\\\"\"\nrsync --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\nlocal basename\nbasename=\"$(basename -s .dSYM \"$source\")\"\nbinary_name=\"$(ls \"$source/Contents/Resources/DWARF\")\"\nbinary=\"${DERIVED_FILES_DIR}/${basename}.dSYM/Contents/Resources/DWARF/${binary_name}\"\n\n# Strip invalid architectures from the dSYM.\nif [[ \"$(file \"$binary\")\" == *\"Mach-O \"*\"dSYM companion\"* ]]; then\nstrip_invalid_archs \"$binary\" \"$warn_missing_arch\"\nfi\nif [[ $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}\"\nelse\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\"\nfi\nfi\n}\n".strip_heredoc.freeze
INSTALL_BCSYMBOLMAP_METHOD =
"# Copies the bcsymbolmap files of a vendored framework\ninstall_bcsymbolmap() {\nlocal bcsymbolmap_path=\"$1\"\nlocal destination=\"${BUILT_PRODUCTS_DIR}\"\necho \"rsync --delete -av \"${RSYNC_PROTECT_TMP_FILES[@]}\" --filter \\\"- CVS/\\\" --filter \\\"- .svn/\\\" --filter \\\"- .git/\\\" --filter \\\"- .hg/\\\" --filter \\\"- Headers\\\" --filter \\\"- PrivateHeaders\\\" --filter \\\"- Modules\\\" \\\"${bcsymbolmap_path}\\\" \\\"${destination}\\\"\"\nrsync --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