"xcode_locator -v" dedupes multiple copies of the same xcode version installed on the host, and appends DEVELOPER_DIR to the specification on each line. This should be the last of what is needed from this option, in order to launch local generated xcode_config and xcode_version targets in skylark. -- MOS_MIGRATED_REVID=125725500
diff --git a/src/tools/xcode/xcodelocator/xcode_locator.m b/src/tools/xcode/xcodelocator/xcode_locator.m index 4939259..1c79357 100644 --- a/src/tools/xcode/xcodelocator/xcode_locator.m +++ b/src/tools/xcode/xcodelocator/xcode_locator.m
@@ -115,7 +115,8 @@ "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, each on a new line. For example: '7.3.1:7,7.3,7.3.1'.\n"); + "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; } @@ -155,9 +156,20 @@ if (versionsOnly) { NSSet *distinctValues = [[NSSet alloc] initWithArray:[dict allValues]]; + NSMutableDictionary *aliasDict = [[NSMutableDictionary alloc] init]; for (XcodeVersionEntry *value in distinctValues) { - printf("%s:", value.version.UTF8String); - printf("%s\n", [[dict allKeysForObject:value] componentsJoinedByString: @","].UTF8String); + 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.