aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/tools/xcode
diff options
context:
space:
mode:
authorGravatar Chris Parsons <cparsons@google.com>2016-06-14 13:34:30 +0000
committerGravatar Yue Gan <yueg@google.com>2016-06-15 08:33:21 +0000
commit591d1e15740c9eeb85940291e5b10dd8f49a88b7 (patch)
tree84658a3c44509dd71b515164ce78442406efd550 /src/tools/xcode
parent8fefee65ee7154160d06de255eafaf80e71c424a (diff)
Move libtool-wrapper symlinking logic from xcrunwrapper to libtool script.
-- MOS_MIGRATED_REVID=124831722
Diffstat (limited to 'src/tools/xcode')
-rwxr-xr-xsrc/tools/xcode/libtool/libtool.sh61
-rwxr-xr-xsrc/tools/xcode/xcrunwrapper/xcrunwrapper.sh66
2 files changed, 60 insertions, 67 deletions
diff --git a/src/tools/xcode/libtool/libtool.sh b/src/tools/xcode/libtool/libtool.sh
index c72f229b00..390a060def 100755
--- a/src/tools/xcode/libtool/libtool.sh
+++ b/src/tools/xcode/libtool/libtool.sh
@@ -26,6 +26,61 @@ set -eu
MY_LOCATION=${MY_LOCATION:-"$0.runfiles/bazel_tools/tools/objc"}
WRAPPER="${MY_LOCATION}/xcrunwrapper.sh"
-# TODO(b/28347228): When all callers of "xcrunwrapper libtool" are migrated to
-# using this script, move the symlinking behavior to this script.
-"${WRAPPER}" libtool "$@"
+# Creates a symbolic link to the input argument file and returns the symlink
+# file path.
+function hash_objfile() {
+ ORIGINAL_NAME="$1"
+ ORIGINAL_HASH="$(/sbin/md5 -q "${ORIGINAL_NAME}")"
+ SYMLINK_NAME="${ORIGINAL_NAME%.o}_${ORIGINAL_HASH}.o"
+ ln -sf "$(basename "$ORIGINAL_NAME")" "$SYMLINK_NAME"
+ echo "$SYMLINK_NAME"
+}
+
+ARGS=()
+
+while [[ $# -gt 0 ]]; do
+ ARG="$1"
+ shift
+
+ # Libtool artifact symlinking. Apple's libtool has a bug when there are two
+ # input files with the same basename. We thus create symlinks that are named
+ # with a hash suffix for each input, and pass them to libtool.
+ # See b/28186497.
+ case "${ARG}" in
+ # Filelist flag, need to symlink each input in the contents of file and
+ # pass a new filelist which contains the symlinks.
+ -filelist)
+ ARGS+=("${ARG}")
+ ARG="$1"
+ shift
+ HASHED_FILELIST="${ARG%.objlist}_hashes.objlist"
+ rm -f "${HASHED_FILELIST}"
+ while read INPUT_FILE || [ -n "$INPUT_FILE" ]; do
+ echo "$(hash_objfile "${INPUT_FILE}")" >> "$HASHED_FILELIST"
+ done < "${ARG}"
+ ARGS+=("${HASHED_FILELIST}")
+ ;;
+ # Flags with no args
+ -static|-s|-a|-c|-L|-T|-no_warning_for_no_symbols)
+ ARGS+=("${ARG}")
+ ;;
+ # Single-arg flags
+ -o|-arch_only|-syslibroot)
+ ARGS+=("${ARG}")
+ ARG="$1"
+ shift
+ ARGS+=("${ARG}")
+ ;;
+ # Any remaining flags are unexpected and may ruin flag parsing.
+ -*)
+ echo "Unrecognized libtool flag ${ARG}"
+ exit 1
+ ;;
+ # Remaining args are input objects
+ *)
+ ARGS+=("$(echo "$(hash_objfile "${ARG}")")")
+ ;;
+ esac
+done
+
+"${WRAPPER}" libtool "${ARGS[@]}"
diff --git a/src/tools/xcode/xcrunwrapper/xcrunwrapper.sh b/src/tools/xcode/xcrunwrapper/xcrunwrapper.sh
index ecd2ef60c6..e005895881 100755
--- a/src/tools/xcode/xcrunwrapper/xcrunwrapper.sh
+++ b/src/tools/xcode/xcrunwrapper/xcrunwrapper.sh
@@ -27,18 +27,7 @@ set -eu
TOOLNAME=$1
shift
-# Creates a symbolic link to the input argument file and returns the symlink
-# file path.
-function hash_objfile() {
- ORIGINAL_NAME="$1"
- ORIGINAL_HASH="$(/sbin/md5 -q "${ORIGINAL_NAME}")"
- SYMLINK_NAME="${ORIGINAL_NAME%.o}_${ORIGINAL_HASH}.o"
- ln -sf "$(basename "$ORIGINAL_NAME")" "$SYMLINK_NAME"
- echo "$SYMLINK_NAME"
-}
-
# Pick values for DEVELOPER_DIR and SDKROOT as appropriate (if they weren't set)
-
WRAPPER_DEVDIR="${DEVELOPER_DIR:-}"
if [[ -z "${WRAPPER_DEVDIR}" ]] ; then
WRAPPER_DEVDIR="$(xcode-select -p)"
@@ -62,63 +51,12 @@ if [[ -z "${WRAPPER_SDKROOT:-}" ]] ; then
WRAPPER_SDKROOT="$(/usr/bin/xcrun --show-sdk-path --sdk ${WRAPPER_SDK})"
fi
-ARGS=("$TOOLNAME")
-while [[ $# -gt 0 ]]; do
- ARG="$1"
- shift
-
- # Libtool artifact symlinking. Apple's libtool has a bug when there are two
- # input files with the same basename. We thus create symlinks that are named
- # with a hash suffix for each input, and pass them to libtool.
- # See b/28186497.
- # TODO(b/28347228): Handle this in a separate wrapper.
- if [ "$TOOLNAME" = "libtool" ] ; then
- case "${ARG}" in
- # Filelist flag, need to symlink each input in the contents of file and
- # pass a new filelist which contains the symlinks.
- -filelist)
- ARGS+=("${ARG}")
- ARG="$1"
- shift
- HASHED_FILELIST="${ARG%.objlist}_hashes.objlist"
- rm -f "${HASHED_FILELIST}"
- while read INPUT_FILE || [ -n "$INPUT_FILE" ]; do
- echo "$(hash_objfile "${INPUT_FILE}")" >> "$HASHED_FILELIST"
- done < "${ARG}"
- ARGS+=("${HASHED_FILELIST}")
- ;;
- # Flags with no args
- -static|-s|-a|-c|-L|-T|-no_warning_for_no_symbols)
- ARGS+=("${ARG}")
- ;;
- # Single-arg flags
- -o|-arch_only|-syslibroot)
- ARGS+=("${ARG}")
- ARG="$1"
- shift
- ARGS+=("${ARG}")
- ;;
- # Any remaining flags are unexpected and may ruin flag parsing.
- -*)
- echo "Unrecognized libtool flag ${ARG}"
- exit 1
- ;;
- # Remaining args are input objects
- *)
- ARGS+=("$(echo "$(hash_objfile "${ARG}")")")
- ;;
- esac
- else
- ARGS+=("${ARG}")
- fi
-done
-
# Subsitute toolkit path placeholders.
UPDATEDARGS=()
-for ARG in "${ARGS[@]}" ; do
+for ARG in "$@" ; do
ARG="${ARG//__BAZEL_XCODE_DEVELOPER_DIR__/${WRAPPER_DEVDIR}}"
ARG="${ARG//__BAZEL_XCODE_SDKROOT__/${WRAPPER_SDKROOT}}"
UPDATEDARGS+=("${ARG}")
done
-/usr/bin/xcrun "${UPDATEDARGS[@]}"
+/usr/bin/xcrun "${TOOLNAME}" "${UPDATEDARGS[@]}"