Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/bin/bash | 1 #!/bin/bash |
| 2 | 2 |
| 3 # Copyright (c) 2009 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2009 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 # Copies a framework to its new home, "unversioning" it. | 7 # Copies a framework to its new home, "unversioning" it. |
| 8 # | 8 # |
| 9 # Normally, frameworks are versioned bundles. The contents of a framework are | 9 # Normally, frameworks are versioned bundles. The contents of a framework are |
| 10 # stored in a versioned directory within the bundle, and symbolic links | 10 # stored in a versioned directory within the bundle, and symbolic links |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 30 # original outer .framework directory as the framework that ships within the | 30 # original outer .framework directory as the framework that ships within the |
| 31 # .app, the inner versioned directory is used. Instead of accessing bundled | 31 # .app, the inner versioned directory is used. Instead of accessing bundled |
| 32 # resources through symbolic links, they are accessed directly. In normal | 32 # resources through symbolic links, they are accessed directly. In normal |
| 33 # situations, the only hard-coded use of the versioned directory is by dyld, | 33 # situations, the only hard-coded use of the versioned directory is by dyld, |
| 34 # when loading the framework's code, but this is handled through a normal | 34 # when loading the framework's code, but this is handled through a normal |
| 35 # Mach-O load command, and it is easy to adjust the load command to point to | 35 # Mach-O load command, and it is easy to adjust the load command to point to |
| 36 # the unversioned framework code rather than the versioned counterpart. | 36 # the unversioned framework code rather than the versioned counterpart. |
| 37 # | 37 # |
| 38 # The resulting framework bundles aren't strictly conforming, but they work | 38 # The resulting framework bundles aren't strictly conforming, but they work |
| 39 # as well as normal versioned framework bundles. | 39 # as well as normal versioned framework bundles. |
| 40 # | |
| 41 # An option to skip running install_name_tool is available. By passing -I as | |
| 42 # the first argument to this script, install_name_tool will be skipped. This | |
| 43 # is only suitable for copied frameworks that will not be linked against, or | |
| 44 # when install_name_tool will be run on any linker output when something is | |
| 45 # linked against the copied framework. This option exists to allow signed | |
| 46 # frameworks to pass through without subjecting them to any modifications that | |
| 47 # would break their signatures. | |
| 40 | 48 |
| 41 set -e | 49 set -e |
| 42 | 50 |
| 51 RUN_INSTALL_NAME_TOOL=1 | |
| 52 if [ $# -eq 3 ] && [ "${1}" = "-I" ] ; then | |
| 53 shift | |
| 54 RUN_INSTALL_NAME_TOOL= | |
| 55 fi | |
| 56 | |
| 43 if [ $# -ne 2 ] ; then | 57 if [ $# -ne 2 ] ; then |
| 44 echo "usage: ${0} FRAMEWORK DESTINATION_DIR" >& 2 | 58 echo "usage: ${0} [-I] FRAMEWORK DESTINATION_DIR" >& 2 |
| 45 exit 1 | 59 exit 1 |
| 46 fi | 60 fi |
| 47 | 61 |
| 48 # FRAMEWORK should be a path to a versioned framework bundle, ending in | 62 # FRAMEWORK should be a path to a versioned framework bundle, ending in |
| 49 # .framework. DESTINATION_DIR is the directory that the unversioned framework | 63 # .framework. DESTINATION_DIR is the directory that the unversioned framework |
| 50 # bundle will be copied to. | 64 # bundle will be copied to. |
| 51 | 65 |
| 52 FRAMEWORK="${1}" | 66 FRAMEWORK="${1}" |
| 53 DESTINATION_DIR="${2}" | 67 DESTINATION_DIR="${2}" |
| 54 | 68 |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 72 fi | 86 fi |
| 73 | 87 |
| 74 DESTINATION="${DESTINATION_DIR}/${FRAMEWORK_NAME}" | 88 DESTINATION="${DESTINATION_DIR}/${FRAMEWORK_NAME}" |
| 75 | 89 |
| 76 # Copy the versioned directory within the versioned framework to its | 90 # Copy the versioned directory within the versioned framework to its |
| 77 # destination location. | 91 # destination location. |
| 78 mkdir -p "${DESTINATION_DIR}" | 92 mkdir -p "${DESTINATION_DIR}" |
| 79 rsync -acC --delete --exclude Headers --exclude PrivateHeaders \ | 93 rsync -acC --delete --exclude Headers --exclude PrivateHeaders \ |
| 80 --include '*.so' "${CURRENT_VERSION}/" "${DESTINATION}" | 94 --include '*.so' "${CURRENT_VERSION}/" "${DESTINATION}" |
| 81 | 95 |
| 82 # Adjust the Mach-O LC_ID_DYLIB load command in the framework. This does not | 96 if [[ -n "${RUN_INSTALL_NAME_TOOL}" ]]; then |
| 83 # change the LC_LOAD_DYLIB load commands in anything that may have already | 97 # Adjust the Mach-O LC_ID_DYLIB load command in the framework. This does not |
| 84 # linked against the framework. Not all frameworks will actually need this | 98 # change the LC_LOAD_DYLIB load commands in anything that may have already |
| 85 # to be changed. Some frameworks may already be built with the proper | 99 # linked against the framework. Not all frameworks will actually need this |
| 86 # LC_ID_DYLIB for use as an unversioned framework. Xcode users can do this | 100 # to be changed. Some frameworks may already be built with the proper |
| 87 # by setting LD_DYLIB_INSTALL_NAME to | 101 # LC_ID_DYLIB for use as an unversioned framework. Xcode users can do this |
| 88 # $(DYLIB_INSTALL_NAME_BASE:standardizepath)/$(WRAPPER_NAME)/$(PRODUCT_NAME) | 102 # by setting LD_DYLIB_INSTALL_NAME to |
| 89 # If invoking ld via gcc or g++, pass the desired path to -Wl,-install_name | 103 # $(DYLIB_INSTALL_NAME_BASE:standardizepath)/$(WRAPPER_NAME)/$(PRODUCT_NAME) |
| 90 # at link time. | 104 # If invoking ld via gcc or g++, pass the desired path to -Wl,-install_name |
| 91 FRAMEWORK_DYLIB="${DESTINATION}/${FRAMEWORK_NAME_NOEXT}" | 105 # at link time. |
| 92 LC_ID_DYLIB_OLD="$(otool -l "${FRAMEWORK_DYLIB}" | | 106 FRAMEWORK_DYLIB="${DESTINATION}/${FRAMEWORK_NAME_NOEXT}" |
|
TVL
2012/06/06 20:00:44
part of me wonders if there is a way to use codesi
| |
| 93 grep -A10 "^ *cmd LC_ID_DYLIB$" | | 107 LC_ID_DYLIB_OLD="$(otool -l "${FRAMEWORK_DYLIB}" | |
| 94 grep -m1 "^ *name" | | 108 grep -A10 "^ *cmd LC_ID_DYLIB$" | |
| 95 sed -Ee 's/^ *name (.*) \(offset [0-9]+\)$/\1/')" | 109 grep -m1 "^ *name" | |
| 96 VERSION_PATH="/Versions/${CURRENT_VERSION_ID}/${FRAMEWORK_NAME_NOEXT}" | 110 sed -Ee 's/^ *name (.*) \(offset [0-9]+\)$/\1/')" |
| 97 LC_ID_DYLIB_NEW="$(echo "${LC_ID_DYLIB_OLD}" | | 111 VERSION_PATH="/Versions/${CURRENT_VERSION_ID}/${FRAMEWORK_NAME_NOEXT}" |
| 98 sed -Ee "s%${VERSION_PATH}$%/${FRAMEWORK_NAME_NOEXT}%")" | 112 LC_ID_DYLIB_NEW="$(echo "${LC_ID_DYLIB_OLD}" | |
| 113 sed -Ee "s%${VERSION_PATH}$%/${FRAMEWORK_NAME_NOEXT}%")" | |
| 99 | 114 |
| 100 if [ "${LC_ID_DYLIB_NEW}" != "${LC_ID_DYLIB_OLD}" ] ; then | 115 if [ "${LC_ID_DYLIB_NEW}" != "${LC_ID_DYLIB_OLD}" ] ; then |
| 101 install_name_tool -id "${LC_ID_DYLIB_NEW}" "${FRAMEWORK_DYLIB}" | 116 install_name_tool -id "${LC_ID_DYLIB_NEW}" "${FRAMEWORK_DYLIB}" |
| 117 fi | |
| 102 fi | 118 fi |
| OLD | NEW |