OLD | NEW |
| (Empty) |
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_SETTINGS_H_ | |
6 #define TOOLS_GN_SETTINGS_H_ | |
7 | |
8 #include "base/files/file_path.h" | |
9 #include "tools/gn/build_settings.h" | |
10 #include "tools/gn/import_manager.h" | |
11 #include "tools/gn/output_file.h" | |
12 #include "tools/gn/scope.h" | |
13 #include "tools/gn/source_dir.h" | |
14 #include "tools/gn/toolchain.h" | |
15 | |
16 // Holds the settings for one toolchain invocation. There will be one | |
17 // Settings object for each toolchain type, each referring to the same | |
18 // BuildSettings object for shared stuff. | |
19 // | |
20 // The Settings object is const once it is constructed, which allows us to | |
21 // use it from multiple threads during target generation without locking (which | |
22 // is important, because it gets used a lot). | |
23 // | |
24 // The Toolchain object holds the set of stuff that is set by the toolchain | |
25 // declaration, which obviously needs to be set later when we actually parse | |
26 // the file with the toolchain declaration in it. | |
27 class Settings { | |
28 public: | |
29 enum TargetOS { | |
30 UNKNOWN, | |
31 LINUX, | |
32 MAC, | |
33 WIN | |
34 }; | |
35 | |
36 // Constructs a toolchain settings. The output_subdir_name is the name we | |
37 // should use for the subdirectory in the build output directory for this | |
38 // toolchain's outputs. It should have no slashes in it. The default | |
39 // toolchain should use an empty string. | |
40 Settings(const BuildSettings* build_settings, | |
41 const Toolchain* toolchain, | |
42 const std::string& output_subdir_name); | |
43 ~Settings(); | |
44 | |
45 const BuildSettings* build_settings() const { return build_settings_; } | |
46 | |
47 // Danger: this must only be used for getting the toolchain label until the | |
48 // toolchain has been resolved. Otherwise, it will be modified on an | |
49 // arbitrary thread when the toolchain invocation is found. Generally, you | |
50 // will only read this from the target generation where we know everything | |
51 // has been resolved and won't change. | |
52 const Toolchain* toolchain() const { return toolchain_; } | |
53 | |
54 bool IsMac() const { return target_os_ == MAC; } | |
55 bool IsWin() const { return target_os_ == WIN; } | |
56 | |
57 TargetOS target_os() const { return target_os_; } | |
58 void set_target_os(TargetOS t) { target_os_ = t; } | |
59 | |
60 const OutputFile& toolchain_output_subdir() const { | |
61 return toolchain_output_subdir_; | |
62 } | |
63 const SourceDir& toolchain_output_dir() const { | |
64 return toolchain_output_dir_; | |
65 } | |
66 | |
67 // Directory for generated files. | |
68 const SourceDir& toolchain_gen_dir() const { | |
69 return toolchain_gen_dir_; | |
70 } | |
71 | |
72 // The import manager caches the result of executing imported files in the | |
73 // context of a given settings object. | |
74 // | |
75 // See the ItemTree getter in GlobalSettings for why this doesn't return a | |
76 // const pointer. | |
77 ImportManager& import_manager() const { return import_manager_; } | |
78 | |
79 const Scope* base_config() const { return &base_config_; } | |
80 Scope* base_config() { return &base_config_; } | |
81 | |
82 private: | |
83 const BuildSettings* build_settings_; | |
84 | |
85 const Toolchain* toolchain_; | |
86 | |
87 TargetOS target_os_; | |
88 | |
89 mutable ImportManager import_manager_; | |
90 | |
91 // The subdirectory inside the build output for this toolchain. For the | |
92 // default toolchain, this will be empty (since the deafult toolchain's | |
93 // output directory is the same as the build directory). When nonempty, this | |
94 // is guaranteed to end in a slash. | |
95 OutputFile toolchain_output_subdir_; | |
96 | |
97 // Full source file path to the toolchain output directory. | |
98 SourceDir toolchain_output_dir_; | |
99 | |
100 SourceDir toolchain_gen_dir_; | |
101 | |
102 Scope base_config_; | |
103 | |
104 DISALLOW_COPY_AND_ASSIGN(Settings); | |
105 }; | |
106 | |
107 #endif // TOOLS_GN_SETTINGS_H_ | |
OLD | NEW |