Roll src/third_party/WebKit f36d5e0:68b67cd (svn 193299:193303)
[chromium-blink-merge.git] / tools / gn / settings.h
blobe66a13f6a35736bfd2383766e8dc5259391318b1
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_SETTINGS_H_
6 #define TOOLS_GN_SETTINGS_H_
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"
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.
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).
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
36 // Constructs a toolchain settings.
38 // The output_subdir_name is the name we should use for the subdirectory in
39 // the build output directory for this toolchain's outputs. The default
40 // toolchain would use an empty string (it goes in the root build dir).
41 // Otherwise, it must end in a slash.
42 Settings(const BuildSettings* build_settings,
43 const std::string& output_subdir_name);
44 ~Settings();
46 const BuildSettings* build_settings() const { return build_settings_; }
48 const Label& toolchain_label() const { return toolchain_label_; }
49 void set_toolchain_label(const Label& l) { toolchain_label_ = l; }
51 const Label& default_toolchain_label() const {
52 return default_toolchain_label_;
54 void set_default_toolchain_label(const Label& default_label) {
55 default_toolchain_label_ = default_label;
58 // Indicates if this corresponds to the default toolchain.
59 bool is_default() const {
60 return toolchain_label_ == default_toolchain_label_;
63 bool IsMac() const { return target_os_ == MAC; }
64 bool IsLinux() const { return target_os_ == LINUX; }
65 bool IsWin() const { return target_os_ == WIN; }
67 TargetOS target_os() const { return target_os_; }
68 void set_target_os(TargetOS t) { target_os_ = t; }
70 const OutputFile& toolchain_output_subdir() const {
71 return toolchain_output_subdir_;
73 const SourceDir& toolchain_output_dir() const {
74 return toolchain_output_dir_;
77 // Directory for generated files.
78 const SourceDir& toolchain_gen_dir() const {
79 return toolchain_gen_dir_;
82 // The import manager caches the result of executing imported files in the
83 // context of a given settings object.
85 // See the ItemTree getter in GlobalSettings for why this doesn't return a
86 // const pointer.
87 ImportManager& import_manager() const { return import_manager_; }
89 const Scope* base_config() const { return &base_config_; }
90 Scope* base_config() { return &base_config_; }
92 // Set to true when every target we encounter should be generated. False
93 // means that only targets that have a dependency from (directly or
94 // indirectly) some magic root node are actually generated. See the comments
95 // on ItemTree for more.
96 bool greedy_target_generation() const {
97 return greedy_target_generation_;
99 void set_greedy_target_generation(bool gtg) {
100 greedy_target_generation_ = gtg;
103 private:
104 const BuildSettings* build_settings_;
106 Label toolchain_label_;
107 Label default_toolchain_label_;
109 TargetOS target_os_;
111 mutable ImportManager import_manager_;
113 // The subdirectory inside the build output for this toolchain. For the
114 // default toolchain, this will be empty (since the deafult toolchain's
115 // output directory is the same as the build directory). When nonempty, this
116 // is guaranteed to end in a slash.
117 OutputFile toolchain_output_subdir_;
119 // Full source file path to the toolchain output directory.
120 SourceDir toolchain_output_dir_;
122 SourceDir toolchain_gen_dir_;
124 Scope base_config_;
126 bool greedy_target_generation_;
128 DISALLOW_COPY_AND_ASSIGN(Settings);
131 #endif // TOOLS_GN_SETTINGS_H_