1
0
mirror of https://github.com/golang/go synced 2024-11-25 02:17:57 -07:00

misc/xcode: use xcode-select to determine path

If xcode-select is available, use it to determine the path to the
DVTFoundation.xcplugindata file.

Fixes #5997.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/12741047
This commit is contained in:
Emil Hessman 2013-08-20 20:48:29 +10:00 committed by Rob Pike
parent ed738ad354
commit 47ecd52377

View File

@ -3,7 +3,7 @@
# Use of this source code is governed by a BSD-style # Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file. # license that can be found in the LICENSE file.
# Illustrates how a Go language specification can be installed for Xcode 4.x., # Illustrates how a Go language specification can be installed for Xcode 4+,
# to enable syntax coloring, by adding an entry to a plugindata file. # to enable syntax coloring, by adding an entry to a plugindata file.
# #
# FIXME: Write a decent Xcode plugin to handle the file type association and # FIXME: Write a decent Xcode plugin to handle the file type association and
@ -14,21 +14,33 @@ set -e
# Assumes Xcode 4+. # Assumes Xcode 4+.
XCODE_MAJOR_VERSION=`xcodebuild -version | awk 'NR == 1 {print substr($2,1,1)}'` XCODE_MAJOR_VERSION=`xcodebuild -version | awk 'NR == 1 {print substr($2,1,1)}'`
if [ "$XCODE_MAJOR_VERSION" -lt "4" ]; then if [ "$XCODE_MAJOR_VERSION" -lt "4" ]; then
echo "Xcode 4.x not found." echo "Xcode 4+ not found."
exit 1 exit 1
fi fi
# DVTFOUNDATION_DIR may vary depending on Xcode setup. Change it to reflect # DVTFOUNDATION_DIR may vary depending on Xcode setup. If Xcode has installed
# your current Xcode setup. Find suitable path with e.g.: # the `xcode-select` command, it will be determined automatically. Otherwise,
# change it to reflect your current Xcode setup. Find suitable path with e.g.:
# #
# find / -type f -name 'DVTFoundation.xcplugindata' 2> /dev/null # find / -type f -name 'DVTFoundation.xcplugindata' 2> /dev/null
# #
# Example of DVTFOUNDATION_DIR's from "default" Xcode 4.x setups; # Example of DVTFOUNDATION_DIR's from "default" Xcode 4+ setups;
# #
# Xcode 4.1: /Developer/Library/PrivateFrameworks/DVTFoundation.framework/Versions/A/Resources/ # Xcode 4.1: /Developer/Library/PrivateFrameworks/DVTFoundation.framework/Versions/A/Resources/
# Xcode 4.3: /Applications/Xcode.app/Contents/SharedFrameworks/DVTFoundation.framework/Versions/A/Resources/ # Xcode 4.3: /Applications/Xcode.app/Contents/SharedFrameworks/DVTFoundation.framework/Versions/A/Resources/
#
# Defaults to Xcode 4.3's DVTFOUNDATION_DIR. Path is modified automatically if
# `xcode-select` command is available, as mentioned above.
DVTFOUNDATION_DIR="/Applications/Xcode.app/Contents/SharedFrameworks/DVTFoundation.framework/Versions/A/Resources/" DVTFOUNDATION_DIR="/Applications/Xcode.app/Contents/SharedFrameworks/DVTFoundation.framework/Versions/A/Resources/"
if type "xcode-select" > /dev/null; then
DVTFOUNDATION_DIR=`xcode-select --print-path`
DVTFOUNDATION_DIR+="/.."
FRAMEWORK_NAME="DVTFoundation.framework"
DVTFOUNDATION_DIR=`find $DVTFOUNDATION_DIR -name $FRAMEWORK_NAME -print`
DVTFOUNDATION_DIR+="/Versions/A/Resources"
fi
PLUGINDATA_FILE="DVTFoundation.xcplugindata" PLUGINDATA_FILE="DVTFoundation.xcplugindata"
PLISTBUDDY=/usr/libexec/PlistBuddy PLISTBUDDY=/usr/libexec/PlistBuddy
@ -84,7 +96,7 @@ GO_LANG_ENTRY="
</plist> </plist>
" "
echo "Backing up plugindata file." echo "Backing up plugindata file (copied to $PLUGINDATA_FILE.bak)."
cp $DVTFOUNDATION_DIR/$PLUGINDATA_FILE $DVTFOUNDATION_DIR/$PLUGINDATA_FILE.bak cp $DVTFOUNDATION_DIR/$PLUGINDATA_FILE $DVTFOUNDATION_DIR/$PLUGINDATA_FILE.bak
echo "Adding Go language specification entry." echo "Adding Go language specification entry."