Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Side by Side Diff: tools/gn/build_settings.h

Issue 56433003: GN threading refactor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/gn/binary_target_generator.cc ('k') | tools/gn/build_settings.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
13 #include "base/memory/scoped_ptr.h"
13 #include "tools/gn/args.h" 14 #include "tools/gn/args.h"
14 #include "tools/gn/item_tree.h"
15 #include "tools/gn/scope.h" 15 #include "tools/gn/scope.h"
16 #include "tools/gn/source_dir.h" 16 #include "tools/gn/source_dir.h"
17 #include "tools/gn/source_file.h" 17 #include "tools/gn/source_file.h"
18 #include "tools/gn/target_manager.h"
19 #include "tools/gn/toolchain_manager.h"
20 18
19 class Item;
21 class OutputFile; 20 class OutputFile;
22 21
23 // Settings for one build, which is one toplevel output directory. There 22 // 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. 23 // may be multiple Settings objects that refer to this, one for each toolchain.
25 class BuildSettings { 24 class BuildSettings {
26 public: 25 public:
27 typedef base::Callback<void(const Target*)> TargetResolvedCallback; 26 typedef base::Callback<void(scoped_ptr<Item>)> ItemDefinedCallback;
28 27
29 BuildSettings(); 28 BuildSettings();
30 BuildSettings(const BuildSettings& other); 29 BuildSettings(const BuildSettings& other);
31 ~BuildSettings(); 30 ~BuildSettings();
32 31
33 // Absolute path of the source root on the local system. Everything is 32 // Absolute path of the source root on the local system. Everything is
34 // relative to this. Does not end in a [back]slash. 33 // relative to this. Does not end in a [back]slash.
35 const base::FilePath& root_path() const { return root_path_; } 34 const base::FilePath& root_path() const { return root_path_; }
36 const std::string& root_path_utf8() const { return root_path_utf8_; } 35 const std::string& root_path_utf8() const { return root_path_utf8_; }
37 void SetRootPath(const base::FilePath& r); 36 void SetRootPath(const base::FilePath& r);
38 37
39 // When nonempty, specifies a parallel directory higherarchy in which to 38 // When nonempty, specifies a parallel directory higherarchy in which to
40 // search for buildfiles if they're not found in the root higherarchy. This 39 // 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. 40 // allows us to keep buildfiles in a separate tree during development.
42 const base::FilePath& secondary_source_path() const { 41 const base::FilePath& secondary_source_path() const {
43 return secondary_source_path_; 42 return secondary_source_path_;
44 } 43 }
45 void SetSecondarySourcePath(const SourceDir& d); 44 void SetSecondarySourcePath(const SourceDir& d);
46 45
47 // Set when we're running an external generator (e.g. GYP) and should
48 // enable "external" flags on targets.
49 bool using_external_generator() const { return using_external_generator_; }
50 void set_using_external_generator(bool ueg) {
51 using_external_generator_ = ueg;
52 }
53
54 // Path of the python executable to run scripts with. 46 // Path of the python executable to run scripts with.
55 base::FilePath python_path() const { return python_path_; } 47 base::FilePath python_path() const { return python_path_; }
56 void set_python_path(const base::FilePath& p) { python_path_ = p; } 48 void set_python_path(const base::FilePath& p) { python_path_ = p; }
57 49
58 const SourceFile& build_config_file() const { return build_config_file_; } 50 const SourceFile& build_config_file() const { return build_config_file_; }
59 void set_build_config_file(const SourceFile& f) { build_config_file_ = f; } 51 void set_build_config_file(const SourceFile& f) { build_config_file_ = f; }
60 52
61 // The build directory is the root of all output files. The default toolchain 53 // The build directory is the root of all output files. The default toolchain
62 // files go into here, and non-default toolchains will have separate 54 // files go into here, and non-default toolchains will have separate
63 // toolchain-specific root directories inside this. 55 // toolchain-specific root directories inside this.
64 const SourceDir& build_dir() const { return build_dir_; } 56 const SourceDir& build_dir() const { return build_dir_; }
65 void SetBuildDir(const SourceDir& dir); 57 void SetBuildDir(const SourceDir& dir);
66 58
67 // The inverse of relative_build_dir, ending with a separator. 59 // The inverse of relative_build_dir, ending with a separator.
68 // Example: relative_build_dir_ = "out/Debug/" this will be "../../" 60 // Example: relative_build_dir_ = "out/Debug/" this will be "../../"
69 const std::string& build_to_source_dir_string() const { 61 const std::string& build_to_source_dir_string() const {
70 return build_to_source_dir_string_; 62 return build_to_source_dir_string_;
71 } 63 }
72 64
73 // The build args are normally specified on the command-line. 65 // The build args are normally specified on the command-line.
74 Args& build_args() { return build_args_; } 66 Args& build_args() { return build_args_; }
75 const Args& build_args() const { return build_args_; } 67 const Args& build_args() const { return build_args_; }
76 68
77 // These accessors do not return const objects since the resulting objects
78 // are threadsafe. In this setting, we use constness primarily to ensure
79 // that the Settings object is used in a threadsafe manner. Although this
80 // violates the concept of logical constness, that's less important in our
81 // application, and actually implementing this in a way that preserves
82 // logical constness is cumbersome.
83 ItemTree& item_tree() const { return item_tree_; }
84 TargetManager& target_manager() const { return target_manager_; }
85 ToolchainManager& toolchain_manager() const { return toolchain_manager_; }
86
87 // Returns the full absolute OS path cooresponding to the given file in the 69 // Returns the full absolute OS path cooresponding to the given file in the
88 // root source tree. 70 // root source tree.
89 base::FilePath GetFullPath(const SourceFile& file) const; 71 base::FilePath GetFullPath(const SourceFile& file) const;
90 base::FilePath GetFullPath(const SourceDir& dir) const; 72 base::FilePath GetFullPath(const SourceDir& dir) const;
91 73
92 // Returns the absolute OS path inside the secondary source path. Will return 74 // Returns the absolute OS path inside the secondary source path. Will return
93 // an empty FilePath if the secondary source path is empty. When loading a 75 // an empty FilePath if the secondary source path is empty. When loading a
94 // buildfile, the GetFullPath should always be consulted first. 76 // buildfile, the GetFullPath should always be consulted first.
95 base::FilePath GetFullPathSecondary(const SourceFile& file) const; 77 base::FilePath GetFullPathSecondary(const SourceFile& file) const;
96 base::FilePath GetFullPathSecondary(const SourceDir& dir) const; 78 base::FilePath GetFullPathSecondary(const SourceDir& dir) const;
97 79
98 // This is the callback to execute when a target is marked resolved. If we 80 // Called when an item is defined from a background thread.
99 // don't need to do anything, this will be null. When a target is resolved, 81 void ItemDefined(scoped_ptr<Item> item) const;
100 // this callback should be posted to the scheduler pool so the work is 82 void set_item_defined_callback(ItemDefinedCallback cb) {
101 // distributed properly. 83 item_defined_callback_ = cb;
102 const TargetResolvedCallback& target_resolved_callback() const {
103 return target_resolved_callback_;
104 }
105 void set_target_resolved_callback(const TargetResolvedCallback& cb) {
106 target_resolved_callback_ = cb;
107 } 84 }
108 85
109 private: 86 private:
110 base::FilePath root_path_; 87 base::FilePath root_path_;
111 std::string root_path_utf8_; 88 std::string root_path_utf8_;
112 base::FilePath secondary_source_path_; 89 base::FilePath secondary_source_path_;
113 bool using_external_generator_;
114 base::FilePath python_path_; 90 base::FilePath python_path_;
115 91
116 SourceFile build_config_file_; 92 SourceFile build_config_file_;
117 SourceDir build_dir_; 93 SourceDir build_dir_;
118 std::string build_to_source_dir_string_; 94 std::string build_to_source_dir_string_;
119 Args build_args_; 95 Args build_args_;
120 96
121 TargetResolvedCallback target_resolved_callback_; 97 ItemDefinedCallback item_defined_callback_;
122
123 // See getters above.
124 mutable ItemTree item_tree_;
125 mutable TargetManager target_manager_;
126 mutable ToolchainManager toolchain_manager_;
127 98
128 BuildSettings& operator=(const BuildSettings& other); // Disallow. 99 BuildSettings& operator=(const BuildSettings& other); // Disallow.
129 }; 100 };
130 101
131 #endif // TOOLS_GN_BUILD_SETTINGS_H_ 102 #endif // TOOLS_GN_BUILD_SETTINGS_H_
OLDNEW
« no previous file with comments | « tools/gn/binary_target_generator.cc ('k') | tools/gn/build_settings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698