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

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

Issue 216903004: Add optional public header checking to GN build (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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 | Annotate | Revision Log
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/setup.h" 5 #include "tools/gn/setup.h"
6 6
7 #include <stdlib.h> 7 #include <stdlib.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/file_util.h" 13 #include "base/file_util.h"
14 #include "base/files/file_path.h" 14 #include "base/files/file_path.h"
15 #include "base/process/launch.h" 15 #include "base/process/launch.h"
16 #include "base/strings/string_split.h" 16 #include "base/strings/string_split.h"
17 #include "base/strings/string_util.h" 17 #include "base/strings/string_util.h"
18 #include "base/strings/utf_string_conversions.h" 18 #include "base/strings/utf_string_conversions.h"
19 #include "build/build_config.h" 19 #include "build/build_config.h"
20 #include "tools/gn/filesystem_utils.h" 20 #include "tools/gn/filesystem_utils.h"
21 #include "tools/gn/header_checker.h"
21 #include "tools/gn/input_file.h" 22 #include "tools/gn/input_file.h"
22 #include "tools/gn/parse_tree.h" 23 #include "tools/gn/parse_tree.h"
23 #include "tools/gn/parser.h" 24 #include "tools/gn/parser.h"
24 #include "tools/gn/source_dir.h" 25 #include "tools/gn/source_dir.h"
25 #include "tools/gn/source_file.h" 26 #include "tools/gn/source_file.h"
26 #include "tools/gn/standard_out.h" 27 #include "tools/gn/standard_out.h"
27 #include "tools/gn/tokenizer.h" 28 #include "tools/gn/tokenizer.h"
28 #include "tools/gn/trace.h" 29 #include "tools/gn/trace.h"
29 #include "tools/gn/value.h" 30 #include "tools/gn/value.h"
30 31
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 117
117 } // namespace 118 } // namespace
118 119
119 // CommonSetup ----------------------------------------------------------------- 120 // CommonSetup -----------------------------------------------------------------
120 121
121 CommonSetup::CommonSetup() 122 CommonSetup::CommonSetup()
122 : build_settings_(), 123 : build_settings_(),
123 loader_(new LoaderImpl(&build_settings_)), 124 loader_(new LoaderImpl(&build_settings_)),
124 builder_(new Builder(loader_.get())), 125 builder_(new Builder(loader_.get())),
125 check_for_bad_items_(true), 126 check_for_bad_items_(true),
126 check_for_unused_overrides_(true) { 127 check_for_unused_overrides_(true),
128 check_public_headers_(false) {
127 loader_->set_complete_callback(base::Bind(&DecrementWorkCount)); 129 loader_->set_complete_callback(base::Bind(&DecrementWorkCount));
128 } 130 }
129 131
130 CommonSetup::CommonSetup(const CommonSetup& other) 132 CommonSetup::CommonSetup(const CommonSetup& other)
131 : build_settings_(other.build_settings_), 133 : build_settings_(other.build_settings_),
132 loader_(new LoaderImpl(&build_settings_)), 134 loader_(new LoaderImpl(&build_settings_)),
133 builder_(new Builder(loader_.get())), 135 builder_(new Builder(loader_.get())),
134 check_for_bad_items_(other.check_for_bad_items_), 136 check_for_bad_items_(other.check_for_bad_items_),
135 check_for_unused_overrides_(other.check_for_unused_overrides_) { 137 check_for_unused_overrides_(other.check_for_unused_overrides_) {
136 loader_->set_complete_callback(base::Bind(&DecrementWorkCount)); 138 loader_->set_complete_callback(base::Bind(&DecrementWorkCount));
(...skipping 21 matching lines...) Expand all
158 160
159 if (check_for_unused_overrides_) { 161 if (check_for_unused_overrides_) {
160 if (!build_settings_.build_args().VerifyAllOverridesUsed(&err)) { 162 if (!build_settings_.build_args().VerifyAllOverridesUsed(&err)) {
161 // TODO(brettw) implement a system of warnings. Until we have a better 163 // TODO(brettw) implement a system of warnings. Until we have a better
162 // system, print the error but don't return failure. 164 // system, print the error but don't return failure.
163 err.PrintToStdout(); 165 err.PrintToStdout();
164 return true; 166 return true;
165 } 167 }
166 } 168 }
167 169
170 if (check_public_headers_) {
171 std::vector<const Target*> targets = builder_->GetAllResolvedTargets();
172 scoped_refptr<HeaderChecker> header_checker(
173 new HeaderChecker(&build_settings_, targets));
174
175 std::vector<Err> header_errors;
176 header_checker->Run(&header_errors);
177 for (size_t i = 0; i < header_errors.size(); i++) {
178 if (i > 0)
179 OutputString("___________________\n", DECORATION_YELLOW);
180 header_errors[i].PrintToStdout();
181 }
182 if (!header_errors.empty())
183 return false;
184 }
185
168 // Write out tracing and timing if requested. 186 // Write out tracing and timing if requested.
169 const CommandLine* cmdline = CommandLine::ForCurrentProcess(); 187 const CommandLine* cmdline = CommandLine::ForCurrentProcess();
170 if (cmdline->HasSwitch(kTimeSwitch)) 188 if (cmdline->HasSwitch(kTimeSwitch))
171 PrintLongHelp(SummarizeTraces()); 189 PrintLongHelp(SummarizeTraces());
172 if (cmdline->HasSwitch(kTracelogSwitch)) 190 if (cmdline->HasSwitch(kTracelogSwitch))
173 SaveTraces(cmdline->GetSwitchValuePath(kTracelogSwitch)); 191 SaveTraces(cmdline->GetSwitchValuePath(kTracelogSwitch));
174 192
175 return true; 193 return true;
176 } 194 }
177 195
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 } 449 }
432 450
433 void DependentSetup::RunPreMessageLoop() { 451 void DependentSetup::RunPreMessageLoop() {
434 CommonSetup::RunPreMessageLoop(); 452 CommonSetup::RunPreMessageLoop();
435 } 453 }
436 454
437 bool DependentSetup::RunPostMessageLoop() { 455 bool DependentSetup::RunPostMessageLoop() {
438 return CommonSetup::RunPostMessageLoop(); 456 return CommonSetup::RunPostMessageLoop();
439 } 457 }
440 458
OLDNEW
« tools/gn/header_checker.cc ('K') | « tools/gn/setup.h ('k') | tools/gn/target.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698