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

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: unit test 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
« no previous file with comments | « tools/gn/setup.h ('k') | tools/gn/target.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 } // namespace 132 } // namespace
132 133
133 // CommonSetup ----------------------------------------------------------------- 134 // CommonSetup -----------------------------------------------------------------
134 135
135 CommonSetup::CommonSetup() 136 CommonSetup::CommonSetup()
136 : build_settings_(), 137 : build_settings_(),
137 loader_(new LoaderImpl(&build_settings_)), 138 loader_(new LoaderImpl(&build_settings_)),
138 builder_(new Builder(loader_.get())), 139 builder_(new Builder(loader_.get())),
139 root_build_file_("//BUILD.gn"), 140 root_build_file_("//BUILD.gn"),
140 check_for_bad_items_(true), 141 check_for_bad_items_(true),
141 check_for_unused_overrides_(true) { 142 check_for_unused_overrides_(true),
143 check_public_headers_(false) {
142 loader_->set_complete_callback(base::Bind(&DecrementWorkCount)); 144 loader_->set_complete_callback(base::Bind(&DecrementWorkCount));
143 } 145 }
144 146
145 CommonSetup::CommonSetup(const CommonSetup& other) 147 CommonSetup::CommonSetup(const CommonSetup& other)
146 : build_settings_(other.build_settings_), 148 : build_settings_(other.build_settings_),
147 loader_(new LoaderImpl(&build_settings_)), 149 loader_(new LoaderImpl(&build_settings_)),
148 builder_(new Builder(loader_.get())), 150 builder_(new Builder(loader_.get())),
149 root_build_file_(other.root_build_file_), 151 root_build_file_(other.root_build_file_),
150 check_for_bad_items_(other.check_for_bad_items_), 152 check_for_bad_items_(other.check_for_bad_items_),
151 check_for_unused_overrides_(other.check_for_unused_overrides_) { 153 check_for_unused_overrides_(other.check_for_unused_overrides_),
154 check_public_headers_(other.check_public_headers_) {
152 loader_->set_complete_callback(base::Bind(&DecrementWorkCount)); 155 loader_->set_complete_callback(base::Bind(&DecrementWorkCount));
153 } 156 }
154 157
155 CommonSetup::~CommonSetup() { 158 CommonSetup::~CommonSetup() {
156 } 159 }
157 160
158 void CommonSetup::RunPreMessageLoop() { 161 void CommonSetup::RunPreMessageLoop() {
159 // Load the root build file. 162 // Load the root build file.
160 loader_->Load(root_build_file_, Label()); 163 loader_->Load(root_build_file_, Label());
161 164
(...skipping 12 matching lines...) Expand all
174 177
175 if (check_for_unused_overrides_) { 178 if (check_for_unused_overrides_) {
176 if (!build_settings_.build_args().VerifyAllOverridesUsed(&err)) { 179 if (!build_settings_.build_args().VerifyAllOverridesUsed(&err)) {
177 // TODO(brettw) implement a system of warnings. Until we have a better 180 // TODO(brettw) implement a system of warnings. Until we have a better
178 // system, print the error but don't return failure. 181 // system, print the error but don't return failure.
179 err.PrintToStdout(); 182 err.PrintToStdout();
180 return true; 183 return true;
181 } 184 }
182 } 185 }
183 186
187 if (check_public_headers_) {
188 std::vector<const Target*> targets = builder_->GetAllResolvedTargets();
189 scoped_refptr<HeaderChecker> header_checker(
190 new HeaderChecker(&build_settings_, targets));
191
192 std::vector<Err> header_errors;
193 header_checker->Run(&header_errors);
194 for (size_t i = 0; i < header_errors.size(); i++) {
195 if (i > 0)
196 OutputString("___________________\n", DECORATION_YELLOW);
197 header_errors[i].PrintToStdout();
198 }
199 if (!header_errors.empty())
200 return false;
201 }
202
184 // Write out tracing and timing if requested. 203 // Write out tracing and timing if requested.
185 const CommandLine* cmdline = CommandLine::ForCurrentProcess(); 204 const CommandLine* cmdline = CommandLine::ForCurrentProcess();
186 if (cmdline->HasSwitch(kTimeSwitch)) 205 if (cmdline->HasSwitch(kTimeSwitch))
187 PrintLongHelp(SummarizeTraces()); 206 PrintLongHelp(SummarizeTraces());
188 if (cmdline->HasSwitch(kTracelogSwitch)) 207 if (cmdline->HasSwitch(kTracelogSwitch))
189 SaveTraces(cmdline->GetSwitchValuePath(kTracelogSwitch)); 208 SaveTraces(cmdline->GetSwitchValuePath(kTracelogSwitch));
190 209
191 return true; 210 return true;
192 } 211 }
193 212
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 } 500 }
482 501
483 void DependentSetup::RunPreMessageLoop() { 502 void DependentSetup::RunPreMessageLoop() {
484 CommonSetup::RunPreMessageLoop(); 503 CommonSetup::RunPreMessageLoop();
485 } 504 }
486 505
487 bool DependentSetup::RunPostMessageLoop() { 506 bool DependentSetup::RunPostMessageLoop() {
488 return CommonSetup::RunPostMessageLoop(); 507 return CommonSetup::RunPostMessageLoop();
489 } 508 }
490 509
OLDNEW
« no previous file with comments | « tools/gn/setup.h ('k') | tools/gn/target.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698