Index: tools/gn/xcode_object.cc |
diff --git a/tools/gn/xcode_object.cc b/tools/gn/xcode_object.cc |
index dc5bfb86a7a942b60bf0956dc6df6be0d024ef87..48e27f67e07001096ae59d0bb19f6c51f7d8232f 100644 |
--- a/tools/gn/xcode_object.cc |
+++ b/tools/gn/xcode_object.cc |
@@ -607,31 +607,22 @@ PBXProject::PBXProject(const std::string& name, |
PBXProject::~PBXProject() {} |
-void PBXProject::AddSourceFile(const std::string& source_path) { |
+void PBXProject::AddSourceFileToIndexingTarget(const std::string& source_path) { |
+ if (!target_for_indexing_) { |
+ AddIndexingTarget(); |
+ } |
+ AddSourceFile(source_path, target_for_indexing_); |
+} |
+ |
+void PBXProject::AddSourceFile(const std::string& source_path, |
+ PBXNativeTarget* target) { |
PBXFileReference* file_reference = sources_->AddSourceFile(source_path); |
base::StringPiece ext = FindExtension(&source_path); |
if (!IsSourceFileForIndexing(ext)) |
return; |
- if (!target_for_indexing_) { |
- PBXAttributes attributes; |
- attributes["EXECUTABLE_PREFIX"] = ""; |
- attributes["HEADER_SEARCH_PATHS"] = sources_->path(); |
- attributes["PRODUCT_NAME"] = name_; |
- |
- PBXFileReference* product_reference = static_cast<PBXFileReference*>( |
- products_->AddChild(base::MakeUnique<PBXFileReference>( |
- std::string(), name_, "compiled.mach-o.executable"))); |
- |
- const char product_type[] = "com.apple.product-type.tool"; |
- targets_.push_back(base::MakeUnique<PBXNativeTarget>( |
- name_, std::string(), config_name_, attributes, product_type, name_, |
- product_reference)); |
- target_for_indexing_ = static_cast<PBXNativeTarget*>(targets_.back().get()); |
- } |
- |
- DCHECK(target_for_indexing_); |
- target_for_indexing_->AddFileForIndexing(file_reference); |
+ DCHECK(target); |
+ target->AddFileForIndexing(file_reference); |
} |
void PBXProject::AddAggregateTarget(const std::string& name, |
@@ -645,11 +636,29 @@ void PBXProject::AddAggregateTarget(const std::string& name, |
name, shell_script, config_name_, attributes)); |
} |
-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) { |
+void PBXProject::AddIndexingTarget() { |
+ DCHECK(!target_for_indexing_); |
+ PBXAttributes attributes; |
+ attributes["EXECUTABLE_PREFIX"] = ""; |
+ attributes["HEADER_SEARCH_PATHS"] = sources_->path(); |
+ attributes["PRODUCT_NAME"] = name_; |
+ |
+ PBXFileReference* product_reference = static_cast<PBXFileReference*>( |
+ products_->AddChild(base::MakeUnique<PBXFileReference>( |
+ std::string(), name_, "compiled.mach-o.executable"))); |
+ |
+ const char product_type[] = "com.apple.product-type.tool"; |
+ targets_.push_back(base::MakeUnique<PBXNativeTarget>( |
+ name_, std::string(), config_name_, attributes, product_type, name_, |
+ product_reference)); |
+ target_for_indexing_ = static_cast<PBXNativeTarget*>(targets_.back().get()); |
+} |
+ |
+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) { |
base::StringPiece ext = FindExtension(&output_name); |
PBXFileReference* product = static_cast<PBXFileReference*>( |
products_->AddChild(base::MakeUnique<PBXFileReference>( |
@@ -669,6 +678,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) { |