| 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/compiler_specific.h" | |
| 12 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
| 13 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 14 #include "tools/gn/build_settings.h" | 13 #include "tools/gn/build_settings.h" |
| 15 #include "tools/gn/builder.h" | 14 #include "tools/gn/builder.h" |
| 16 #include "tools/gn/loader.h" | 15 #include "tools/gn/loader.h" |
| 17 #include "tools/gn/scheduler.h" | 16 #include "tools/gn/scheduler.h" |
| 18 #include "tools/gn/scope.h" | 17 #include "tools/gn/scope.h" |
| 19 #include "tools/gn/settings.h" | 18 #include "tools/gn/settings.h" |
| 20 #include "tools/gn/token.h" | 19 #include "tools/gn/token.h" |
| 21 #include "tools/gn/toolchain.h" | 20 #include "tools/gn/toolchain.h" |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 | 82 |
| 84 private: | 83 private: |
| 85 CommonSetup& operator=(const CommonSetup& other); // Disallow. | 84 CommonSetup& operator=(const CommonSetup& other); // Disallow. |
| 86 }; | 85 }; |
| 87 | 86 |
| 88 // Helper class to setup the build settings and environment for the various | 87 // Helper class to setup the build settings and environment for the various |
| 89 // commands to run. | 88 // commands to run. |
| 90 class Setup : public CommonSetup { | 89 class Setup : public CommonSetup { |
| 91 public: | 90 public: |
| 92 Setup(); | 91 Setup(); |
| 93 virtual ~Setup(); | 92 ~Setup() override; |
| 94 | 93 |
| 95 // Configures the build for the current command line. On success returns | 94 // Configures the build for the current command line. On success returns |
| 96 // true. On failure, prints the error and returns false. | 95 // true. On failure, prints the error and returns false. |
| 97 // | 96 // |
| 98 // The parameter is the string the user specified for the build directory. We | 97 // The parameter is the string the user specified for the build directory. We |
| 99 // will try to interpret this as a SourceDir if possible, and will fail if is | 98 // will try to interpret this as a SourceDir if possible, and will fail if is |
| 100 // is malformed. | 99 // is malformed. |
| 101 // | 100 // |
| 102 // With force_create = false, setup will fail if the build directory doesn't | 101 // With force_create = false, setup will fail if the build directory doesn't |
| 103 // alreay exist with an args file in it. With force_create set to true, the | 102 // alreay exist with an args file in it. With force_create set to true, the |
| 104 // directory will be created if necessary. Commands explicitly doing | 103 // directory will be created if necessary. Commands explicitly doing |
| 105 // generation should set this to true to create it, but querying commands | 104 // generation should set this to true to create it, but querying commands |
| 106 // should set it to false to prevent creating oddly-named directories in case | 105 // should set it to false to prevent creating oddly-named directories in case |
| 107 // the user omits the build directory argument (which is easy to do). | 106 // the user omits the build directory argument (which is easy to do). |
| 108 bool DoSetup(const std::string& build_dir, bool force_create); | 107 bool DoSetup(const std::string& build_dir, bool force_create); |
| 109 | 108 |
| 110 // Runs the load, returning true on success. On failure, prints the error | 109 // Runs the load, returning true on success. On failure, prints the error |
| 111 // and returns false. This includes both RunPreMessageLoop() and | 110 // and returns false. This includes both RunPreMessageLoop() and |
| 112 // RunPostMessageLoop(). | 111 // RunPostMessageLoop(). |
| 113 bool Run(); | 112 bool Run(); |
| 114 | 113 |
| 115 Scheduler& scheduler() { return scheduler_; } | 114 Scheduler& scheduler() { return scheduler_; } |
| 116 | 115 |
| 117 virtual Scheduler* GetScheduler() override; | 116 Scheduler* GetScheduler() override; |
| 118 | 117 |
| 119 // Returns the file used to store the build arguments. Note that the path | 118 // Returns the file used to store the build arguments. Note that the path |
| 120 // might not exist. | 119 // might not exist. |
| 121 SourceFile GetBuildArgFile() const; | 120 SourceFile GetBuildArgFile() const; |
| 122 | 121 |
| 123 // Sets whether the build arguments should be filled during setup from the | 122 // Sets whether the build arguments should be filled during setup from the |
| 124 // command line/build argument file. This will be true by default. The use | 123 // command line/build argument file. This will be true by default. The use |
| 125 // case for setting it to false is when editing build arguments, we don't | 124 // case for setting it to false is when editing build arguments, we don't |
| 126 // want to rely on them being valid. | 125 // want to rely on them being valid. |
| 127 void set_fill_arguments(bool fa) { fill_arguments_ = fa; } | 126 void set_fill_arguments(bool fa) { fill_arguments_ = fa; } |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 // main_setup.Run(); | 194 // main_setup.Run(); |
| 196 // dependent_setup.RunPostMessageLoop(); | 195 // dependent_setup.RunPostMessageLoop(); |
| 197 // so that the main setup executes the message loop, but both are run. | 196 // so that the main setup executes the message loop, but both are run. |
| 198 class DependentSetup : public CommonSetup { | 197 class DependentSetup : public CommonSetup { |
| 199 public: | 198 public: |
| 200 // Note: this could be one function that takes a CommonSetup*, but then | 199 // Note: this could be one function that takes a CommonSetup*, but then |
| 201 // the compiler can get confused what to call, since it also matches the | 200 // the compiler can get confused what to call, since it also matches the |
| 202 // default copy constructor. | 201 // default copy constructor. |
| 203 DependentSetup(Setup* derive_from); | 202 DependentSetup(Setup* derive_from); |
| 204 DependentSetup(DependentSetup* derive_from); | 203 DependentSetup(DependentSetup* derive_from); |
| 205 virtual ~DependentSetup(); | 204 ~DependentSetup() override; |
| 206 | 205 |
| 207 // These are the two parts of Run() in the regular setup, not including the | 206 // These are the two parts of Run() in the regular setup, not including the |
| 208 // call to actually run the message loop. | 207 // call to actually run the message loop. |
| 209 void RunPreMessageLoop(); | 208 void RunPreMessageLoop(); |
| 210 bool RunPostMessageLoop(); | 209 bool RunPostMessageLoop(); |
| 211 | 210 |
| 212 virtual Scheduler* GetScheduler() override; | 211 Scheduler* GetScheduler() override; |
| 213 | 212 |
| 214 private: | 213 private: |
| 215 Scheduler* scheduler_; | 214 Scheduler* scheduler_; |
| 216 }; | 215 }; |
| 217 | 216 |
| 218 #endif // TOOLS_GN_SETUP_H_ | 217 #endif // TOOLS_GN_SETUP_H_ |
| OLD | NEW |