aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/cpp
diff options
context:
space:
mode:
authorGravatar hlopko <hlopko@google.com>2017-10-10 17:49:07 +0200
committerGravatar Marcel Hlopko <hlopko@google.com>2017-10-11 10:56:45 +0200
commit0257c29f496719bb8414d012334155de6bbefa11 (patch)
tree9dd202e76dc8d62e025d61140f319354542a77ba /tools/cpp
parent7c672ac643dd59bf4b3e284c6ad019c54545492f (diff)
Fix osx_cc_wrapper to also update dylibs
In https://github.com/bazelbuild/bazel/commit/f426544e67170d31b9d228ecf4cdc4b6ce1ba00d I updated osx_cc_wrapper to work correctly in case both precompiled .so and cc_library-made .so are linked into a single binary. This cl makes osx_cc_wrapper work also when a precompiled .dylib is provided. Fixes #3450 again for dylibs Fixes #407 One step closer to finishing #1576 RELNOTES: None. PiperOrigin-RevId: 171683650
Diffstat (limited to 'tools/cpp')
-rwxr-xr-xtools/cpp/osx_cc_wrapper.sh13
-rw-r--r--tools/cpp/osx_cc_wrapper.sh.tpl13
2 files changed, 22 insertions, 4 deletions
diff --git a/tools/cpp/osx_cc_wrapper.sh b/tools/cpp/osx_cc_wrapper.sh
index 8aba869443..9438567d73 100755
--- a/tools/cpp/osx_cc_wrapper.sh
+++ b/tools/cpp/osx_cc_wrapper.sh
@@ -57,6 +57,8 @@ function get_library_path() {
for libdir in ${LIB_DIRS}; do
if [ -f ${libdir}/lib$1.so ]; then
echo "${libdir}/lib$1.so"
+ elif [ -f ${libdir}/lib$1.dylib ]; then
+ echo "${libdir}/lib$1.dylib"
fi
done
}
@@ -82,11 +84,18 @@ function get_otool_path() {
# Do replacements in the output
for rpath in ${RPATHS}; do
for lib in ${LIBS}; do
- if [ -f "`dirname ${OUTPUT}`/${rpath}/lib${lib}.so" ]; then
+ if [ -f "$(dirname ${OUTPUT})/${rpath}/lib${lib}.so" ]; then
+ libname="lib${lib}.so"
+ elif [ -f "$(dirname ${OUTPUT})/${rpath}/lib${lib}.dylib" ]; then
+ libname="lib${lib}.dylib"
+ fi
+ # ${libname-} --> return $libname if defined, or undefined otherwise. This is to make
+ # this set -e friendly
+ if [[ -n "${libname-}" ]]; then
libpath=$(get_library_path ${lib})
if [ -n "${libpath}" ]; then
${INSTALL_NAME_TOOL} -change $(get_otool_path "${libpath}") \
- "@loader_path/${rpath}/lib${lib}.so" "${OUTPUT}"
+ "@loader_path/${rpath}/${libname}" "${OUTPUT}"
fi
fi
done
diff --git a/tools/cpp/osx_cc_wrapper.sh.tpl b/tools/cpp/osx_cc_wrapper.sh.tpl
index fb32e1e6b9..713c71117d 100644
--- a/tools/cpp/osx_cc_wrapper.sh.tpl
+++ b/tools/cpp/osx_cc_wrapper.sh.tpl
@@ -59,6 +59,8 @@ function get_library_path() {
for libdir in ${LIB_DIRS}; do
if [ -f ${libdir}/lib$1.so ]; then
echo "${libdir}/lib$1.so"
+ elif [ -f ${libdir}/lib$1.dylib ]; then
+ echo "${libdir}/lib$1.dylib"
fi
done
}
@@ -84,11 +86,18 @@ function get_otool_path() {
# Do replacements in the output
for rpath in ${RPATHS}; do
for lib in ${LIBS}; do
- if [ -f "`dirname ${OUTPUT}`/${rpath}/lib${lib}.so" ]; then
+ if [ -f "$(dirname ${OUTPUT})/${rpath}/lib${lib}.so" ]; then
+ libname="lib${lib}.so"
+ elif [ -f "$(dirname ${OUTPUT})/${rpath}/lib${lib}.dylib" ]; then
+ libname="lib${lib}.dylib"
+ fi
+ # ${libname-} --> return $libname if defined, or undefined otherwise. This is to make
+ # this set -e friendly
+ if [[ -n "${libname-}" ]]; then
libpath=$(get_library_path ${lib})
if [ -n "${libpath}" ]; then
${INSTALL_NAME_TOOL} -change $(get_otool_path "${libpath}") \
- "@loader_path/${rpath}/lib${lib}.so" "${OUTPUT}"
+ "@loader_path/${rpath}/${libname}" "${OUTPUT}"
fi
fi
done