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_BUILD_SETTINGS_H_ | 5 #ifndef TOOLS_GN_BUILD_SETTINGS_H_ |
6 #define TOOLS_GN_BUILD_SETTINGS_H_ | 6 #define TOOLS_GN_BUILD_SETTINGS_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
| 9 #include <memory> |
9 #include <set> | 10 #include <set> |
10 #include <utility> | 11 #include <utility> |
11 | 12 |
12 #include "base/callback.h" | 13 #include "base/callback.h" |
13 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
14 #include "base/macros.h" | 15 #include "base/macros.h" |
15 #include "base/memory/scoped_ptr.h" | |
16 #include "tools/gn/args.h" | 16 #include "tools/gn/args.h" |
17 #include "tools/gn/scope.h" | 17 #include "tools/gn/scope.h" |
18 #include "tools/gn/source_dir.h" | 18 #include "tools/gn/source_dir.h" |
19 #include "tools/gn/source_file.h" | 19 #include "tools/gn/source_file.h" |
20 | 20 |
21 class Item; | 21 class Item; |
22 | 22 |
23 // Settings for one build, which is one toplevel output directory. There | 23 // Settings for one build, which is one toplevel output directory. There |
24 // may be multiple Settings objects that refer to this, one for each toolchain. | 24 // may be multiple Settings objects that refer to this, one for each toolchain. |
25 class BuildSettings { | 25 class BuildSettings { |
26 public: | 26 public: |
27 typedef base::Callback<void(scoped_ptr<Item>)> ItemDefinedCallback; | 27 typedef base::Callback<void(std::unique_ptr<Item>)> ItemDefinedCallback; |
28 typedef base::Callback<void(const std::string&)> PrintCallback; | 28 typedef base::Callback<void(const std::string&)> PrintCallback; |
29 | 29 |
30 BuildSettings(); | 30 BuildSettings(); |
31 BuildSettings(const BuildSettings& other); | 31 BuildSettings(const BuildSettings& other); |
32 ~BuildSettings(); | 32 ~BuildSettings(); |
33 | 33 |
34 // Absolute path of the source root on the local system. Everything is | 34 // Absolute path of the source root on the local system. Everything is |
35 // relative to this. Does not end in a [back]slash. | 35 // relative to this. Does not end in a [back]slash. |
36 const base::FilePath& root_path() const { return root_path_; } | 36 const base::FilePath& root_path() const { return root_path_; } |
37 const std::string& root_path_utf8() const { return root_path_utf8_; } | 37 const std::string& root_path_utf8() const { return root_path_utf8_; } |
(...skipping 29 matching lines...) Expand all Loading... |
67 base::FilePath GetFullPath(const SourceFile& file) const; | 67 base::FilePath GetFullPath(const SourceFile& file) const; |
68 base::FilePath GetFullPath(const SourceDir& dir) const; | 68 base::FilePath GetFullPath(const SourceDir& dir) const; |
69 | 69 |
70 // Returns the absolute OS path inside the secondary source path. Will return | 70 // Returns the absolute OS path inside the secondary source path. Will return |
71 // an empty FilePath if the secondary source path is empty. When loading a | 71 // an empty FilePath if the secondary source path is empty. When loading a |
72 // buildfile, the GetFullPath should always be consulted first. | 72 // buildfile, the GetFullPath should always be consulted first. |
73 base::FilePath GetFullPathSecondary(const SourceFile& file) const; | 73 base::FilePath GetFullPathSecondary(const SourceFile& file) const; |
74 base::FilePath GetFullPathSecondary(const SourceDir& dir) const; | 74 base::FilePath GetFullPathSecondary(const SourceDir& dir) const; |
75 | 75 |
76 // Called when an item is defined from a background thread. | 76 // Called when an item is defined from a background thread. |
77 void ItemDefined(scoped_ptr<Item> item) const; | 77 void ItemDefined(std::unique_ptr<Item> item) const; |
78 void set_item_defined_callback(ItemDefinedCallback cb) { | 78 void set_item_defined_callback(ItemDefinedCallback cb) { |
79 item_defined_callback_ = cb; | 79 item_defined_callback_ = cb; |
80 } | 80 } |
81 | 81 |
82 // Defines a callback that will be used to override the behavior of the | 82 // Defines a callback that will be used to override the behavior of the |
83 // print function. This is used in tests to collect print output. If the | 83 // print function. This is used in tests to collect print output. If the |
84 // callback is is_null() (the default) the output will be printed to the | 84 // callback is is_null() (the default) the output will be printed to the |
85 // console. | 85 // console. |
86 const PrintCallback& print_callback() const { return print_callback_; } | 86 const PrintCallback& print_callback() const { return print_callback_; } |
87 void set_print_callback(const PrintCallback& cb) { print_callback_ = cb; } | 87 void set_print_callback(const PrintCallback& cb) { print_callback_ = cb; } |
88 | 88 |
89 // A list of files that can call exec_script(). If the returned pointer is | 89 // A list of files that can call exec_script(). If the returned pointer is |
90 // null, exec_script may be called from anywhere. | 90 // null, exec_script may be called from anywhere. |
91 const std::set<SourceFile>* exec_script_whitelist() const { | 91 const std::set<SourceFile>* exec_script_whitelist() const { |
92 return exec_script_whitelist_.get(); | 92 return exec_script_whitelist_.get(); |
93 } | 93 } |
94 void set_exec_script_whitelist(scoped_ptr<std::set<SourceFile>> list) { | 94 void set_exec_script_whitelist(std::unique_ptr<std::set<SourceFile>> list) { |
95 exec_script_whitelist_ = std::move(list); | 95 exec_script_whitelist_ = std::move(list); |
96 } | 96 } |
97 | 97 |
98 // When set (the default), code should perform normal validation of inputs | 98 // When set (the default), code should perform normal validation of inputs |
99 // and structures, like undefined or possibly incorrectly used things. For | 99 // and structures, like undefined or possibly incorrectly used things. For |
100 // some interrogation commands, we don't care about this and actually want | 100 // some interrogation commands, we don't care about this and actually want |
101 // to allow the user to check the structure of the build to solve their | 101 // to allow the user to check the structure of the build to solve their |
102 // problem, and these checks are undesirable. | 102 // problem, and these checks are undesirable. |
103 bool check_for_bad_items() const { | 103 bool check_for_bad_items() const { |
104 return check_for_bad_items_; | 104 return check_for_bad_items_; |
105 } | 105 } |
106 void set_check_for_bad_items(bool c) { | 106 void set_check_for_bad_items(bool c) { |
107 check_for_bad_items_ = c; | 107 check_for_bad_items_ = c; |
108 } | 108 } |
109 | 109 |
110 private: | 110 private: |
111 base::FilePath root_path_; | 111 base::FilePath root_path_; |
112 std::string root_path_utf8_; | 112 std::string root_path_utf8_; |
113 base::FilePath secondary_source_path_; | 113 base::FilePath secondary_source_path_; |
114 base::FilePath python_path_; | 114 base::FilePath python_path_; |
115 | 115 |
116 SourceFile build_config_file_; | 116 SourceFile build_config_file_; |
117 SourceDir build_dir_; | 117 SourceDir build_dir_; |
118 Args build_args_; | 118 Args build_args_; |
119 | 119 |
120 ItemDefinedCallback item_defined_callback_; | 120 ItemDefinedCallback item_defined_callback_; |
121 PrintCallback print_callback_; | 121 PrintCallback print_callback_; |
122 | 122 |
123 scoped_ptr<std::set<SourceFile>> exec_script_whitelist_; | 123 std::unique_ptr<std::set<SourceFile>> exec_script_whitelist_; |
124 | 124 |
125 bool check_for_bad_items_; | 125 bool check_for_bad_items_; |
126 | 126 |
127 BuildSettings& operator=(const BuildSettings& other); // Disallow. | 127 BuildSettings& operator=(const BuildSettings& other); // Disallow. |
128 }; | 128 }; |
129 | 129 |
130 #endif // TOOLS_GN_BUILD_SETTINGS_H_ | 130 #endif // TOOLS_GN_BUILD_SETTINGS_H_ |
OLD | NEW |