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

Side by Side Diff: tools/gn/ninja_target_writer.cc

Issue 2071573003: GN: Use implicit dependency for binary input deps (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Code review changes Created 4 years, 6 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 unified diff | Download patch
OLDNEW
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_target_writer.h" 5 #include "tools/gn/ninja_target_writer.h"
6 6
7 #include <sstream> 7 #include <sstream>
8 8
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 // number before writing allows us to either skip writing the input deps 158 // number before writing allows us to either skip writing the input deps
159 // stamp or optimize it. Use pointers to avoid copies here. 159 // stamp or optimize it. Use pointers to avoid copies here.
160 std::vector<const SourceFile*> input_deps_sources; 160 std::vector<const SourceFile*> input_deps_sources;
161 input_deps_sources.reserve(32); 161 input_deps_sources.reserve(32);
162 162
163 // Actions get implicit dependencies on the script itself. 163 // Actions get implicit dependencies on the script itself.
164 if (target_->output_type() == Target::ACTION || 164 if (target_->output_type() == Target::ACTION ||
165 target_->output_type() == Target::ACTION_FOREACH) 165 target_->output_type() == Target::ACTION_FOREACH)
166 input_deps_sources.push_back(&target_->action_values().script()); 166 input_deps_sources.push_back(&target_->action_values().script());
167 167
168 // Input files. 168 // Input files are only considered for non-binary targets which use an
169 for (const auto& input : target_->inputs()) 169 // implicit dependency instead. The implicit depedency in this case is
170 input_deps_sources.push_back(&input); 170 // handled separately by the binary target writer.
171 if (!target_->IsBinary()) {
172 for (const auto& input : target_->inputs())
173 input_deps_sources.push_back(&input);
174 }
171 175
172 // For an action (where we run a script only once) the sources are the same 176 // For an action (where we run a script only once) the sources are the same
173 // as the inputs. For action_foreach, the sources will be operated on 177 // as the inputs. For action_foreach, the sources will be operated on
174 // separately so don't handle them here. 178 // separately so don't handle them here.
175 if (target_->output_type() == Target::ACTION) { 179 if (target_->output_type() == Target::ACTION) {
176 for (const auto& source : target_->sources()) 180 for (const auto& source : target_->sources())
177 input_deps_sources.push_back(&source); 181 input_deps_sources.push_back(&source);
178 } 182 }
179 183
180 // ---------- 184 // ----------
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 << GetNinjaRulePrefixForToolchain(settings_) 284 << GetNinjaRulePrefixForToolchain(settings_)
281 << Toolchain::ToolTypeToName(Toolchain::TYPE_STAMP); 285 << Toolchain::ToolTypeToName(Toolchain::TYPE_STAMP);
282 path_output_.WriteFiles(out_, files); 286 path_output_.WriteFiles(out_, files);
283 287
284 if (!order_only_deps.empty()) { 288 if (!order_only_deps.empty()) {
285 out_ << " ||"; 289 out_ << " ||";
286 path_output_.WriteFiles(out_, order_only_deps); 290 path_output_.WriteFiles(out_, order_only_deps);
287 } 291 }
288 out_ << std::endl; 292 out_ << std::endl;
289 } 293 }
OLDNEW
« no previous file with comments | « tools/gn/ninja_binary_target_writer_unittest.cc ('k') | tools/gn/ninja_target_writer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698