michael@0: #!/bin/bash michael@0: michael@0: # Copyright (c) 2008 The Chromium Authors. All rights reserved. michael@0: # Use of this source code is governed by a BSD-style license that can be michael@0: # found in the LICENSE file. michael@0: michael@0: # This is a handy wrapper script that figures out how to call the strip michael@0: # utility (strip_save_dsym in this case), if it even needs to be called at all, michael@0: # and then does it. This script should be called by a post-link phase in michael@0: # targets that might generate Mach-O executables, dynamic libraries, or michael@0: # loadable bundles. michael@0: # michael@0: # An example "Strip If Needed" build phase placed after "Link Binary With michael@0: # Libraries" would do: michael@0: # exec "${XCODEPROJ_DEPTH}/build/mac/strip_from_xcode" michael@0: michael@0: if [ "${CONFIGURATION}" != "Release" ] ; then michael@0: # Only strip in release mode. michael@0: exit 0 michael@0: fi michael@0: michael@0: declare -a FLAGS michael@0: michael@0: # MACH_O_TYPE is not set for a command-line tool, so check PRODUCT_TYPE too. michael@0: # Weird. michael@0: if [ "${MACH_O_TYPE}" = "mh_execute" ] || \ michael@0: [ "${PRODUCT_TYPE}" = "com.apple.product-type.tool" ] ; then michael@0: # Strip everything (no special flags). No-op. michael@0: true michael@0: elif [ "${MACH_O_TYPE}" = "mh_dylib" ] || \ michael@0: [ "${MACH_O_TYPE}" = "mh_bundle" ]; then michael@0: # Strip debugging symbols and local symbols michael@0: FLAGS[${#FLAGS[@]}]=-S michael@0: FLAGS[${#FLAGS[@]}]=-x michael@0: elif [ "${MACH_O_TYPE}" = "staticlib" ] ; then michael@0: # Don't strip static libraries. michael@0: exit 0 michael@0: else michael@0: # Warn, but don't treat this as an error. michael@0: echo $0: warning: unrecognized MACH_O_TYPE ${MACH_O_TYPE} michael@0: exit 0 michael@0: fi michael@0: michael@0: if [ -n "${STRIPFLAGS}" ] ; then michael@0: # Pick up the standard STRIPFLAGS Xcode setting, used for "Additional Strip michael@0: # Flags". michael@0: for stripflag in "${STRIPFLAGS}" ; do michael@0: FLAGS[${#FLAGS[@]}]="${stripflag}" michael@0: done michael@0: fi michael@0: michael@0: if [ -n "${CHROMIUM_STRIP_SAVE_FILE}" ] ; then michael@0: # An Xcode project can communicate a file listing symbols to saved in this michael@0: # environment variable by setting it as a build setting. This isn't a michael@0: # standard Xcode setting. It's used in preference to STRIPFLAGS to michael@0: # eliminate quoting ambiguity concerns. michael@0: FLAGS[${#FLAGS[@]}]=-s michael@0: FLAGS[${#FLAGS[@]}]="${CHROMIUM_STRIP_SAVE_FILE}" michael@0: fi michael@0: michael@0: exec "$(dirname ${0})/strip_save_dsym" "${FLAGS[@]}" \ michael@0: "${BUILT_PRODUCTS_DIR}/${EXECUTABLE_PATH}"