diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/BUILD | 8 | ||||
-rwxr-xr-x | src/create_embedded_tools.sh | 2 | ||||
-rw-r--r-- | src/test/shell/bazel/BUILD | 2 | ||||
-rwxr-xr-x | src/test/shell/bazel/bazel_apple_test.sh | 15 | ||||
-rwxr-xr-x | src/test/shell/bazel/bazel_objc_test.sh | 2 | ||||
-rw-r--r-- | src/tools/xcode/xcodelocator/BUILD | 28 | ||||
-rw-r--r-- | src/tools/xcode/xcodelocator/xcode_locator.m | 185 | ||||
-rwxr-xr-x | src/tools/xcode/xcodelocator/xcode_locator_stub.sh | 19 |
8 files changed, 21 insertions, 240 deletions
@@ -28,7 +28,7 @@ filegroup( "//src/main/tools:process-wrapper", "//src/main/tools:linux-sandbox", "//src/main/tools:build_interface_so", - "//src/tools/xcode/xcodelocator:xcode-locator", + "//tools/osx:xcode-locator", ] + embedded_tools, outs = ["install_base_key" + suffix], cmd = select({ @@ -105,12 +105,12 @@ filegroup( "//src/tools/xcode/momcwrapper:momcwrapper", "//src/tools/xcode/swiftstdlibtoolwrapper:swiftstdlibtoolwrapper", "//src/tools/xcode/environment:environment_plist", - "//src/tools/xcode/xcodelocator:xcode-locator", "//src/tools/xcode/xcrunwrapper:xcrunwrapper", "//src/objc_tools/bundlemerge:bundlemerge_deploy.jar", "//src/objc_tools/plmerge:plmerge_deploy.jar", "//src/objc_tools/xcodegen:xcodegen_deploy.jar", "//src/tools/xcode/realpath:realpath", + "//tools/osx:xcode_locator.m", ] + select({ ":iphonesdk": ["//src/tools/xcode/stdredirect:StdRedirect.dylib"], "//conditions:default": [":dummy_darwin_tool_src_tools_xcode_stdredirect_StdRedirect.dylib"], @@ -185,7 +185,7 @@ genrule( "//src/main/tools:jdk-support", "//src/main/tools:linux-sandbox", "//src/main/tools:build_interface_so", - "//src/tools/xcode/xcodelocator:xcode-locator", + "//tools/osx:xcode-locator", ":java-version", ], outs = ["package" + suffix + ".zip"], @@ -313,10 +313,10 @@ filegroup( "//src/tools/singlejar:srcs", "//src/tools/xcode/stdredirect:srcs", "//src/tools/xcode/swiftstdlibtoolwrapper:srcs", - "//src/tools/xcode/xcodelocator:srcs", "//src/tools/xcode/xcrunwrapper:srcs", "//src/tools/xcode-common:srcs", "//src/tools/remote_worker:srcs", + "//tools/osx:srcs", ], visibility = ["//:__pkg__"], ) diff --git a/src/create_embedded_tools.sh b/src/create_embedded_tools.sh index f8ab4c824e..d482c86481 100755 --- a/src/create_embedded_tools.sh +++ b/src/create_embedded_tools.sh @@ -54,6 +54,8 @@ for i in $*; do *xcode*StdRedirect.dylib) OUTPUT_PATH=tools/objc/StdRedirect.dylib ;; *xcode*realpath) OUTPUT_PATH=tools/objc/realpath ;; *xcode*xcode-locator) OUTPUT_PATH=tools/objc/xcode-locator ;; +# *xcode*xcode_locator.m) OUTPUT_PATH=tools/osx/xcode_locator.m ;; +# *tools/osx/BUILD) OUTPUT_PATH=tools/osx/BUILD ;; *src/tools/xcode/*) OUTPUT_PATH=tools/objc/${i##*/}.sh ;; *) OUTPUT_PATH=$(echo $i | sed 's_^.*bazel-out/[^/]*/bin/__') ;; esac diff --git a/src/test/shell/bazel/BUILD b/src/test/shell/bazel/BUILD index 95151b40e2..a3d9751b3a 100644 --- a/src/test/shell/bazel/BUILD +++ b/src/test/shell/bazel/BUILD @@ -39,7 +39,7 @@ filegroup( "//src/tools/xcode/stdredirect:StdRedirect.dylib", "//src/tools/xcode/swiftstdlibtoolwrapper", "//src/tools/xcode/xcrunwrapper", - "//src/tools/xcode/xcodelocator:xcode-locator", + "//tools/osx:xcode-locator", "//third_party/iossim", ], "//conditions:default": [], diff --git a/src/test/shell/bazel/bazel_apple_test.sh b/src/test/shell/bazel/bazel_apple_test.sh index 6eb6ca265a..a8e6bea721 100755 --- a/src/test/shell/bazel/bazel_apple_test.sh +++ b/src/test/shell/bazel/bazel_apple_test.sh @@ -33,8 +33,19 @@ function set_up() { # Find where Xcode 7 (any sub-version will do) is located and get the iOS SDK # version it contains. # TODO(b/27267941): This is a hack until the bug is fixed. - XCODE_LOCATOR="$(bazel info output_base)/external/bazel_tools/tools/objc/xcode-locator" - XCODE_INFO=$($XCODE_LOCATOR -v | grep -m1 7) + rm -rf xcodehelper + mkdir -p xcodehelper + cat > xcodehelper/BUILD <<EOF +genrule( + name = "invoke_tool", + srcs = ["@bazel_tools//tools/osx:xcode-locator"], + outs = ["xcode_locations"], + cmd = "\$< -v > \$@", +) +EOF + + bazel build xcodehelper:xcode_locations + XCODE_INFO=$(cat bazel-genfiles/xcodehelper/xcode_locations | grep -m1 7) XCODE_DIR=$(echo $XCODE_INFO | cut -d ':' -f3) XCODE_VERSION=$(echo $XCODE_INFO | cut -d ':' -f1) IOS_SDK_VERSION=$(DEVELOPER_DIR=$XCODE_DIR xcodebuild -sdk -version \ diff --git a/src/test/shell/bazel/bazel_objc_test.sh b/src/test/shell/bazel/bazel_objc_test.sh index 5a80672c55..125392cb00 100755 --- a/src/test/shell/bazel/bazel_objc_test.sh +++ b/src/test/shell/bazel/bazel_objc_test.sh @@ -168,7 +168,7 @@ function test_xcodelocator_embedded_tool() { cat >ios/BUILD <<EOF genrule( name = "invoke_tool", - srcs = ["@bazel_tools//tools/objc:xcode-locator"], + srcs = ["@bazel_tools//tools/osx:xcode-locator"], outs = ["tool_output"], cmd = "\$< > \$@", tags = ["requires-darwin"], diff --git a/src/tools/xcode/xcodelocator/BUILD b/src/tools/xcode/xcodelocator/BUILD deleted file mode 100644 index 48eb69426e..0000000000 --- a/src/tools/xcode/xcodelocator/BUILD +++ /dev/null @@ -1,28 +0,0 @@ -package(default_visibility = ["//src:__subpackages__"]) - -filegroup( - name = "srcs", - srcs = glob(["**"]), -) - -DARWIN_XCODE_LOCATOR_COMPILE_COMMAND = """ - /usr/bin/xcrun clang -fobjc-arc -framework CoreServices \ - -framework Foundation -o $@ $< -""" - -genrule( - name = "xcode-locator-genrule", - srcs = select({ - "//src:darwin": ["xcode_locator.m"], - "//src:darwin_x86_64": ["xcode_locator.m"], - "//conditions:default": ["xcode_locator_stub.sh"], - }), - outs = ["xcode-locator"], - cmd = select({ - "//src:darwin": DARWIN_XCODE_LOCATOR_COMPILE_COMMAND, - "//src:darwin_x86_64": DARWIN_XCODE_LOCATOR_COMPILE_COMMAND, - "//conditions:default": "cp $< $@", - }), - local = 1, - output_to_bindir = 1, -) diff --git a/src/tools/xcode/xcodelocator/xcode_locator.m b/src/tools/xcode/xcodelocator/xcode_locator.m deleted file mode 100644 index 1c79357559..0000000000 --- a/src/tools/xcode/xcodelocator/xcode_locator.m +++ /dev/null @@ -1,185 +0,0 @@ -// Copyright 2015 Google Inc. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Application that finds all Xcodes installed on a given Mac and will return a path -// for a given version number. -// If you have 7.0, 6.4.1 and 6.3 installed the inputs will map to: -// 7,7.0,7.0.0 = 7.0 -// 6,6.4,6.4.1 = 6.4.1 -// 6.3,6.3.0 = 6.3 - -#if !defined(__has_feature) || !__has_feature(objc_arc) -#error "This file requires ARC support." -#endif - -#import <CoreServices/CoreServices.h> -#import <Foundation/Foundation.h> - -// Simple data structure for tracking a version of Xcode (i.e. 6.4) with an URL to the -// appplication. -@interface XcodeVersionEntry : NSObject -@property(readonly) NSString *version; -@property(readonly) NSURL *url; -@end - -@implementation XcodeVersionEntry - -- (id)initWithVersion:(NSString *)version url:(NSURL *)url { - if ((self = [super init])) { - _version = version; - _url = url; - } - return self; -} - -- (id)description { - return [NSString stringWithFormat:@"<%@ %p>: %@ %@", [self class], self, _version, _url]; -} - -@end - -// Given an entry, insert it into a dictionary that is keyed by versions. -// For an entry that is 6.4.1:/Applications/Xcode.app -// Add it for 6.4.1, and optionally add it for 6.4 if it is newer than any entry that may already -// be there, and add it for 6 if it is newer than what is there. -static void AddEntryToDictionary(XcodeVersionEntry *entry, NSMutableDictionary *dict) { - NSString *entryVersion = entry.version; - NSString *subversion = entryVersion; - dict[entryVersion] = entry; - while (YES) { - NSRange range = [subversion rangeOfString:@"." options:NSBackwardsSearch]; - if (range.length == 0 || range.location == 0) { - break; - } - subversion = [subversion substringToIndex:range.location]; - XcodeVersionEntry *subversionEntry = dict[subversion]; - if (subversionEntry) { - if ([subversionEntry.version compare:entry.version] == NSOrderedAscending) { - dict[subversion] = entry; - } - } else { - dict[subversion] = entry; - } - } -} - -// Given a "version", expand it to at least 3 components by adding .0 as necessary. -static NSString *ExpandVersion(NSString *version) { - NSArray *components = [version componentsSeparatedByString:@"."]; - NSString *appendage = nil; - if (components.count == 2) { - appendage = @".0"; - } else if (components.count == 1) { - appendage = @".0.0"; - } - if (appendage) { - version = [version stringByAppendingString:appendage]; - } - return version; -} - -int main(int argc, const char * argv[]) { - @autoreleasepool { - NSString *versionArg = nil; - BOOL versionsOnly = NO; - if (argc == 1) { - versionArg = @""; - } else if (argc == 2) { - NSString *firstArg = [NSString stringWithUTF8String:argv[1]]; - if ([@"-v" isEqualToString:firstArg]) { - versionsOnly = YES; - versionArg = @""; - } else { - versionArg = firstArg; - NSCharacterSet *versSet = - [NSCharacterSet characterSetWithCharactersInString:@"0123456789."]; - if ([versionArg rangeOfCharacterFromSet:versSet.invertedSet].length != 0) { - versionArg = nil; - } - } - } - if (versionArg == nil) { - printf("xcode_locator [-v|<version_number>]\n" - "Given a version number, or partial version number in x.y.z format, will attempt " - "to return the path to the appropriate developer directory.\nOmitting a version " - "number will list all available versions in JSON format, alongside their paths.\n" - "Passing -v will list all available fully-specified version numbers along with " - "their possible aliases and their developer directory, each on a new line.\n" - "For example: '7.3.1:7,7.3,7.3.1:/Applications/Xcode.app/Contents/Developer'.\n"); - return 1; - } - - NSMutableDictionary *dict = [[NSMutableDictionary alloc] init]; - CFErrorRef cfError; - NSArray *array = CFBridgingRelease(LSCopyApplicationURLsForBundleIdentifier( - CFSTR("com.apple.dt.Xcode"), &cfError)); - if (array == nil) { - NSError *nsError = (__bridge NSError *)cfError; - printf("error: %s\n", nsError.description.UTF8String); - return 1; - } - for (NSURL *url in array) { - NSBundle *bundle = [NSBundle bundleWithURL:url]; - if (!bundle) { - printf("error: Unable to open bundle at URL: %s\n", url.description.UTF8String); - return 1; - } - NSString *version = bundle.infoDictionary[@"CFBundleShortVersionString"]; - if (!version) { - printf("error: Unable to extract CFBundleShortVersionString from URL: %s\n", - url.description.UTF8String); - return 1; - } - version = ExpandVersion(version); - NSURL *developerDir = [url URLByAppendingPathComponent:@"Contents/Developer"]; - XcodeVersionEntry *entry = - [[XcodeVersionEntry alloc] initWithVersion:version url:developerDir]; - AddEntryToDictionary(entry, dict); - } - - XcodeVersionEntry *entry = [dict objectForKey:versionArg]; - if (entry) { - printf("%s\n", entry.url.fileSystemRepresentation); - return 0; - } - - if (versionsOnly) { - NSSet *distinctValues = [[NSSet alloc] initWithArray:[dict allValues]]; - NSMutableDictionary *aliasDict = [[NSMutableDictionary alloc] init]; - for (XcodeVersionEntry *value in distinctValues) { - NSString *versionString = value.version; - if (aliasDict[versionString] == nil) { - aliasDict[versionString] = [[NSMutableSet alloc] init]; - } - [aliasDict[versionString] addObjectsFromArray:[dict allKeysForObject:value]]; - } - for (NSString *version in aliasDict) { - XcodeVersionEntry *entry = dict[version]; - printf("%s:%s:%s\n", - version.UTF8String, - [[aliasDict[version] allObjects] componentsJoinedByString: @","].UTF8String, - entry.url.fileSystemRepresentation); - } - } else { - // Print out list in json format. - printf("{\n"); - for (NSString *version in dict) { - XcodeVersionEntry *entry = dict[version]; - printf("\t\"%s\": \"%s\",\n", version.UTF8String, entry.url.fileSystemRepresentation); - } - printf("}\n"); - } - return ([@"" isEqualToString:versionArg] ? 0 : 1); - } -} diff --git a/src/tools/xcode/xcodelocator/xcode_locator_stub.sh b/src/tools/xcode/xcodelocator/xcode_locator_stub.sh deleted file mode 100755 index 33191c9b87..0000000000 --- a/src/tools/xcode/xcodelocator/xcode_locator_stub.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash -# -# Copyright 2015 The Bazel Authors. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -printf 'xcode_locator should not be invoked on non-darwin systems\n' >&2 - -exit 1 |