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

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

Issue 2940873002: Implement tracking of BUILD.gn files used to define target, toolchain or (Closed)
Patch Set: Use base::flat_set instead of std::set. Created 3 years, 5 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
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 #include <algorithm> 8 #include <algorithm>
9 #include <sstream> 9 #include <sstream>
10 #include <utility> 10 #include <utility>
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 269
270 const char Setup::kBuildArgFileName[] = "args.gn"; 270 const char Setup::kBuildArgFileName[] = "args.gn";
271 271
272 Setup::Setup() 272 Setup::Setup()
273 : build_settings_(), 273 : build_settings_(),
274 loader_(new LoaderImpl(&build_settings_)), 274 loader_(new LoaderImpl(&build_settings_)),
275 builder_(loader_.get()), 275 builder_(loader_.get()),
276 root_build_file_("//BUILD.gn"), 276 root_build_file_("//BUILD.gn"),
277 check_public_headers_(false), 277 check_public_headers_(false),
278 dotfile_settings_(&build_settings_, std::string()), 278 dotfile_settings_(&build_settings_, std::string()),
279 dotfile_scope_(&dotfile_settings_), 279 dotfile_scope_(&dotfile_settings_, {}),
280 default_args_(nullptr), 280 default_args_(nullptr),
281 fill_arguments_(true) { 281 fill_arguments_(true) {
282 dotfile_settings_.set_toolchain_label(Label()); 282 dotfile_settings_.set_toolchain_label(Label());
283 283
284 build_settings_.set_item_defined_callback( 284 build_settings_.set_item_defined_callback(
285 base::Bind(&ItemDefinedCallback, scheduler_.task_runner(), &builder_)); 285 base::Bind(&ItemDefinedCallback, scheduler_.task_runner(), &builder_));
286 286
287 loader_->set_complete_callback(base::Bind(&DecrementWorkCount)); 287 loader_->set_complete_callback(base::Bind(&DecrementWorkCount));
288 // The scheduler's task runner wasn't created when the Loader was created, so 288 // The scheduler's task runner wasn't created when the Loader was created, so
289 // we need to set it now. 289 // we need to set it now.
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 err.PrintToStdout(); 458 err.PrintToStdout();
459 return false; 459 return false;
460 } 460 }
461 461
462 args_root_ = Parser::Parse(args_tokens_, &err); 462 args_root_ = Parser::Parse(args_tokens_, &err);
463 if (err.has_error()) { 463 if (err.has_error()) {
464 err.PrintToStdout(); 464 err.PrintToStdout();
465 return false; 465 return false;
466 } 466 }
467 467
468 Scope arg_scope(&dotfile_settings_); 468 Scope arg_scope(&dotfile_settings_, {args_input_file_.get()});
469 // Set soure dir so relative imports in args work. 469 // Set soure dir so relative imports in args work.
470 SourceDir root_source_dir = 470 SourceDir root_source_dir =
471 SourceDirForCurrentDirectory(build_settings_.root_path()); 471 SourceDirForCurrentDirectory(build_settings_.root_path());
472 arg_scope.set_source_dir(root_source_dir); 472 arg_scope.set_source_dir(root_source_dir);
473 args_root_->Execute(&arg_scope, &err); 473 args_root_->Execute(&arg_scope, &err);
474 if (err.has_error()) { 474 if (err.has_error()) {
475 err.PrintToStdout(); 475 err.PrintToStdout();
476 return false; 476 return false;
477 } 477 }
478 478
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
645 build_settings_.set_python_path(base::FilePath("python")); 645 build_settings_.set_python_path(base::FilePath("python"));
646 #endif 646 #endif
647 } 647 }
648 } 648 }
649 649
650 bool Setup::RunConfigFile() { 650 bool Setup::RunConfigFile() {
651 if (scheduler_.verbose_logging()) 651 if (scheduler_.verbose_logging())
652 scheduler_.Log("Got dotfile", FilePathToUTF8(dotfile_name_)); 652 scheduler_.Log("Got dotfile", FilePathToUTF8(dotfile_name_));
653 653
654 dotfile_input_file_.reset(new InputFile(SourceFile("//.gn"))); 654 dotfile_input_file_.reset(new InputFile(SourceFile("//.gn")));
655 dotfile_scope_.AddInputFile(dotfile_input_file_.get());
655 if (!dotfile_input_file_->Load(dotfile_name_)) { 656 if (!dotfile_input_file_->Load(dotfile_name_)) {
656 Err(Location(), "Could not load dotfile.", 657 Err(Location(), "Could not load dotfile.",
657 "The file \"" + FilePathToUTF8(dotfile_name_) + "\" couldn't be loaded") 658 "The file \"" + FilePathToUTF8(dotfile_name_) + "\" couldn't be loaded")
658 .PrintToStdout(); 659 .PrintToStdout();
659 return false; 660 return false;
660 } 661 }
661 662
662 Err err; 663 Err err;
663 dotfile_tokens_ = Tokenizer::Tokenize(dotfile_input_file_.get(), &err); 664 dotfile_tokens_ = Tokenizer::Tokenize(dotfile_input_file_.get(), &err);
664 if (err.has_error()) { 665 if (err.has_error()) {
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
787 if (!arg_file_template_value->VerifyTypeIs(Value::STRING, &err)) { 788 if (!arg_file_template_value->VerifyTypeIs(Value::STRING, &err)) {
788 err.PrintToStdout(); 789 err.PrintToStdout();
789 return false; 790 return false;
790 } 791 }
791 SourceFile path(arg_file_template_value->string_value()); 792 SourceFile path(arg_file_template_value->string_value());
792 build_settings_.set_arg_file_template_path(path); 793 build_settings_.set_arg_file_template_path(path);
793 } 794 }
794 795
795 return true; 796 return true;
796 } 797 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698