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