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 3 // found in the LICENSE file. 4 5 #ifndef TOOLS_GN_SETUP_H_ 6 #define TOOLS_GN_SETUP_H_ 7 8 #include <vector> 9 10 #include "base/basictypes.h" 11 #include "base/files/file_path.h" 12 #include "base/memory/scoped_ptr.h" 13 #include "tools/gn/build_settings.h" 14 #include "tools/gn/scheduler.h" 15 #include "tools/gn/scope.h" 16 #include "tools/gn/settings.h" 17 #include "tools/gn/token.h" 18 #include "tools/gn/toolchain.h" 19 20 class CommandLine; 21 class InputFile; 22 class ParseNode; 23 24 extern const char kDotfile_Help[]; 25 26 // Helper class to setup the build settings and environment for the various 27 // commands to run. 28 class Setup { 29 public: 30 Setup(); 31 ~Setup(); 32 33 // Configures the build for the current command line. On success returns 34 // true. On failure, prints the error and returns false. 35 bool DoSetup(); 36 37 // Runs the load, returning true on success. On failure, prints the error 38 // and returns false. 39 bool Run(); 40 41 BuildSettings& build_settings() { return build_settings_; } 42 Scheduler& scheduler() { return scheduler_; } 43 44 private: 45 // Fills the root directory into the settings. Returns true on success. 46 bool FillSourceDir(const CommandLine& cmdline); 47 48 // Run config file. 49 bool RunConfigFile(); 50 51 bool FillOtherConfig(const CommandLine& cmdline); 52 53 BuildSettings build_settings_; 54 Scheduler scheduler_; 55 56 // State for invoking the dotfile. 57 // TODO(brettw) this seems a bit excessive, maybe we can get this down 58 // somehow? 59 base::FilePath dotfile_name_; 60 scoped_ptr<InputFile> dotfile_input_file_; 61 std::vector<Token> dotfile_tokens_; 62 scoped_ptr<ParseNode> dotfile_root_; 63 BuildSettings dotfile_build_settings_; 64 Toolchain dotfile_toolchain_; 65 Settings dotfile_settings_; 66 Scope dotfile_scope_; 67 68 DISALLOW_COPY_AND_ASSIGN(Setup); 69 }; 70 71 #endif // TOOLS_GN_SETUP_H_ 72