| Index: tools/gn/xcode_object.cc
|
| diff --git a/tools/gn/xcode_object.cc b/tools/gn/xcode_object.cc
|
| index ef24e7d07fe91bad72ad731e865263069d3caaae..d9712c1ed9e0c506c271bcd359072fb44b5f4079 100644
|
| --- a/tools/gn/xcode_object.cc
|
| +++ b/tools/gn/xcode_object.cc
|
| @@ -222,6 +222,38 @@ void PrintValue(std::ostream& out,
|
| out << "}";
|
| }
|
|
|
| +// Single entry values will by printed as value, multiple entries as vector
|
| +template <typename ValueType>
|
| +void PrintValue(std::ostream& out,
|
| + IndentRules rules,
|
| + const std::multimap<std::string, ValueType>& values) {
|
| + IndentRules sub_rule{rules.one_line, rules.level + 1};
|
| + out << "{" << (rules.one_line ? " " : "\n");
|
| +
|
| + for (auto i = values.begin(); i != values.end();) {
|
| + if (!sub_rule.one_line)
|
| + out << std::string(sub_rule.level, '\t');
|
| + out << i->first << " = ";
|
| + auto upper = values.upper_bound(i->first);
|
| + std::vector<ValueType> values;
|
| + while (i != upper) {
|
| + values.push_back(i->second);
|
| + ++i;
|
| + }
|
| + if (values.size() == 1) {
|
| + PrintValue(out, sub_rule, values.front());
|
| + } else {
|
| + PrintValue(out, sub_rule, values);
|
| + }
|
| +
|
| + out << ";" << (rules.one_line ? " " : "\n");
|
| + }
|
| +
|
| + if (!rules.one_line && rules.level)
|
| + out << std::string(rules.level, '\t');
|
| + out << "}";
|
| +}
|
| +
|
| template <typename ValueType>
|
| void PrintProperty(std::ostream& out,
|
| IndentRules rules,
|
| @@ -365,8 +397,11 @@ void PBXAggregateTarget::Print(std::ostream& out, unsigned indent) const {
|
| // PBXBuildFile ---------------------------------------------------------------
|
|
|
| PBXBuildFile::PBXBuildFile(const PBXFileReference* file_reference,
|
| - const PBXSourcesBuildPhase* build_phase)
|
| - : file_reference_(file_reference), build_phase_(build_phase) {
|
| + const PBXSourcesBuildPhase* build_phase,
|
| + const std::string& cflags)
|
| + : file_reference_(file_reference),
|
| + build_phase_(build_phase),
|
| + cflags_(cflags) {
|
| DCHECK(file_reference_);
|
| DCHECK(build_phase_);
|
| }
|
| @@ -387,6 +422,11 @@ void PBXBuildFile::Print(std::ostream& out, unsigned indent) const {
|
| out << indent_str << Reference() << " = {";
|
| PrintProperty(out, rules, "isa", ToString(Class()));
|
| PrintProperty(out, rules, "fileRef", file_reference_);
|
| + if (!cflags_.empty()) {
|
| + std::map<std::string, std::string> settings;
|
| + settings["COMPILER_FLAGS"] = cflags_;
|
| + PrintProperty(out, rules, "settings", settings);
|
| + }
|
| out << "};\n";
|
| }
|
|
|
| @@ -559,11 +599,11 @@ PBXNativeTarget::PBXNativeTarget(const std::string& name,
|
|
|
| PBXNativeTarget::~PBXNativeTarget() {}
|
|
|
| -void PBXNativeTarget::AddFileForIndexing(
|
| - const PBXFileReference* file_reference) {
|
| +void PBXNativeTarget::AddFileForIndexing(const PBXFileReference* file_reference,
|
| + const std::string& cflags) {
|
| DCHECK(file_reference);
|
| - source_build_phase_->AddBuildFile(
|
| - base::WrapUnique(new PBXBuildFile(file_reference, source_build_phase_)));
|
| + source_build_phase_->AddBuildFile(base::WrapUnique(
|
| + new PBXBuildFile(file_reference, source_build_phase_, cflags)));
|
| }
|
|
|
| PBXObjectClass PBXNativeTarget::Class() const {
|
| @@ -593,7 +633,10 @@ PBXProject::PBXProject(const std::string& name,
|
| const std::string& source_path,
|
| const PBXAttributes& attributes)
|
| : name_(name), config_name_(config_name), target_for_indexing_(nullptr) {
|
| - attributes_["BuildIndependentTargetsInParallel"] = "YES";
|
| + if (attributes_.find("BuildIndependentTargetsInParallel") ==
|
| + attributes_.end())
|
| + attributes_.insert(
|
| + std::make_pair("BuildIndependentTargetsInParallel", "YES"));
|
|
|
| main_group_.reset(new PBXGroup);
|
| sources_ = static_cast<PBXGroup*>(main_group_->AddChild(
|
| @@ -607,17 +650,21 @@ PBXProject::PBXProject(const std::string& name,
|
|
|
| PBXProject::~PBXProject() {}
|
|
|
| -void PBXProject::AddSourceFile(const std::string& source_path) {
|
| - PBXFileReference* file_reference = sources_->AddSourceFile(source_path);
|
| +bool PBXProject::SourceFileShouldBeIndexed(const std::string& source_path) {
|
| base::StringPiece ext = FindExtension(&source_path);
|
| - if (!IsSourceFileForIndexing(ext))
|
| + return IsSourceFileForIndexing(ext);
|
| +}
|
| +
|
| +void PBXProject::AddSourceFile(const std::string& source_path,
|
| + const std::string& cflags) {
|
| + PBXFileReference* file_reference = sources_->AddSourceFile(source_path);
|
| + if (!SourceFileShouldBeIndexed(source_path))
|
| return;
|
|
|
| if (!target_for_indexing_) {
|
| PBXAttributes attributes;
|
| - attributes["EXECUTABLE_PREFIX"] = "";
|
| - attributes["HEADER_SEARCH_PATHS"] = sources_->path();
|
| - attributes["PRODUCT_NAME"] = name_;
|
| + attributes.insert(std::make_pair("EXECUTABLE_PREFIX", ""));
|
| + attributes.insert(std::make_pair("PRODUCT_NAME", name_));
|
|
|
| PBXFileReference* product_reference = static_cast<PBXFileReference*>(
|
| products_->AddChild(base::WrapUnique(new PBXFileReference(
|
| @@ -631,15 +678,15 @@ void PBXProject::AddSourceFile(const std::string& source_path) {
|
| }
|
|
|
| DCHECK(target_for_indexing_);
|
| - target_for_indexing_->AddFileForIndexing(file_reference);
|
| + target_for_indexing_->AddFileForIndexing(file_reference, cflags);
|
| }
|
|
|
| void PBXProject::AddAggregateTarget(const std::string& name,
|
| const std::string& shell_script) {
|
| PBXAttributes attributes;
|
| - attributes["CODE_SIGNING_REQUIRED"] = "NO";
|
| - attributes["CONFIGURATION_BUILD_DIR"] = ".";
|
| - attributes["PRODUCT_NAME"] = name;
|
| + attributes.insert(std::make_pair("CODE_SIGNING_REQUIRED", "NO"));
|
| + attributes.insert(std::make_pair("CONFIGURATION_BUILD_DIR", "."));
|
| + attributes.insert(std::make_pair("PRODUCT_NAME", name));
|
|
|
| targets_.push_back(base::WrapUnique(
|
| new PBXAggregateTarget(name, shell_script, config_name_, attributes)));
|
| @@ -662,9 +709,9 @@ void PBXProject::AddNativeTarget(const std::string& name,
|
| : output_name;
|
|
|
| PBXAttributes attributes;
|
| - attributes["CODE_SIGNING_REQUIRED"] = "NO";
|
| - attributes["CONFIGURATION_BUILD_DIR"] = ".";
|
| - attributes["PRODUCT_NAME"] = product_name;
|
| + attributes.insert(std::make_pair("CODE_SIGNING_REQUIRED", "NO"));
|
| + attributes.insert(std::make_pair("CONFIGURATION_BUILD_DIR", "."));
|
| + attributes.insert(std::make_pair("PRODUCT_NAME", product_name));
|
|
|
| targets_.push_back(base::WrapUnique(
|
| new PBXNativeTarget(name, shell_script, config_name_, attributes,
|
|
|