| 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 |
| 12 BINARY="${BUILT_PRODUCTS_DIR}/${EXECUTABLE_PATH}" |
| 13 BINARY_PATH="$(dirname "${BINARY}")" |
| 14 RUNTIME_PATTERN="asan_osx_dynamic.dylib" |
| 15 RUNTIME_LIB="$(otool -L "${BINARY}" | |
| 16 grep "${RUNTIME_PATTERN}" | |
| 17 tr -d '\011' | # remove leading tab |
| 18 sed "s/${RUNTIME_PATTERN}.*/${RUNTIME_PATTERN}/")" |
| 19 if [ -z "${RUNTIME_LIB}" ] |
| 20 then |
| 21 # TODO(glider): report an error here once we switch to ASan with dynamic |
| 22 # runtime. |
| 23 exit 0 |
| 24 fi |
| 25 |
| 26 RUNTIME_FNAME="$(basename "${RUNTIME_LIB}")" |
| 27 cp "${RUNTIME_LIB}" "${BINARY_PATH}" |
| 28 install_name_tool \ |
| 29 -change "${RUNTIME_LIB}" "@executable_path/${RUNTIME_FNAME}" "${BINARY}" |
| OLD | NEW |