| 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 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 Err err; | 292 Err err; |
| 293 if (!dotfile_scope_.CheckForUnusedVars(&err)) { | 293 if (!dotfile_scope_.CheckForUnusedVars(&err)) { |
| 294 err.PrintToStdout(); | 294 err.PrintToStdout(); |
| 295 return false; | 295 return false; |
| 296 } | 296 } |
| 297 | 297 |
| 298 if (fill_arguments_) { | 298 if (fill_arguments_) { |
| 299 if (!FillArguments(*cmdline)) | 299 if (!FillArguments(*cmdline)) |
| 300 return false; | 300 return false; |
| 301 } | 301 } |
| 302 FillPythonPath(); | 302 FillPythonPath(*cmdline); |
| 303 | 303 |
| 304 return true; | 304 return true; |
| 305 } | 305 } |
| 306 | 306 |
| 307 bool Setup::Run() { | 307 bool Setup::Run() { |
| 308 RunPreMessageLoop(); | 308 RunPreMessageLoop(); |
| 309 if (!scheduler_.Run()) | 309 if (!scheduler_.Run()) |
| 310 return false; | 310 return false; |
| 311 return RunPostMessageLoop(); | 311 return RunPostMessageLoop(); |
| 312 } | 312 } |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 587 "\nwhich doesn't seem to contain a previously-generated build.") | 587 "\nwhich doesn't seem to contain a previously-generated build.") |
| 588 .PrintToStdout(); | 588 .PrintToStdout(); |
| 589 return false; | 589 return false; |
| 590 } | 590 } |
| 591 } | 591 } |
| 592 | 592 |
| 593 build_settings_.SetBuildDir(resolved); | 593 build_settings_.SetBuildDir(resolved); |
| 594 return true; | 594 return true; |
| 595 } | 595 } |
| 596 | 596 |
| 597 void Setup::FillPythonPath() { | 597 void Setup::FillPythonPath(const base::CommandLine& cmdline) { |
| 598 // Trace this since it tends to be a bit slow on Windows. | 598 // Trace this since it tends to be a bit slow on Windows. |
| 599 ScopedTrace setup_trace(TraceItem::TRACE_SETUP, "Fill Python Path"); | 599 ScopedTrace setup_trace(TraceItem::TRACE_SETUP, "Fill Python Path"); |
| 600 if (cmdline.HasSwitch(switches::kScriptExecutable)) { |
| 601 build_settings_.set_python_path( |
| 602 cmdline.GetSwitchValuePath(switches::kScriptExecutable)); |
| 603 } else { |
| 600 #if defined(OS_WIN) | 604 #if defined(OS_WIN) |
| 601 base::FilePath python_path = FindWindowsPython(); | 605 base::FilePath python_path = FindWindowsPython(); |
| 602 if (python_path.empty()) { | 606 if (python_path.empty()) { |
| 603 scheduler_.Log("WARNING", "Could not find python on path, using " | 607 scheduler_.Log("WARNING", "Could not find python on path, using " |
| 604 "just \"python.exe\""); | 608 "just \"python.exe\""); |
| 605 python_path = base::FilePath(kPythonExeName); | 609 python_path = base::FilePath(kPythonExeName); |
| 610 } |
| 611 build_settings_.set_python_path(python_path.NormalizePathSeparatorsTo('/')); |
| 612 #else |
| 613 build_settings_.set_python_path(base::FilePath("python")); |
| 614 #endif |
| 606 } | 615 } |
| 607 build_settings_.set_python_path(python_path.NormalizePathSeparatorsTo('/')); | |
| 608 #else | |
| 609 build_settings_.set_python_path(base::FilePath("python")); | |
| 610 #endif | |
| 611 } | 616 } |
| 612 | 617 |
| 613 bool Setup::RunConfigFile() { | 618 bool Setup::RunConfigFile() { |
| 614 if (scheduler_.verbose_logging()) | 619 if (scheduler_.verbose_logging()) |
| 615 scheduler_.Log("Got dotfile", FilePathToUTF8(dotfile_name_)); | 620 scheduler_.Log("Got dotfile", FilePathToUTF8(dotfile_name_)); |
| 616 | 621 |
| 617 dotfile_input_file_.reset(new InputFile(SourceFile("//.gn"))); | 622 dotfile_input_file_.reset(new InputFile(SourceFile("//.gn"))); |
| 618 if (!dotfile_input_file_->Load(dotfile_name_)) { | 623 if (!dotfile_input_file_->Load(dotfile_name_)) { |
| 619 Err(Location(), "Could not load dotfile.", | 624 Err(Location(), "Could not load dotfile.", |
| 620 "The file \"" + FilePathToUTF8(dotfile_name_) + "\" cound't be loaded") | 625 "The file \"" + FilePathToUTF8(dotfile_name_) + "\" cound't be loaded") |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 726 if (err.has_error()) { | 731 if (err.has_error()) { |
| 727 err.PrintToStdout(); | 732 err.PrintToStdout(); |
| 728 return false; | 733 return false; |
| 729 } | 734 } |
| 730 } | 735 } |
| 731 build_settings_.set_exec_script_whitelist(std::move(whitelist)); | 736 build_settings_.set_exec_script_whitelist(std::move(whitelist)); |
| 732 } | 737 } |
| 733 | 738 |
| 734 return true; | 739 return true; |
| 735 } | 740 } |
| OLD | NEW |