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

Unified Diff: tools/gn/command_desc.cc

Issue 22290010: Add support for data deps. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Clarify deps documentation. Created 7 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/gn/BUILD.gn ('k') | tools/gn/command_gen.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/command_desc.cc
diff --git a/tools/gn/command_desc.cc b/tools/gn/command_desc.cc
index 1aeb2befa45fb70277578c03531452e13397b011..416f72c2fe0cf403a2d744e2cdf34c1dddbf972e 100644
--- a/tools/gn/command_desc.cc
+++ b/tools/gn/command_desc.cc
@@ -21,6 +21,8 @@ namespace commands {
namespace {
+const char kIncludeDataDeps[] = "include-datadeps";
+
struct CompareTargetLabel {
bool operator()(const Target* a, const Target* b) const {
return a->label() < b->label();
@@ -35,6 +37,12 @@ void RecursiveCollectDeps(const Target* target, std::set<Label>* result) {
const std::vector<const Target*>& deps = target->deps();
for (size_t i = 0; i < deps.size(); i++)
RecursiveCollectDeps(deps[i], result);
+
+ if (CommandLine::ForCurrentProcess()->HasSwitch(kIncludeDataDeps)) {
+ const std::vector<const Target*>& datadeps = target->datadeps();
+ for (size_t i = 0; i < datadeps.size(); i++)
+ RecursiveCollectDeps(datadeps[i], result);
+ }
}
// Prints dependencies of the given target (not the target itself).
@@ -42,6 +50,12 @@ void RecursivePrintDeps(const Target* target,
const Label& default_toolchain,
int indent_level) {
std::vector<const Target*> sorted_deps = target->deps();
+ if (CommandLine::ForCurrentProcess()->HasSwitch(kIncludeDataDeps)) {
+ const std::vector<const Target*> datadeps = target->datadeps();
+ for (size_t i = 0; i < datadeps.size(); i++)
+ sorted_deps.push_back(datadeps[i]);
+ }
+
std::sort(sorted_deps.begin(), sorted_deps.end(), CompareTargetLabel());
std::string indent(indent_level * 2, ' ');
@@ -53,10 +67,11 @@ void RecursivePrintDeps(const Target* target,
}
void PrintDeps(const Target* target, bool display_header) {
+ const CommandLine* cmdline = CommandLine::ForCurrentProcess();
Label toolchain_label = target->label().GetToolchainLabel();
// Tree mode is separate.
- if (CommandLine::ForCurrentProcess()->HasSwitch("tree")) {
+ if (cmdline->HasSwitch("tree")) {
if (display_header)
OutputString("\nDependency tree:\n");
RecursivePrintDeps(target, toolchain_label, 1);
@@ -65,7 +80,7 @@ void PrintDeps(const Target* target, bool display_header) {
// Collect the deps to display.
std::vector<Label> deps;
- if (CommandLine::ForCurrentProcess()->HasSwitch("all")) {
+ if (cmdline->HasSwitch("all")) {
if (display_header)
OutputString("\nAll recursive dependencies:\n");
@@ -83,6 +98,13 @@ void PrintDeps(const Target* target, bool display_header) {
const std::vector<const Target*>& target_deps = target->deps();
for (size_t i = 0; i < target_deps.size(); i++)
deps.push_back(target_deps[i]->label());
+
+ // Optionally include data deps.
+ if (cmdline->HasSwitch(kIncludeDataDeps)) {
scottmg 2013/08/06 20:27:58 i feel like you probably always want to see these,
brettw 2013/08/06 21:10:22 Okay, I removed this and included them all the tim
+ const std::vector<const Target*>& target_datadeps = target->datadeps();
+ for (size_t i = 0; i < target_datadeps.size(); i++)
+ deps.push_back(target_datadeps[i]->label());
+ }
}
std::sort(deps.begin(), deps.end());
@@ -223,11 +245,14 @@ const char kDesc_Help[] =
" via dependencies specifying \"all\" or \"direct\" dependent\n"
" configs.\n"
"\n"
- " deps [--all | --tree]\n"
+ " deps [--all | --tree] [--include-datadeps]\n"
" Show immediate (or, when \"--all\" or \"--tree\" is specified,\n"
" recursive) dependencies of the given target. \"--tree\" shows them\n"
" in a tree format. Otherwise, they will be sorted alphabetically.\n"
"\n"
+ " If \"--include-datadeps\" is specified, the datadeps will be shown\n"
+ " mixed in with the regular dependendencies.\n"
+ "\n"
" defines [--blame]\n"
" includes [--blame]\n"
" cflags [--blame]\n"
« no previous file with comments | « tools/gn/BUILD.gn ('k') | tools/gn/command_gen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698