Wed, 31 Dec 2014 13:27:57 +0100
Ignore runtime configuration files generated during quality assurance.
michael@0 | 1 | #!/bin/bash |
michael@0 | 2 | |
michael@0 | 3 | # Copyright (c) 2008 The Chromium Authors. All rights reserved. |
michael@0 | 4 | # Use of this source code is governed by a BSD-style license that can be |
michael@0 | 5 | # found in the LICENSE file. |
michael@0 | 6 | |
michael@0 | 7 | # This is a handy wrapper script that figures out how to call the strip |
michael@0 | 8 | # utility (strip_save_dsym in this case), if it even needs to be called at all, |
michael@0 | 9 | # and then does it. This script should be called by a post-link phase in |
michael@0 | 10 | # targets that might generate Mach-O executables, dynamic libraries, or |
michael@0 | 11 | # loadable bundles. |
michael@0 | 12 | # |
michael@0 | 13 | # An example "Strip If Needed" build phase placed after "Link Binary With |
michael@0 | 14 | # Libraries" would do: |
michael@0 | 15 | # exec "${XCODEPROJ_DEPTH}/build/mac/strip_from_xcode" |
michael@0 | 16 | |
michael@0 | 17 | if [ "${CONFIGURATION}" != "Release" ] ; then |
michael@0 | 18 | # Only strip in release mode. |
michael@0 | 19 | exit 0 |
michael@0 | 20 | fi |
michael@0 | 21 | |
michael@0 | 22 | declare -a FLAGS |
michael@0 | 23 | |
michael@0 | 24 | # MACH_O_TYPE is not set for a command-line tool, so check PRODUCT_TYPE too. |
michael@0 | 25 | # Weird. |
michael@0 | 26 | if [ "${MACH_O_TYPE}" = "mh_execute" ] || \ |
michael@0 | 27 | [ "${PRODUCT_TYPE}" = "com.apple.product-type.tool" ] ; then |
michael@0 | 28 | # Strip everything (no special flags). No-op. |
michael@0 | 29 | true |
michael@0 | 30 | elif [ "${MACH_O_TYPE}" = "mh_dylib" ] || \ |
michael@0 | 31 | [ "${MACH_O_TYPE}" = "mh_bundle" ]; then |
michael@0 | 32 | # Strip debugging symbols and local symbols |
michael@0 | 33 | FLAGS[${#FLAGS[@]}]=-S |
michael@0 | 34 | FLAGS[${#FLAGS[@]}]=-x |
michael@0 | 35 | elif [ "${MACH_O_TYPE}" = "staticlib" ] ; then |
michael@0 | 36 | # Don't strip static libraries. |
michael@0 | 37 | exit 0 |
michael@0 | 38 | else |
michael@0 | 39 | # Warn, but don't treat this as an error. |
michael@0 | 40 | echo $0: warning: unrecognized MACH_O_TYPE ${MACH_O_TYPE} |
michael@0 | 41 | exit 0 |
michael@0 | 42 | fi |
michael@0 | 43 | |
michael@0 | 44 | if [ -n "${STRIPFLAGS}" ] ; then |
michael@0 | 45 | # Pick up the standard STRIPFLAGS Xcode setting, used for "Additional Strip |
michael@0 | 46 | # Flags". |
michael@0 | 47 | for stripflag in "${STRIPFLAGS}" ; do |
michael@0 | 48 | FLAGS[${#FLAGS[@]}]="${stripflag}" |
michael@0 | 49 | done |
michael@0 | 50 | fi |
michael@0 | 51 | |
michael@0 | 52 | if [ -n "${CHROMIUM_STRIP_SAVE_FILE}" ] ; then |
michael@0 | 53 | # An Xcode project can communicate a file listing symbols to saved in this |
michael@0 | 54 | # environment variable by setting it as a build setting. This isn't a |
michael@0 | 55 | # standard Xcode setting. It's used in preference to STRIPFLAGS to |
michael@0 | 56 | # eliminate quoting ambiguity concerns. |
michael@0 | 57 | FLAGS[${#FLAGS[@]}]=-s |
michael@0 | 58 | FLAGS[${#FLAGS[@]}]="${CHROMIUM_STRIP_SAVE_FILE}" |
michael@0 | 59 | fi |
michael@0 | 60 | |
michael@0 | 61 | exec "$(dirname ${0})/strip_save_dsym" "${FLAGS[@]}" \ |
michael@0 | 62 | "${BUILT_PRODUCTS_DIR}/${EXECUTABLE_PATH}" |