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

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

Issue 561273003: Add public deps to GN (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge Created 6 years, 3 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_binary_target_writer.h" 5 #include "tools/gn/ninja_binary_target_writer.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "tools/gn/config_values_extractors.h" 10 #include "tools/gn/config_values_extractors.h"
11 #include "tools/gn/deps_iterator.h"
11 #include "tools/gn/err.h" 12 #include "tools/gn/err.h"
12 #include "tools/gn/escape.h" 13 #include "tools/gn/escape.h"
13 #include "tools/gn/ninja_utils.h" 14 #include "tools/gn/ninja_utils.h"
14 #include "tools/gn/settings.h" 15 #include "tools/gn/settings.h"
15 #include "tools/gn/string_utils.h" 16 #include "tools/gn/string_utils.h"
16 #include "tools/gn/substitution_writer.h" 17 #include "tools/gn/substitution_writer.h"
17 #include "tools/gn/target.h" 18 #include "tools/gn/target.h"
18 19
19 namespace { 20 namespace {
20 21
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 for (size_t i = 0; i < non_linkable_deps.size(); i++) 360 for (size_t i = 0; i < non_linkable_deps.size(); i++)
360 order_only_deps.push_back(non_linkable_deps[i]->dependency_output_file()); 361 order_only_deps.push_back(non_linkable_deps[i]->dependency_output_file());
361 362
362 WriteStampForTarget(object_files, order_only_deps); 363 WriteStampForTarget(object_files, order_only_deps);
363 } 364 }
364 365
365 void NinjaBinaryTargetWriter::GetDeps( 366 void NinjaBinaryTargetWriter::GetDeps(
366 UniqueVector<OutputFile>* extra_object_files, 367 UniqueVector<OutputFile>* extra_object_files,
367 UniqueVector<const Target*>* linkable_deps, 368 UniqueVector<const Target*>* linkable_deps,
368 UniqueVector<const Target*>* non_linkable_deps) const { 369 UniqueVector<const Target*>* non_linkable_deps) const {
369 const LabelTargetVector& deps = target_->deps();
370 const UniqueVector<const Target*>& inherited = 370 const UniqueVector<const Target*>& inherited =
371 target_->inherited_libraries(); 371 target_->inherited_libraries();
372 372
373 // Normal deps. 373 // Normal public/private deps.
374 for (size_t i = 0; i < deps.size(); i++) { 374 for (DepsIterator iter(target_, DepsIterator::LINKED_ONLY); !iter.done();
375 ClassifyDependency(deps[i].ptr, extra_object_files, 375 iter.Advance()) {
376 ClassifyDependency(iter.target(), extra_object_files,
376 linkable_deps, non_linkable_deps); 377 linkable_deps, non_linkable_deps);
377 } 378 }
378 379
379 // Inherited libraries. 380 // Inherited libraries.
380 for (size_t i = 0; i < inherited.size(); i++) { 381 for (size_t i = 0; i < inherited.size(); i++) {
381 ClassifyDependency(inherited[i], extra_object_files, 382 ClassifyDependency(inherited[i], extra_object_files,
382 linkable_deps, non_linkable_deps); 383 linkable_deps, non_linkable_deps);
383 } 384 }
384 385
385 // Data deps. 386 // Data deps.
386 const LabelTargetVector& datadeps = target_->datadeps(); 387 const LabelTargetVector& data_deps = target_->data_deps();
387 for (size_t i = 0; i < datadeps.size(); i++) 388 for (size_t i = 0; i < data_deps.size(); i++)
388 non_linkable_deps->push_back(datadeps[i].ptr); 389 non_linkable_deps->push_back(data_deps[i].ptr);
389 } 390 }
390 391
391 void NinjaBinaryTargetWriter::ClassifyDependency( 392 void NinjaBinaryTargetWriter::ClassifyDependency(
392 const Target* dep, 393 const Target* dep,
393 UniqueVector<OutputFile>* extra_object_files, 394 UniqueVector<OutputFile>* extra_object_files,
394 UniqueVector<const Target*>* linkable_deps, 395 UniqueVector<const Target*>* linkable_deps,
395 UniqueVector<const Target*>* non_linkable_deps) const { 396 UniqueVector<const Target*>* non_linkable_deps) const {
396 // Only the following types of outputs have libraries linked into them: 397 // Only the following types of outputs have libraries linked into them:
397 // EXECUTABLE 398 // EXECUTABLE
398 // SHARED_LIBRARY 399 // SHARED_LIBRARY
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 return false; // No tool for this file (it's a header file or something). 469 return false; // No tool for this file (it's a header file or something).
469 const Tool* tool = target->toolchain()->GetTool(*computed_tool_type); 470 const Tool* tool = target->toolchain()->GetTool(*computed_tool_type);
470 if (!tool) 471 if (!tool)
471 return false; // Tool does not apply for this toolchain.file. 472 return false; // Tool does not apply for this toolchain.file.
472 473
473 // Figure out what output(s) this compiler produces. 474 // Figure out what output(s) this compiler produces.
474 SubstitutionWriter::ApplyListToCompilerAsOutputFile( 475 SubstitutionWriter::ApplyListToCompilerAsOutputFile(
475 target, source, tool->outputs(), outputs); 476 target, source, tool->outputs(), outputs);
476 return !outputs->empty(); 477 return !outputs->empty();
477 } 478 }
OLDNEW
« no previous file with comments | « tools/gn/ninja_action_target_writer_unittest.cc ('k') | tools/gn/ninja_binary_target_writer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698