| 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 #ifndef TOOLS_GN_SETUP_H_ | 5 #ifndef TOOLS_GN_SETUP_H_ |
| 6 #define TOOLS_GN_SETUP_H_ | 6 #define TOOLS_GN_SETUP_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "tools/gn/build_settings.h" | 13 #include "tools/gn/build_settings.h" |
| 14 #include "tools/gn/builder.h" |
| 15 #include "tools/gn/loader.h" |
| 14 #include "tools/gn/scheduler.h" | 16 #include "tools/gn/scheduler.h" |
| 15 #include "tools/gn/scope.h" | 17 #include "tools/gn/scope.h" |
| 16 #include "tools/gn/settings.h" | 18 #include "tools/gn/settings.h" |
| 17 #include "tools/gn/token.h" | 19 #include "tools/gn/token.h" |
| 18 #include "tools/gn/toolchain.h" | 20 #include "tools/gn/toolchain.h" |
| 19 | 21 |
| 20 class CommandLine; | 22 class CommandLine; |
| 21 class InputFile; | 23 class InputFile; |
| 22 class ParseNode; | 24 class ParseNode; |
| 23 | 25 |
| 24 extern const char kDotfile_Help[]; | 26 extern const char kDotfile_Help[]; |
| 25 | 27 |
| 26 // Base class for code shared between Setup and DependentSetup. | 28 // Base class for code shared between Setup and DependentSetup. |
| 27 class CommonSetup { | 29 class CommonSetup { |
| 28 public: | 30 public: |
| 29 virtual ~CommonSetup(); | 31 virtual ~CommonSetup(); |
| 30 | 32 |
| 31 // When true (the default), Run() will check for unresolved dependencies and | 33 // When true (the default), Run() will check for unresolved dependencies and |
| 32 // cycles upon completion. When false, such errors will be ignored. | 34 // cycles upon completion. When false, such errors will be ignored. |
| 33 void set_check_for_bad_items(bool s) { check_for_bad_items_ = s; } | 35 void set_check_for_bad_items(bool s) { check_for_bad_items_ = s; } |
| 34 | 36 |
| 35 BuildSettings& build_settings() { return build_settings_; } | 37 BuildSettings& build_settings() { return build_settings_; } |
| 38 Builder* builder() { return builder_.get(); } |
| 39 LoaderImpl* loader() { return loader_.get(); } |
| 36 | 40 |
| 37 protected: | 41 protected: |
| 38 CommonSetup(); | 42 CommonSetup(); |
| 39 CommonSetup(const CommonSetup& other); | 43 CommonSetup(const CommonSetup& other); |
| 40 | 44 |
| 41 // Performs the two sets of operations to run the generation before and after | 45 // Performs the two sets of operations to run the generation before and after |
| 42 // the message loop is run. | 46 // the message loop is run. |
| 43 void RunPreMessageLoop(); | 47 void RunPreMessageLoop(); |
| 44 bool RunPostMessageLoop(); | 48 bool RunPostMessageLoop(); |
| 45 | 49 |
| 46 protected: | |
| 47 BuildSettings build_settings_; | 50 BuildSettings build_settings_; |
| 51 scoped_refptr<LoaderImpl> loader_; |
| 52 scoped_refptr<Builder> builder_; |
| 48 | 53 |
| 49 bool check_for_bad_items_; | 54 bool check_for_bad_items_; |
| 50 | 55 |
| 51 private: | 56 private: |
| 52 CommonSetup& operator=(const CommonSetup& other); // Disallow. | 57 CommonSetup& operator=(const CommonSetup& other); // Disallow. |
| 53 }; | 58 }; |
| 54 | 59 |
| 55 // Helper class to setup the build settings and environment for the various | 60 // Helper class to setup the build settings and environment for the various |
| 56 // commands to run. | 61 // commands to run. |
| 57 class Setup : public CommonSetup { | 62 class Setup : public CommonSetup { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 // make a dependent setup which clones the state of the main one, make any | 119 // make a dependent setup which clones the state of the main one, make any |
| 115 // necessary changes, and then run it. | 120 // necessary changes, and then run it. |
| 116 // | 121 // |
| 117 // The way to run both at the same time is: | 122 // The way to run both at the same time is: |
| 118 // dependent_setup.RunPreMessageLoop(); | 123 // dependent_setup.RunPreMessageLoop(); |
| 119 // main_setup.Run(); | 124 // main_setup.Run(); |
| 120 // dependent_setup.RunPostMessageLoop(); | 125 // dependent_setup.RunPostMessageLoop(); |
| 121 // so that the main setup executes the message loop, but both are run. | 126 // so that the main setup executes the message loop, but both are run. |
| 122 class DependentSetup : public CommonSetup { | 127 class DependentSetup : public CommonSetup { |
| 123 public: | 128 public: |
| 124 DependentSetup(const Setup& main_setup); | 129 DependentSetup(Setup& main_setup); |
| 125 virtual ~DependentSetup(); | 130 virtual ~DependentSetup(); |
| 126 | 131 |
| 127 // These are the two parts of Run() in the regular setup, not including the | 132 // These are the two parts of Run() in the regular setup, not including the |
| 128 // call to actually run the message loop. | 133 // call to actually run the message loop. |
| 129 void RunPreMessageLoop(); | 134 void RunPreMessageLoop(); |
| 130 bool RunPostMessageLoop(); | 135 bool RunPostMessageLoop(); |
| 131 | 136 |
| 132 private: | 137 private: |
| 133 DISALLOW_COPY_AND_ASSIGN(DependentSetup); | 138 DISALLOW_COPY_AND_ASSIGN(DependentSetup); |
| 134 }; | 139 }; |
| 135 | 140 |
| 136 #endif // TOOLS_GN_SETUP_H_ | 141 #endif // TOOLS_GN_SETUP_H_ |
| OLD | NEW |