| 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 #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 Loading... |
| 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_, {base::Hash("//.gn")}), |
| 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 Loading... |
| 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_, |
| 469 {base::Hash(args_input_file_->name().value())}); |
| 469 // Set soure dir so relative imports in args work. | 470 // Set soure dir so relative imports in args work. |
| 470 SourceDir root_source_dir = | 471 SourceDir root_source_dir = |
| 471 SourceDirForCurrentDirectory(build_settings_.root_path()); | 472 SourceDirForCurrentDirectory(build_settings_.root_path()); |
| 472 arg_scope.set_source_dir(root_source_dir); | 473 arg_scope.set_source_dir(root_source_dir); |
| 473 args_root_->Execute(&arg_scope, &err); | 474 args_root_->Execute(&arg_scope, &err); |
| 474 if (err.has_error()) { | 475 if (err.has_error()) { |
| 475 err.PrintToStdout(); | 476 err.PrintToStdout(); |
| 476 return false; | 477 return false; |
| 477 } | 478 } |
| 478 | 479 |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 645 build_settings_.set_python_path(base::FilePath("python")); | 646 build_settings_.set_python_path(base::FilePath("python")); |
| 646 #endif | 647 #endif |
| 647 } | 648 } |
| 648 } | 649 } |
| 649 | 650 |
| 650 bool Setup::RunConfigFile() { | 651 bool Setup::RunConfigFile() { |
| 651 if (scheduler_.verbose_logging()) | 652 if (scheduler_.verbose_logging()) |
| 652 scheduler_.Log("Got dotfile", FilePathToUTF8(dotfile_name_)); | 653 scheduler_.Log("Got dotfile", FilePathToUTF8(dotfile_name_)); |
| 653 | 654 |
| 654 dotfile_input_file_.reset(new InputFile(SourceFile("//.gn"))); | 655 dotfile_input_file_.reset(new InputFile(SourceFile("//.gn"))); |
| 656 dotfile_scope_.AddSourceFile(dotfile_input_file_->name()); |
| 655 if (!dotfile_input_file_->Load(dotfile_name_)) { | 657 if (!dotfile_input_file_->Load(dotfile_name_)) { |
| 656 Err(Location(), "Could not load dotfile.", | 658 Err(Location(), "Could not load dotfile.", |
| 657 "The file \"" + FilePathToUTF8(dotfile_name_) + "\" couldn't be loaded") | 659 "The file \"" + FilePathToUTF8(dotfile_name_) + "\" couldn't be loaded") |
| 658 .PrintToStdout(); | 660 .PrintToStdout(); |
| 659 return false; | 661 return false; |
| 660 } | 662 } |
| 661 | 663 |
| 662 Err err; | 664 Err err; |
| 663 dotfile_tokens_ = Tokenizer::Tokenize(dotfile_input_file_.get(), &err); | 665 dotfile_tokens_ = Tokenizer::Tokenize(dotfile_input_file_.get(), &err); |
| 664 if (err.has_error()) { | 666 if (err.has_error()) { |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 787 if (!arg_file_template_value->VerifyTypeIs(Value::STRING, &err)) { | 789 if (!arg_file_template_value->VerifyTypeIs(Value::STRING, &err)) { |
| 788 err.PrintToStdout(); | 790 err.PrintToStdout(); |
| 789 return false; | 791 return false; |
| 790 } | 792 } |
| 791 SourceFile path(arg_file_template_value->string_value()); | 793 SourceFile path(arg_file_template_value->string_value()); |
| 792 build_settings_.set_arg_file_template_path(path); | 794 build_settings_.set_arg_file_template_path(path); |
| 793 } | 795 } |
| 794 | 796 |
| 795 return true; | 797 return true; |
| 796 } | 798 } |
| OLD | NEW |