OLD | NEW |
(Empty) | |
| 1 #!/bin/bash |
| 2 |
| 3 # For executables built with ASan, copies the runtime lib |
| 4 # (libclang_rt.asan_osx_dynamic.dylib) on which they depend from the compiler |
| 5 # installation path to the build dir and fixes the dylib's install name in the |
| 6 # binary to be relative to @executable_path. This is needed if the executables |
| 7 # are copied to a different machine (the ASan runtime library must be copied in |
| 8 # this case as well). |
| 9 |
| 10 set -e |
| 11 set -x |
| 12 |
| 13 BINARY="${BUILT_PRODUCTS_DIR}/${EXECUTABLE_PATH}" |
| 14 BINARY_PATH="$(dirname "${BINARY}")" |
| 15 RUNTIME_PATTERN="asan_osx_dynamic.dylib" |
| 16 RUNTIME_LIB="$(otool -L "${BINARY}" | |
| 17 grep "${RUNTIME_PATTERN}" | |
| 18 tr -d '\011' | # remove leading tab |
| 19 sed "s/${RUNTIME_PATTERN}.*/${RUNTIME_PATTERN}/")" |
| 20 if [ -z "${RUNTIME_LIB}" ] |
| 21 then |
| 22 # TODO(glider): report an error here once we switch to ASan with dynamic |
| 23 # runtime. |
| 24 exit 0 |
| 25 fi |
| 26 |
| 27 RUNTIME_FNAME="$(basename "${RUNTIME_LIB}")" |
| 28 cp "${RUNTIME_LIB}" "${BINARY_PATH}" |
| 29 #install_name_tool \ |
| 30 # -change "${RUNTIME_LIB}" "@executable_path/${RUNTIME_FNAME}" "${BINARY}" |
| 31 touch "${BINARY_PATH}"/"${RUNTIME_LIB}" |
OLD | NEW |