Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(463)

Unified Diff: tools/gn/xcode_object.cc

Issue 2616773003: Associate xctest files with corresponding xctest targets. (Closed)
Patch Set: Addressed feedback Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/gn/xcode_object.h ('k') | tools/gn/xcode_writer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/xcode_object.cc
diff --git a/tools/gn/xcode_object.cc b/tools/gn/xcode_object.cc
index eeae7e479f796eca0de3873ab49016a6ec2bae9c..9854095c3cf3e1617ad0d29812458b9257fddb69 100644
--- a/tools/gn/xcode_object.cc
+++ b/tools/gn/xcode_object.cc
@@ -487,6 +487,19 @@ PBXFileReference* PBXGroup::AddSourceFile(const std::string& navigator_path,
DCHECK(!source_path.empty());
std::string::size_type sep = navigator_path.find("/");
if (sep == std::string::npos) {
+ // Prevent same file reference being created and added multiple times.
+ for (const auto& child : children_) {
+ if (child->Class() != PBXFileReferenceClass)
+ continue;
+
+ PBXFileReference* child_as_file_reference =
+ static_cast<PBXFileReference*>(child.get());
+ if (child_as_file_reference->Name() == navigator_path &&
+ child_as_file_reference->path() == source_path) {
+ return child_as_file_reference;
+ }
+ }
+
children_.push_back(base::MakeUnique<PBXFileReference>(
navigator_path, source_path, std::string()));
return static_cast<PBXFileReference*>(children_.back().get());
@@ -675,12 +688,13 @@ void PBXProject::AddIndexingTarget() {
target_for_indexing_ = static_cast<PBXNativeTarget*>(targets_.back().get());
}
-void PBXProject::AddNativeTarget(const std::string& name,
- const std::string& type,
- const std::string& output_name,
- const std::string& output_type,
- const std::string& shell_script,
- const PBXAttributes& extra_attributes) {
+PBXNativeTarget* PBXProject::AddNativeTarget(
+ const std::string& name,
+ const std::string& type,
+ const std::string& output_name,
+ const std::string& output_type,
+ const std::string& shell_script,
+ const PBXAttributes& extra_attributes) {
base::StringPiece ext = FindExtension(&output_name);
PBXFileReference* product = static_cast<PBXFileReference*>(
products_->AddChild(base::MakeUnique<PBXFileReference>(
@@ -700,6 +714,7 @@ void PBXProject::AddNativeTarget(const std::string& name,
targets_.push_back(base::MakeUnique<PBXNativeTarget>(
name, shell_script, config_name_, attributes, output_type, product_name,
product));
+ return static_cast<PBXNativeTarget*>(targets_.back().get());
}
void PBXProject::SetProjectDirPath(const std::string& project_dir_path) {
« no previous file with comments | « tools/gn/xcode_object.h ('k') | tools/gn/xcode_writer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698