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

Unified Diff: tools/gn/xcode_object.cc

Issue 2577753002: [Refactor Xcode Objects] Decouple file references and indexing target. (Closed)
Patch Set: Rebase Created 4 years 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 039cb5210d63cc0e0168634104d869652aea36ab..e97cbfdb7b1a240fb1df936ed393a2bba13adab2 100644
--- a/tools/gn/xcode_object.cc
+++ b/tools/gn/xcode_object.cc
@@ -612,33 +612,26 @@ PBXProject::PBXProject(const std::string& name,
PBXProject::~PBXProject() {}
+void PBXProject::AddSourceFileToIndexingTarget(
+ const std::string& navigator_path,
+ const std::string& source_path) {
+ if (!target_for_indexing_) {
+ AddIndexingTarget();
+ }
+ AddSourceFile(navigator_path, source_path, target_for_indexing_);
+}
+
void PBXProject::AddSourceFile(const std::string& navigator_path,
- const std::string& source_path) {
+ const std::string& source_path,
+ PBXNativeTarget* target) {
PBXFileReference* file_reference =
sources_->AddSourceFile(navigator_path, 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,
@@ -652,6 +645,24 @@ void PBXProject::AddAggregateTarget(const std::string& name,
name, shell_script, config_name_, attributes));
}
+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());
+}
+
void PBXProject::AddNativeTarget(const std::string& name,
const std::string& type,
const std::string& output_name,
« 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