OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "tools/gn/ninja_toolchain_writer.h" | 5 #include "tools/gn/ninja_toolchain_writer.h" |
6 | 6 |
7 #include <fstream> | 7 #include <fstream> |
8 | 8 |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/strings/stringize_macros.h" | 10 #include "base/strings/stringize_macros.h" |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 // GCC-style deps require a depfile. | 101 // GCC-style deps require a depfile. |
102 if (!tool->depfile().empty()) { | 102 if (!tool->depfile().empty()) { |
103 WriteRulePattern("depfile", tool->depfile(), options); | 103 WriteRulePattern("depfile", tool->depfile(), options); |
104 out_ << kIndent << "deps = gcc" << std::endl; | 104 out_ << kIndent << "deps = gcc" << std::endl; |
105 } | 105 } |
106 } else if (tool->depsformat() == Tool::DEPS_MSVC) { | 106 } else if (tool->depsformat() == Tool::DEPS_MSVC) { |
107 // MSVC deps don't have a depfile. | 107 // MSVC deps don't have a depfile. |
108 out_ << kIndent << "deps = msvc" << std::endl; | 108 out_ << kIndent << "deps = msvc" << std::endl; |
109 } | 109 } |
110 | 110 |
111 // The link pool applies to linker tools. Don't count TYPE_ALINK since | 111 // Use pool is specified. |
112 // static libraries are not generally intensive to write. | 112 if (tool->pool().ptr) { |
113 if (type == Toolchain::TYPE_SOLINK || | |
114 type == Toolchain::TYPE_SOLINK_MODULE || | |
115 type == Toolchain::TYPE_LINK) { | |
116 out_ << kIndent << "pool = link_pool\n"; | |
117 } else if (tool->pool().ptr) { | |
118 std::string pool_name = | 113 std::string pool_name = |
119 tool->pool().ptr->GetNinjaName(settings_->default_toolchain_label()); | 114 tool->pool().ptr->GetNinjaName(settings_->default_toolchain_label()); |
120 out_ << kIndent << "pool = " << pool_name << std::endl; | 115 out_ << kIndent << "pool = " << pool_name << std::endl; |
| 116 } else if (type == Toolchain::TYPE_SOLINK || |
| 117 type == Toolchain::TYPE_SOLINK_MODULE || |
| 118 type == Toolchain::TYPE_LINK) { |
| 119 // The link pool applies to linker tools. Don't count TYPE_ALINK since |
| 120 // static libraries are not generally intensive to write. |
| 121 out_ << kIndent << "pool = link_pool\n"; |
121 } | 122 } |
122 | 123 |
123 if (tool->restat()) | 124 if (tool->restat()) |
124 out_ << kIndent << "restat = 1" << std::endl; | 125 out_ << kIndent << "restat = 1" << std::endl; |
125 } | 126 } |
126 | 127 |
127 void NinjaToolchainWriter::WriteRulePattern(const char* name, | 128 void NinjaToolchainWriter::WriteRulePattern(const char* name, |
128 const SubstitutionPattern& pattern, | 129 const SubstitutionPattern& pattern, |
129 const EscapeOptions& options) { | 130 const EscapeOptions& options) { |
130 if (pattern.empty()) | 131 if (pattern.empty()) |
131 return; | 132 return; |
132 out_ << kIndent << name << " = "; | 133 out_ << kIndent << name << " = "; |
133 SubstitutionWriter::WriteWithNinjaVariables(pattern, options, out_); | 134 SubstitutionWriter::WriteWithNinjaVariables(pattern, options, out_); |
134 out_ << std::endl; | 135 out_ << std::endl; |
135 } | 136 } |
136 | 137 |
137 void NinjaToolchainWriter::WriteSubninjas() { | 138 void NinjaToolchainWriter::WriteSubninjas() { |
138 // Write subninja commands for each generated target. | 139 // Write subninja commands for each generated target. |
139 for (auto* target : targets_) { | 140 for (auto* target : targets_) { |
140 OutputFile ninja_file(target->settings()->build_settings(), | 141 OutputFile ninja_file(target->settings()->build_settings(), |
141 GetNinjaFileForTarget(target)); | 142 GetNinjaFileForTarget(target)); |
142 out_ << "subninja "; | 143 out_ << "subninja "; |
143 path_output_.WriteFile(out_, ninja_file); | 144 path_output_.WriteFile(out_, ninja_file); |
144 out_ << std::endl; | 145 out_ << std::endl; |
145 } | 146 } |
146 out_ << std::endl; | 147 out_ << std::endl; |
147 } | 148 } |
OLD | NEW |