OLD | NEW |
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 |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 } | 118 } |
119 | 119 |
120 } // namespace | 120 } // namespace |
121 | 121 |
122 // CommonSetup ----------------------------------------------------------------- | 122 // CommonSetup ----------------------------------------------------------------- |
123 | 123 |
124 CommonSetup::CommonSetup() | 124 CommonSetup::CommonSetup() |
125 : build_settings_(), | 125 : build_settings_(), |
126 loader_(new LoaderImpl(&build_settings_)), | 126 loader_(new LoaderImpl(&build_settings_)), |
127 builder_(new Builder(loader_.get())), | 127 builder_(new Builder(loader_.get())), |
128 check_for_bad_items_(true) { | 128 check_for_bad_items_(true), |
| 129 check_for_unused_overrides_(true) { |
129 loader_->set_complete_callback(base::Bind(&DecrementWorkCount)); | 130 loader_->set_complete_callback(base::Bind(&DecrementWorkCount)); |
130 } | 131 } |
131 | 132 |
132 CommonSetup::CommonSetup(const CommonSetup& other) | 133 CommonSetup::CommonSetup(const CommonSetup& other) |
133 : build_settings_(other.build_settings_), | 134 : build_settings_(other.build_settings_), |
134 loader_(new LoaderImpl(&build_settings_)), | 135 loader_(new LoaderImpl(&build_settings_)), |
135 builder_(new Builder(loader_.get())), | 136 builder_(new Builder(loader_.get())), |
136 check_for_bad_items_(other.check_for_bad_items_) { | 137 check_for_bad_items_(other.check_for_bad_items_), |
| 138 check_for_unused_overrides_(other.check_for_unused_overrides_) { |
137 loader_->set_complete_callback(base::Bind(&DecrementWorkCount)); | 139 loader_->set_complete_callback(base::Bind(&DecrementWorkCount)); |
138 } | 140 } |
139 | 141 |
140 CommonSetup::~CommonSetup() { | 142 CommonSetup::~CommonSetup() { |
141 } | 143 } |
142 | 144 |
143 void CommonSetup::RunPreMessageLoop() { | 145 void CommonSetup::RunPreMessageLoop() { |
144 // Load the root build file. | 146 // Load the root build file. |
145 loader_->Load(SourceFile("//BUILD.gn"), Label()); | 147 loader_->Load(SourceFile("//BUILD.gn"), Label()); |
146 | 148 |
147 // Will be decremented with the loader is drained. | 149 // Will be decremented with the loader is drained. |
148 g_scheduler->IncrementWorkCount(); | 150 g_scheduler->IncrementWorkCount(); |
149 } | 151 } |
150 | 152 |
151 bool CommonSetup::RunPostMessageLoop() { | 153 bool CommonSetup::RunPostMessageLoop() { |
152 Err err; | 154 Err err; |
153 if (check_for_bad_items_) { | 155 if (check_for_bad_items_) { |
154 if (!builder_->CheckForBadItems(&err)) { | 156 if (!builder_->CheckForBadItems(&err)) { |
155 err.PrintToStdout(); | 157 err.PrintToStdout(); |
156 return false; | 158 return false; |
157 } | 159 } |
158 } | 160 } |
159 | 161 |
160 if (!build_settings_.build_args().VerifyAllOverridesUsed(&err)) { | 162 if (check_for_unused_overrides_) { |
161 err.PrintToStdout(); | 163 if (!build_settings_.build_args().VerifyAllOverridesUsed(&err)) { |
162 return false; | 164 // TODO(brettw) implement a system of warnings. Until we have a better |
| 165 // system, print the error but don't return failure. |
| 166 err.PrintToStdout(); |
| 167 return true; |
| 168 } |
163 } | 169 } |
164 | 170 |
165 // Write out tracing and timing if requested. | 171 // Write out tracing and timing if requested. |
166 const CommandLine* cmdline = CommandLine::ForCurrentProcess(); | 172 const CommandLine* cmdline = CommandLine::ForCurrentProcess(); |
167 if (cmdline->HasSwitch(kTimeSwitch)) | 173 if (cmdline->HasSwitch(kTimeSwitch)) |
168 PrintLongHelp(SummarizeTraces()); | 174 PrintLongHelp(SummarizeTraces()); |
169 if (cmdline->HasSwitch(kTracelogSwitch)) | 175 if (cmdline->HasSwitch(kTracelogSwitch)) |
170 SaveTraces(cmdline->GetSwitchValuePath(kTracelogSwitch)); | 176 SaveTraces(cmdline->GetSwitchValuePath(kTracelogSwitch)); |
171 | 177 |
172 return true; | 178 return true; |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
426 } | 432 } |
427 | 433 |
428 void DependentSetup::RunPreMessageLoop() { | 434 void DependentSetup::RunPreMessageLoop() { |
429 CommonSetup::RunPreMessageLoop(); | 435 CommonSetup::RunPreMessageLoop(); |
430 } | 436 } |
431 | 437 |
432 bool DependentSetup::RunPostMessageLoop() { | 438 bool DependentSetup::RunPostMessageLoop() { |
433 return CommonSetup::RunPostMessageLoop(); | 439 return CommonSetup::RunPostMessageLoop(); |
434 } | 440 } |
435 | 441 |
OLD | NEW |