From 9888cbb81a5997562251f4b1e04da5cc5e673386 Mon Sep 17 00:00:00 2001 From: Googler Date: Mon, 20 Jul 2015 19:41:54 +0000 Subject: Simplify Target Names in generated Xcode projects. Compare: https://screenshot.googleplex.com/hzmgwbpUeuf RELNOTES:Target names in Xcode projects have been simplified. This may require recreating any schemes that you have defined. -- MOS_MIGRATED_REVID=98664733 --- .../build/xcode/xcodegen/XcodeprojGeneration.java | 26 +++++++++++----------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'src/objc_tools') diff --git a/src/objc_tools/xcodegen/java/com/google/devtools/build/xcode/xcodegen/XcodeprojGeneration.java b/src/objc_tools/xcodegen/java/com/google/devtools/build/xcode/xcodegen/XcodeprojGeneration.java index c2d1457a41..496d50df56 100644 --- a/src/objc_tools/xcodegen/java/com/google/devtools/build/xcode/xcodegen/XcodeprojGeneration.java +++ b/src/objc_tools/xcodegen/java/com/google/devtools/build/xcode/xcodegen/XcodeprojGeneration.java @@ -21,7 +21,6 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Joiner; import com.google.common.base.Optional; import com.google.common.base.Preconditions; -import com.google.common.base.Splitter; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; @@ -67,6 +66,7 @@ import java.nio.charset.StandardCharsets; import java.nio.file.FileSystem; import java.nio.file.Path; import java.nio.file.Paths; +import java.util.ArrayList; import java.util.Collections; import java.util.EnumSet; import java.util.HashMap; @@ -166,7 +166,7 @@ public class XcodeprojGeneration { // Unlike other product types, a full application may have dozens of static libraries, // so rather than just use the target name, we use the full label to generate the product // name. - return labelToXcodeTargetName(targetControl.getLabel()); + return targetControl.getLabel(); } else { return targetControl.getName(); } @@ -275,14 +275,6 @@ public class XcodeprojGeneration { } } - // TODO(bazel-team): Make this a no-op once the released version of Bazel sends the label to - // xcodegen pre-processed. - private static String labelToXcodeTargetName(String label) { - String pathFromWorkspaceRoot = label.replace("//", "").replace(':', '/'); - List components = Splitter.on('/').splitToList(pathFromWorkspaceRoot); - return Joiner.on('_').join(Lists.reverse(components)); - } - private static NSDictionary nonArcCompileSettings() { NSDictionary result = new NSDictionary(); result.put("COMPILER_FLAGS", "-fno-objc-arc"); @@ -414,7 +406,7 @@ public class XcodeprojGeneration { } Map targetInfoByLabel = new HashMap<>(); - + List usedTargetNames = new ArrayList<>(); PBXFileReferences fileReferences = new PBXFileReferences(); LibraryObjects libraryObjects = new LibraryObjects(fileReferences); PBXBuildFiles pbxBuildFiles = new PBXBuildFiles(fileReferences); @@ -497,8 +489,16 @@ public class XcodeprojGeneration { targetBuildConfigMap.put(name, value); } - PBXNativeTarget target = new PBXNativeTarget( - labelToXcodeTargetName(targetControl.getLabel()), productType); + String targetName = targetControl.getName(); + if (usedTargetNames.contains(targetName)) { + // Use the label in the odd case where we have two targets with the same name. + targetName = targetControl.getLabel(); + } + checkState(!usedTargetNames.contains(targetName), + "Name already exists for target with label/name %s/%s in list: %s", + targetControl.getLabel(), targetControl.getName(), usedTargetNames); + usedTargetNames.add(targetName); + PBXNativeTarget target = new PBXNativeTarget(targetName, productType); try { target .getBuildConfigurationList() -- cgit v1.2.3