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 #include <sstream> | 10 #include <sstream> |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 | 150 |
151 } // namespace | 151 } // namespace |
152 | 152 |
153 const char Setup::kBuildArgFileName[] = "args.gn"; | 153 const char Setup::kBuildArgFileName[] = "args.gn"; |
154 | 154 |
155 Setup::Setup() | 155 Setup::Setup() |
156 : build_settings_(), | 156 : build_settings_(), |
157 loader_(new LoaderImpl(&build_settings_)), | 157 loader_(new LoaderImpl(&build_settings_)), |
158 builder_(new Builder(loader_.get())), | 158 builder_(new Builder(loader_.get())), |
159 root_build_file_("//BUILD.gn"), | 159 root_build_file_("//BUILD.gn"), |
160 check_for_bad_items_(true), | |
161 check_for_unused_overrides_(true), | |
162 check_public_headers_(false), | 160 check_public_headers_(false), |
163 dotfile_settings_(&build_settings_, std::string()), | 161 dotfile_settings_(&build_settings_, std::string()), |
164 dotfile_scope_(&dotfile_settings_), | 162 dotfile_scope_(&dotfile_settings_), |
165 fill_arguments_(true) { | 163 fill_arguments_(true) { |
166 dotfile_settings_.set_toolchain_label(Label()); | 164 dotfile_settings_.set_toolchain_label(Label()); |
167 build_settings_.set_item_defined_callback( | 165 build_settings_.set_item_defined_callback( |
168 base::Bind(&ItemDefinedCallback, scheduler_.main_loop(), builder_)); | 166 base::Bind(&ItemDefinedCallback, scheduler_.main_loop(), builder_)); |
169 | 167 |
170 loader_->set_complete_callback(base::Bind(&DecrementWorkCount)); | 168 loader_->set_complete_callback(base::Bind(&DecrementWorkCount)); |
171 // The scheduler's main loop wasn't created when the Loader was created, so | 169 // The scheduler's main loop wasn't created when the Loader was created, so |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 void Setup::RunPreMessageLoop() { | 225 void Setup::RunPreMessageLoop() { |
228 // Load the root build file. | 226 // Load the root build file. |
229 loader_->Load(root_build_file_, LocationRange(), Label()); | 227 loader_->Load(root_build_file_, LocationRange(), Label()); |
230 | 228 |
231 // Will be decremented with the loader is drained. | 229 // Will be decremented with the loader is drained. |
232 g_scheduler->IncrementWorkCount(); | 230 g_scheduler->IncrementWorkCount(); |
233 } | 231 } |
234 | 232 |
235 bool Setup::RunPostMessageLoop() { | 233 bool Setup::RunPostMessageLoop() { |
236 Err err; | 234 Err err; |
237 if (check_for_bad_items_) { | 235 if (build_settings_.check_for_bad_items()) { |
238 if (!builder_->CheckForBadItems(&err)) { | 236 if (!builder_->CheckForBadItems(&err)) { |
239 err.PrintToStdout(); | 237 err.PrintToStdout(); |
240 return false; | 238 return false; |
241 } | 239 } |
242 } | |
243 | 240 |
244 if (check_for_unused_overrides_) { | |
245 if (!build_settings_.build_args().VerifyAllOverridesUsed(&err)) { | 241 if (!build_settings_.build_args().VerifyAllOverridesUsed(&err)) { |
246 // TODO(brettw) implement a system of warnings. Until we have a better | 242 // TODO(brettw) implement a system of warnings. Until we have a better |
247 // system, print the error but don't return failure. | 243 // system, print the error but don't return failure. |
248 err.PrintToStdout(); | 244 err.PrintToStdout(); |
249 return true; | 245 return true; |
250 } | 246 } |
251 } | 247 } |
252 | 248 |
253 if (check_public_headers_) { | 249 if (check_public_headers_) { |
254 std::vector<const Target*> all_targets = builder_->GetAllResolvedTargets(); | 250 std::vector<const Target*> all_targets = builder_->GetAllResolvedTargets(); |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
622 err.PrintToStdout(); | 618 err.PrintToStdout(); |
623 return false; | 619 return false; |
624 } | 620 } |
625 whitelist->insert(current_dir.ResolveRelativeFile(item.string_value())); | 621 whitelist->insert(current_dir.ResolveRelativeFile(item.string_value())); |
626 } | 622 } |
627 build_settings_.set_exec_script_whitelist(whitelist.Pass()); | 623 build_settings_.set_exec_script_whitelist(whitelist.Pass()); |
628 } | 624 } |
629 | 625 |
630 return true; | 626 return true; |
631 } | 627 } |
OLD | NEW |