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.
5 #ifndef TOOLS_GN_SETUP_H_
6 #define TOOLS_GN_SETUP_H_
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"
24 extern const char kDotfile_Help
[];
26 // Helper class to setup the build settings and environment for the various
33 // Configures the build for the current command line. On success returns
34 // true. On failure, prints the error and returns false.
37 // When true (the default), Run() will check for unresolved dependencies and
38 // cycles upon completion. When false, such errors will be ignored.
39 void set_check_for_bad_items(bool s
) { check_for_bad_items_
= s
; }
41 // Runs the load, returning true on success. On failure, prints the error
45 BuildSettings
& build_settings() { return build_settings_
; }
46 Scheduler
& scheduler() { return scheduler_
; }
49 // Fills build arguments. Returns true on success.
50 bool FillArguments(const CommandLine
& cmdline
);
52 // Fills the root directory into the settings. Returns true on success.
53 bool FillSourceDir(const CommandLine
& cmdline
);
55 // Fills the python path portion of the command line. On failure, sets
56 // it to just "python".
57 void FillPythonPath();
62 bool FillOtherConfig(const CommandLine
& cmdline
);
64 BuildSettings build_settings_
;
67 bool check_for_bad_items_
;
69 // These empty settings and toolchain are used to interpret the command line
71 BuildSettings empty_build_settings_
;
72 Toolchain empty_toolchain_
;
73 Settings empty_settings_
;
76 // State for invoking the dotfile.
77 base::FilePath dotfile_name_
;
78 scoped_ptr
<InputFile
> dotfile_input_file_
;
79 std::vector
<Token
> dotfile_tokens_
;
80 scoped_ptr
<ParseNode
> dotfile_root_
;
82 // State for invoking the command line args. We specifically want to keep
83 // this around for the entire run so that Values can blame to the command
84 // line when we issue errors about them.
85 scoped_ptr
<InputFile
> args_input_file_
;
86 std::vector
<Token
> args_tokens_
;
87 scoped_ptr
<ParseNode
> args_root_
;
89 DISALLOW_COPY_AND_ASSIGN(Setup
);
92 #endif // TOOLS_GN_SETUP_H_