diff options
author | mark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-14 19:55:26 +0000 |
---|---|---|
committer | mark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-14 19:55:26 +0000 |
commit | 12f8872770bd2a8051490d05d8ba9a2c49402515 (patch) | |
tree | 04ddd2434b0904ed4a79e83343f149c89246362f /chrome/tools | |
parent | 46e55d2673f99087d7a5ba8159aea9b01239938c (diff) | |
download | chromium_src-12f8872770bd2a8051490d05d8ba9a2c49402515.zip chromium_src-12f8872770bd2a8051490d05d8ba9a2c49402515.tar.gz chromium_src-12f8872770bd2a8051490d05d8ba9a2c49402515.tar.bz2 |
Unversion frameworks
BUG=24823
TEST= - GC.app/Contents/Versions/GCF.framework should not contain any symlinks.
- GC.app/Contents/Versions/GCF.framework/Frameworks/KSR.framework
shouldn't either.
- There should only be three remaining symlinks in the entire GC.app
package, in each of three different Resources directories. Each of
the remaining symlinks should just be en.lproj -> en_US.lproj.
- The app should still run. Keystone should still operate. (Make sure
that Keystone does its up-to-date check in the About box.)
Review URL: http://codereview.chromium.org/278007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28999 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/tools')
-rwxr-xr-x | chrome/tools/build/mac/copy_framework_unversioned | 109 | ||||
-rwxr-xr-x | chrome/tools/build/mac/remove_headers_from_framework | 31 | ||||
-rw-r--r-- | chrome/tools/build/mac/sign.sh.in | 8 |
3 files changed, 114 insertions, 34 deletions
diff --git a/chrome/tools/build/mac/copy_framework_unversioned b/chrome/tools/build/mac/copy_framework_unversioned new file mode 100755 index 0000000..4223f67 --- /dev/null +++ b/chrome/tools/build/mac/copy_framework_unversioned @@ -0,0 +1,109 @@ +#!/bin/bash + +# Copyright (c) 2009 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# Copies a framework to its new home, "unversioning" it. +# +# Normally, frameworks are versioned bundles. The contents of a framework are +# stored in a versioned directory within the bundle, and symbolic links +# provide access to the actual code and resources. See +# http://developer.apple.com/mac/library/documentation/MacOSX/Conceptual/BPFrameworks/Concepts/FrameworkAnatomy.html +# +# The symbolic links usually found in frameworks create problems. Symbolic +# links are excluded from code signatures. That means that it's possible to +# remove or retarget a symbolic link within a framework without affecting the +# seal. In Chrome's case, the outer .app bundle contains a framework where +# all application code and resources live. In order for the signature on the +# .app to be meaningful, it encompasses the framework. Because framework +# resources are accessed through the framework's symbolic links, this +# arrangement results in a case where the resources can be altered without +# affecting the .app signature's validity. +# +# Indirection through symbolic links also carries a runtime performance +# penalty on open() operations, although open() typically completes so quickly +# that this is not considered a major performance problem. +# +# To resolve these problems, the frameworks that ship within Chrome's .app +# bundle are unversioned. Unversioning is simple: instead of using the +# original outer .framework directory as the framework that ships within the +# .app, the inner versioned directory is used. Instead of accessing bundled +# resources through symbolic links, they are accessed directly. In normal +# situations, the only hard-coded use of the versioned directory is by dyld, +# when loading the framework's code, but this is handled through a normal +# Mach-O load command, and it is easy to adjust the load command to point to +# the unversioned framework code rather than the versioned counterpart. +# +# The resulting framework bundles aren't strictly conforming, but they work +# as well as normal versioned framework bundles. + +set -e + +if [ $# -ne 2 ] ; then + echo "usage: ${0} FRAMEWORK DESTINATION_DIR" >& 2 + exit 1 +fi + +# FRAMEWORK should be a path to a versioned framework bundle, ending in +# .framework. DESTINATION_DIR is the directory that the unversioned framework +# bundle will be copied to. + +FRAMEWORK="${1}" +DESTINATION_DIR="${2}" + +FRAMEWORK_NAME="$(basename "${FRAMEWORK}")" +if [ "${FRAMEWORK_NAME: -10}" != ".framework" ] ; then + echo "${0}: ${FRAMEWORK_NAME} does not end in .framework" >& 2 + exit 1 +fi +FRAMEWORK_NAME_NOEXT="${FRAMEWORK_NAME:0:$((${#FRAMEWORK_NAME} - 10))}" + +# Find the current version. +VERSIONS="${FRAMEWORK}/Versions" +CURRENT_VERSION_LINK="${VERSIONS}/Current" +CURRENT_VERSION_ID="$(readlink "${VERSIONS}/Current")" +CURRENT_VERSION="${VERSIONS}/${CURRENT_VERSION_ID}" + +# Make sure that the framework's structure makes sense as a versioned bundle. +if [ ! -e "${CURRENT_VERSION}/${FRAMEWORK_NAME_NOEXT}" ] ; then + echo "${0}: ${FRAMEWORK_NAME} does not contain a dylib" >& 2 + exit 1 +fi + +DESTINATION="${DESTINATION_DIR}/${FRAMEWORK_NAME}" + +# Copy the versioned directory within the versioned framework to its +# destination location. +mkdir -p "${DESTINATION_DIR}" +rsync -ac --delete --exclude Headers --exclude PrivateHeaders \ + "${CURRENT_VERSION}/" "${DESTINATION}" + +# The --exclude will prevent Headers and PrivateHeaders from showing up in +# ${DESTINATION} in clobber builds, but if they are already present in older +# builds, they will not be removed. Remove them manually. +# TODO(mark): Remove this after October 28, 2009, allowing two weeks for the +# transition. +rm -rf -- "${DESTINATION}/Headers" "${DESTINATION}/PrivateHeaders" + +# Adjust the Mach-O LC_ID_DYLIB load command in the framework. This does not +# change the LC_LOAD_DYLIB load commands in anything that may have already +# linked against the framework. Not all frameworks will actually need this +# to be changed. Some frameworks may already be built with the proper +# LC_ID_DYLIB for use as an unversioned framework. Xcode users can do this +# by setting LD_DYLIB_INSTALL_NAME to +# $(DYLIB_INSTALL_NAME_BASE:standardizepath)/$(WRAPPER_NAME)/$(PRODUCT_NAME) +# If invoking ld via gcc or g++, pass the desired path to -Wl,-install_name +# at link time. +FRAMEWORK_DYLIB="${DESTINATION}/${FRAMEWORK_NAME_NOEXT}" +LC_ID_DYLIB_OLD="$(otool -l "${FRAMEWORK_DYLIB}" | + grep -A10 "^ *cmd LC_ID_DYLIB$" | + grep -m1 "^ *name" | + sed -Ee 's/^ *name (.*) \(offset [0-9]+\)$/\1/')" +VERSION_PATH="/Versions/${CURRENT_VERSION_ID}/${FRAMEWORK_NAME_NOEXT}" +LC_ID_DYLIB_NEW="$(echo "${LC_ID_DYLIB_OLD}" | + sed -Ee "s%${VERSION_PATH}$%/${FRAMEWORK_NAME_NOEXT}%")" + +if [ "${LC_ID_DYLIB_NEW}" != "${LC_ID_DYLIB_OLD}" ] ; then + install_name_tool -id "${LC_ID_DYLIB_NEW}" "${FRAMEWORK_DYLIB}" +fi diff --git a/chrome/tools/build/mac/remove_headers_from_framework b/chrome/tools/build/mac/remove_headers_from_framework deleted file mode 100755 index c48fd1f..0000000 --- a/chrome/tools/build/mac/remove_headers_from_framework +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/sh - -# Copyright (c) 2009 The Chromium Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# Frameworks included in an application for distribution aren't used for -# development, and don't need to bundle any headers. - -set -e - -if [ $# -ne 1 ] ; then - echo "usage: ${0} FRAMEWORK" >& 2 - exit 1 -fi - -FRAMEWORK="${1}" - -rm -rf -- "${FRAMEWORK}/Versions/Current/Headers" \ - "${FRAMEWORK}/Versions/Current/PrivateHeaders" \ - "${FRAMEWORK}/Headers" \ - "${FRAMEWORK}/PrivateHeaders" - -# Remove other-versioned headers after current-version headers, in case Current -# is a symbolic link to another version, as is the usual case. If everything -# was done in a single invocation, the shell would do the wildcard expansion -# first, and rm would try (and fail) to remove the same directory twice, such -# as Versions/Current/Headers and Versions/A/Headers when Versions/Current is -# a symbolic link for A. -rm -rf -- "${FRAMEWORK}"/Versions/*/Headers \ - "${FRAMEWORK}"/Versions/*/PrivateHeaders diff --git a/chrome/tools/build/mac/sign.sh.in b/chrome/tools/build/mac/sign.sh.in index 07a7593..18c8197 100644 --- a/chrome/tools/build/mac/sign.sh.in +++ b/chrome/tools/build/mac/sign.sh.in @@ -21,12 +21,14 @@ CODESIGN_ID="${3}" # Use custom resource rules for the browser application. BROWSER_APP_RULES="$(dirname "${0}")/app_resource_rules.plist" -# An .app bundle to be signed can be signed directly. Signging a framework -# bundle requires that each version within be signed individually. +# An .app bundle to be signed can be signed directly. Normally, signging a +# framework bundle requires that each version within be signed individually. # http://developer.apple.com/mac/library/technotes/tn2007/tn2206.html#TNTAG13 +# In Chrome's case, the framework bundle is unversioned, so it too can be +# signed directly. See copy_framework_unversioned. BROWSER_APP="${APP_PATH}" -FRAMEWORK="${BROWSER_APP}/Contents/Versions/@VERSION@/@MAC_PRODUCT_NAME@ Framework.framework/Versions/A" +FRAMEWORK="${BROWSER_APP}/Contents/Versions/@VERSION@/@MAC_PRODUCT_NAME@ Framework.framework" HELPER_APP="${BROWSER_APP}/Contents/Versions/@VERSION@/@MAC_PRODUCT_NAME@ Helper.app" echo "${0}: signing..." |