Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/bin/bash | 1 #!/bin/bash |
| 2 | 2 |
| 3 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2013 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 # For app bundles built with ASan, copies the runtime lib | 7 # For app bundles built with ASan, copies the runtime lib |
| 8 # (libclang_rt.asan_osx_dynamic.dylib), on which their executables depend, from | 8 # (libclang_rt.asan_osx_dynamic.dylib), on which their executables depend, from |
| 9 # the compiler installation path to appname.app/Contents/Resources and fixes the | 9 # the compiler installation path to appname.app/Contents/Resources and fixes the |
| 10 # dylib's install name in the binary to be relative to @executable_path. | 10 # dylib's install name in the binary to be relative to @executable_path. |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 28 # runtime in ASan. | 28 # runtime in ASan. |
| 29 exit 0 | 29 exit 0 |
| 30 fi | 30 fi |
| 31 | 31 |
| 32 DYLIB_BASENAME=$(basename "${ASAN_DYLIB}") | 32 DYLIB_BASENAME=$(basename "${ASAN_DYLIB}") |
| 33 if [[ "${DYLIB_BASENAME}" != "${ASAN_DYLIB_NAME}" ]]; then | 33 if [[ "${DYLIB_BASENAME}" != "${ASAN_DYLIB_NAME}" ]]; then |
| 34 echo "basename(${ASAN_DYLIB}) != ${ASAN_DYLIB_NAME}" >&2 | 34 echo "basename(${ASAN_DYLIB}) != ${ASAN_DYLIB_NAME}" >&2 |
| 35 exit 1 | 35 exit 1 |
| 36 fi | 36 fi |
| 37 | 37 |
| 38 LIBRARIES_DIR="$(dirname "${BINARY_DIR}")/Libraries" | 38 # Check whether the directory containing the executable binary has an .app |
| 39 mkdir -p "${LIBRARIES_DIR}" | 39 # extension. In this case we're probably building an iOS gtest app, |
| 40 # otherwise it is a regular OSX application. | |
| 41 BINARY_DIR_EXT=$(echo "${BINARY_DIR}" | sed 's/^.*\.//') | |
|
Nico
2013/06/28 19:11:40
I don't think that's the right check. From what I
Alexander Potapenko
2013/07/01 08:35:01
The binary resides in Contents/MacOS, how about ch
| |
| 42 if [ "$BINARY_DIR_EXT" != "app" ]; then | |
| 43 LIBRARIES_DIR="$(dirname "${BINARY_DIR}")/Libraries" | |
| 44 mkdir -p "${LIBRARIES_DIR}" | |
| 45 NEW_LC_ID_DYLIB="@executable_path/../Libraries/${ASAN_DYLIB_NAME}" | |
| 46 else | |
| 47 LIBRARIES_DIR="${BINARY_DIR}" | |
| 48 NEW_LC_ID_DYLIB="@executable_path/${ASAN_DYLIB_NAME}" | |
| 49 fi | |
| 50 | |
| 40 cp "${ASAN_DYLIB}" "${LIBRARIES_DIR}" | 51 cp "${ASAN_DYLIB}" "${LIBRARIES_DIR}" |
| 41 | 52 |
| 42 NEW_LC_ID_DYLIB="@executable_path/../Libraries/${ASAN_DYLIB_NAME}" | |
| 43 | |
| 44 # Make LC_ID_DYLIB of the runtime copy point to its location. | 53 # Make LC_ID_DYLIB of the runtime copy point to its location. |
| 45 install_name_tool \ | 54 install_name_tool \ |
| 46 -id "${NEW_LC_ID_DYLIB}" \ | 55 -id "${NEW_LC_ID_DYLIB}" \ |
| 47 "${LIBRARIES_DIR}/${ASAN_DYLIB_NAME}" | 56 "${LIBRARIES_DIR}/${ASAN_DYLIB_NAME}" |
| 48 | 57 |
| 49 # Fix the rpath to the runtime library recorded in the binary. | 58 # Fix the rpath to the runtime library recorded in the binary. |
| 50 install_name_tool \ | 59 install_name_tool \ |
| 51 -change "${BUILTIN_DYLIB_PATH}" \ | 60 -change "${BUILTIN_DYLIB_PATH}" \ |
| 52 "${NEW_LC_ID_DYLIB}" \ | 61 "${NEW_LC_ID_DYLIB}" \ |
| 53 "${BINARY}" | 62 "${BINARY}" |
| OLD | NEW |