[Android WebViewShell] Add inclusion test for webview exposed stable interfaces.
[chromium-blink-merge.git] / tools / gn / build_settings.h
blobf64d5b7518c6414c07e3af39a9e11267dca289cc
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_BUILD_SETTINGS_H_
6 #define TOOLS_GN_BUILD_SETTINGS_H_
8 #include <map>
9 #include <set>
11 #include "base/basictypes.h"
12 #include "base/callback.h"
13 #include "base/files/file_path.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "tools/gn/args.h"
16 #include "tools/gn/scope.h"
17 #include "tools/gn/source_dir.h"
18 #include "tools/gn/source_file.h"
20 class Item;
22 // Settings for one build, which is one toplevel output directory. There
23 // may be multiple Settings objects that refer to this, one for each toolchain.
24 class BuildSettings {
25 public:
26 typedef base::Callback<void(scoped_ptr<Item>)> ItemDefinedCallback;
27 typedef base::Callback<void(const std::string&)> PrintCallback;
29 BuildSettings();
30 BuildSettings(const BuildSettings& other);
31 ~BuildSettings();
33 // Absolute path of the source root on the local system. Everything is
34 // relative to this. Does not end in a [back]slash.
35 const base::FilePath& root_path() const { return root_path_; }
36 const std::string& root_path_utf8() const { return root_path_utf8_; }
37 void SetRootPath(const base::FilePath& r);
39 // When nonempty, specifies a parallel directory higherarchy in which to
40 // search for buildfiles if they're not found in the root higherarchy. This
41 // allows us to keep buildfiles in a separate tree during development.
42 const base::FilePath& secondary_source_path() const {
43 return secondary_source_path_;
45 void SetSecondarySourcePath(const SourceDir& d);
47 // Path of the python executable to run scripts with.
48 base::FilePath python_path() const { return python_path_; }
49 void set_python_path(const base::FilePath& p) { python_path_ = p; }
51 const SourceFile& build_config_file() const { return build_config_file_; }
52 void set_build_config_file(const SourceFile& f) { build_config_file_ = f; }
54 // The build directory is the root of all output files. The default toolchain
55 // files go into here, and non-default toolchains will have separate
56 // toolchain-specific root directories inside this.
57 const SourceDir& build_dir() const { return build_dir_; }
58 void SetBuildDir(const SourceDir& dir);
60 // The build args are normally specified on the command-line.
61 Args& build_args() { return build_args_; }
62 const Args& build_args() const { return build_args_; }
64 // Returns the full absolute OS path cooresponding to the given file in the
65 // root source tree.
66 base::FilePath GetFullPath(const SourceFile& file) const;
67 base::FilePath GetFullPath(const SourceDir& dir) const;
69 // Returns the absolute OS path inside the secondary source path. Will return
70 // an empty FilePath if the secondary source path is empty. When loading a
71 // buildfile, the GetFullPath should always be consulted first.
72 base::FilePath GetFullPathSecondary(const SourceFile& file) const;
73 base::FilePath GetFullPathSecondary(const SourceDir& dir) const;
75 // Called when an item is defined from a background thread.
76 void ItemDefined(scoped_ptr<Item> item) const;
77 void set_item_defined_callback(ItemDefinedCallback cb) {
78 item_defined_callback_ = cb;
81 // Defines a callback that will be used to override the behavior of the
82 // print function. This is used in tests to collect print output. If the
83 // callback is is_null() (the default) the output will be printed to the
84 // console.
85 const PrintCallback& print_callback() const { return print_callback_; }
86 void set_print_callback(const PrintCallback& cb) { print_callback_ = cb; }
88 // A list of files that can call exec_script(). If the returned pointer is
89 // null, exec_script may be called from anywhere.
90 const std::set<SourceFile>* exec_script_whitelist() const {
91 return exec_script_whitelist_.get();
93 void set_exec_script_whitelist(scoped_ptr<std::set<SourceFile>> list) {
94 exec_script_whitelist_ = list.Pass();
97 // When set (the default), code should perform normal validation of inputs
98 // and structures, like undefined or possibly incorrectly used things. For
99 // some interrogation commands, we don't care about this and actually want
100 // to allow the user to check the structure of the build to solve their
101 // problem, and these checks are undesirable.
102 bool check_for_bad_items() const {
103 return check_for_bad_items_;
105 void set_check_for_bad_items(bool c) {
106 check_for_bad_items_ = c;
109 private:
110 base::FilePath root_path_;
111 std::string root_path_utf8_;
112 base::FilePath secondary_source_path_;
113 base::FilePath python_path_;
115 SourceFile build_config_file_;
116 SourceDir build_dir_;
117 Args build_args_;
119 ItemDefinedCallback item_defined_callback_;
120 PrintCallback print_callback_;
122 scoped_ptr<std::set<SourceFile>> exec_script_whitelist_;
124 bool check_for_bad_items_;
126 BuildSettings& operator=(const BuildSettings& other); // Disallow.
129 #endif // TOOLS_GN_BUILD_SETTINGS_H_