aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/objc_tools
diff options
context:
space:
mode:
authorGravatar Googler <noreply@google.com>2015-07-20 19:41:54 +0000
committerGravatar Kristina Chodorow <kchodorow@google.com>2015-07-21 15:13:38 -0400
commit9888cbb81a5997562251f4b1e04da5cc5e673386 (patch)
treeb1c40a86ddbbcc25bd5f99790d4aa60c72c6d9e5 /src/objc_tools
parent5dc9abfad26c0eda25950ee8ab70b9db1942e8dc (diff)
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
Diffstat (limited to 'src/objc_tools')
-rw-r--r--src/objc_tools/xcodegen/java/com/google/devtools/build/xcode/xcodegen/XcodeprojGeneration.java26
1 files changed, 13 insertions, 13 deletions
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<String> 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<String, TargetInfo> targetInfoByLabel = new HashMap<>();
-
+ List<String> 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()