Chromium Code Reviews
|
| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #!/bin/bash | |
| 2 | |
|
Mark Mentovai
2013/03/06 17:03:19
Copyright boilerplate goes here.
Alexander Potapenko
2013/03/07 08:29:22
Done.
| |
| 3 # For app bundles built with ASan, copies the runtime lib | |
| 4 # (libclang_rt.asan_osx_dynamic.dylib), on which their executables depend, from | |
| 5 # the compiler installation path to appname.app/Contents/Resources and fixes the | |
| 6 # dylib's install name in the binary to be relative to @executable_path. | |
| 7 | |
| 8 set -e | |
| 9 set -x | |
|
Mark Mentovai
2013/03/06 17:03:19
set -ex is fine for both of these.
Alexander Potapenko
2013/03/07 08:29:22
I actually don't need -x, it was only used for deb
| |
| 10 | |
| 11 BINARY="${BUILT_PRODUCTS_DIR}/${EXECUTABLE_PATH}" | |
| 12 BINARY_DIR="$(dirname "${BINARY}")" | |
| 13 ASAN_DYLIB_NAME=libclang_rt.asan_osx_dynamic.dylib | |
| 14 ASAN_DYLIB=$(find \ | |
|
Mark Mentovai
2013/03/06 17:03:19
Again, this is really hokey. Can we get a fixed pa
Alexander Potapenko
2013/03/07 08:29:22
I'll look into this.
| |
| 15 "${BUILT_PRODUCTS_DIR}/../../third_party/llvm-build/Release+Asserts/lib/clan g/" \ | |
| 16 -type f -path "*${ASAN_DYLIB_NAME}") | |
| 17 BUILTIN_DYLIB_PATH=$(otool -L "${BINARY}" | \ | |
| 18 grep "${ASAN_DYLIB_NAME}" | \ | |
|
Mark Mentovai
2013/03/06 17:03:19
grep -F to prevent it from being treated as a regu
Alexander Potapenko
2013/03/07 08:29:22
Decided to replace with sed.
| |
| 19 tr -d '\011' | \ | |
| 20 sed 's/dylib .*/dylib/') | |
|
Mark Mentovai
2013/03/06 17:03:19
Or you can combine the grep, tr, and sed into one
Alexander Potapenko
2013/03/07 08:29:22
Done.
| |
| 21 | |
| 22 if [ -z "${BUILTIN_DYLIB_PATH}" ] | |
|
Mark Mentovai
2013/03/06 17:03:19
1. Use [[ instead of [.
2. Put the “then” on the
Alexander Potapenko
2013/03/07 08:29:22
Done.
| |
| 23 then | |
| 24 echo "${BINARY} does not depend on the ASan runtime library!" | |
|
Mark Mentovai
2013/03/06 17:03:19
Send this to stderr with >&2. Same on line 32.
Alexander Potapenko
2013/03/07 08:29:22
Done.
| |
| 25 # TODO(glider): make this return 1 when we fully switch to the dynamic | |
| 26 # runtime in ASan. | |
| 27 exit 0 | |
| 28 fi | |
| 29 | |
| 30 if [ "$(basename ${ASAN_DYLIB})" != "${ASAN_DYLIB_NAME}" ] | |
|
Mark Mentovai
2013/03/06 17:03:19
You should put quotes around ${ASAN_DYLIB} here.
Alexander Potapenko
2013/03/07 08:29:22
Done.
| |
| 31 then | |
| 32 echo "basename(${ASAN_DYLIB}) != ${ASAN_DYLIB_NAME}" | |
| 33 exit 1 | |
| 34 fi | |
| 35 | |
| 36 RESOURCES_DIR="$(dirname "${BINARY_DIR}")/Resources" | |
|
Mark Mentovai
2013/03/06 17:03:19
This isn’t really a resource and does not belong i
Alexander Potapenko
2013/03/07 08:29:22
Done.
| |
| 37 mkdir -p "${RESOURCES_DIR}" | |
| 38 cp "${ASAN_DYLIB}" "${RESOURCES_DIR}" | |
| 39 | |
| 40 install_name_tool \ | |
|
Mark Mentovai
2013/03/06 17:03:19
You might as well also change the LC_ID_DYLIB in $
Alexander Potapenko
2013/03/07 08:29:22
Good idea. Done.
| |
| 41 -change "${BUILTIN_DYLIB_PATH}" \ | |
| 42 "@executable_path/../Resources/${ASAN_DYLIB_NAME}" \ | |
| 43 "${BINARY}" | |
| OLD | NEW |