| 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_SETTINGS_H_ | 5 #ifndef TOOLS_GN_SETTINGS_H_ |
| 6 #define TOOLS_GN_SETTINGS_H_ | 6 #define TOOLS_GN_SETTINGS_H_ |
| 7 | 7 |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "tools/gn/build_settings.h" | 9 #include "tools/gn/build_settings.h" |
| 10 #include "tools/gn/import_manager.h" | 10 #include "tools/gn/import_manager.h" |
| 11 #include "tools/gn/output_file.h" | 11 #include "tools/gn/output_file.h" |
| 12 #include "tools/gn/scope.h" | 12 #include "tools/gn/scope.h" |
| 13 #include "tools/gn/source_dir.h" | 13 #include "tools/gn/source_dir.h" |
| 14 #include "tools/gn/toolchain.h" | 14 #include "tools/gn/toolchain.h" |
| 15 | 15 |
| 16 // Holds the settings for one toolchain invocation. There will be one | 16 // Holds the settings for one toolchain invocation. There will be one |
| 17 // Settings object for each toolchain type, each referring to the same | 17 // Settings object for each toolchain type, each referring to the same |
| 18 // BuildSettings object for shared stuff. | 18 // BuildSettings object for shared stuff. |
| 19 // | 19 // |
| 20 // The Settings object is const once it is constructed, which allows us to | 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 | 21 // use it from multiple threads during target generation without locking (which |
| 22 // is important, because it gets used a lot). | 22 // is important, because it gets used a lot). |
| 23 // | 23 // |
| 24 // The Toolchain object holds the set of stuff that is set by the toolchain | 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 | 25 // declaration, which obviously needs to be set later when we actually parse |
| 26 // the file with the toolchain declaration in it. | 26 // the file with the toolchain declaration in it. |
| 27 class Settings { | 27 class Settings { |
| 28 public: | 28 public: |
| 29 enum TargetOS { | |
| 30 UNKNOWN, | |
| 31 LINUX, | |
| 32 MAC, | |
| 33 WIN | |
| 34 }; | |
| 35 | |
| 36 // Constructs a toolchain settings. | 29 // Constructs a toolchain settings. |
| 37 // | 30 // |
| 38 // The output_subdir_name is the name we should use for the subdirectory in | 31 // 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 | 32 // 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). | 33 // toolchain would use an empty string (it goes in the root build dir). |
| 41 // Otherwise, it must end in a slash. | 34 // Otherwise, it must end in a slash. |
| 42 Settings(const BuildSettings* build_settings, | 35 Settings(const BuildSettings* build_settings, |
| 43 const std::string& output_subdir_name); | 36 const std::string& output_subdir_name); |
| 44 ~Settings(); | 37 ~Settings(); |
| 45 | 38 |
| 46 const BuildSettings* build_settings() const { return build_settings_; } | 39 const BuildSettings* build_settings() const { return build_settings_; } |
| 47 | 40 |
| 48 const Label& toolchain_label() const { return toolchain_label_; } | 41 const Label& toolchain_label() const { return toolchain_label_; } |
| 49 void set_toolchain_label(const Label& l) { toolchain_label_ = l; } | 42 void set_toolchain_label(const Label& l) { toolchain_label_ = l; } |
| 50 | 43 |
| 51 const Label& default_toolchain_label() const { | 44 const Label& default_toolchain_label() const { |
| 52 return default_toolchain_label_; | 45 return default_toolchain_label_; |
| 53 } | 46 } |
| 54 void set_default_toolchain_label(const Label& default_label) { | 47 void set_default_toolchain_label(const Label& default_label) { |
| 55 default_toolchain_label_ = default_label; | 48 default_toolchain_label_ = default_label; |
| 56 } | 49 } |
| 57 | 50 |
| 58 // Indicates if this corresponds to the default toolchain. | 51 // Indicates if this corresponds to the default toolchain. |
| 59 bool is_default() const { | 52 bool is_default() const { |
| 60 return toolchain_label_ == default_toolchain_label_; | 53 return toolchain_label_ == default_toolchain_label_; |
| 61 } | 54 } |
| 62 | 55 |
| 63 bool IsMac() const { return target_os_ == MAC; } | |
| 64 bool IsLinux() const { return target_os_ == LINUX; } | |
| 65 bool IsWin() const { return target_os_ == WIN; } | |
| 66 | |
| 67 TargetOS target_os() const { return target_os_; } | |
| 68 void set_target_os(TargetOS t) { target_os_ = t; } | |
| 69 | |
| 70 const OutputFile& toolchain_output_subdir() const { | 56 const OutputFile& toolchain_output_subdir() const { |
| 71 return toolchain_output_subdir_; | 57 return toolchain_output_subdir_; |
| 72 } | 58 } |
| 73 const SourceDir& toolchain_output_dir() const { | 59 const SourceDir& toolchain_output_dir() const { |
| 74 return toolchain_output_dir_; | 60 return toolchain_output_dir_; |
| 75 } | 61 } |
| 76 | 62 |
| 77 // Directory for generated files. | 63 // Directory for generated files. |
| 78 const SourceDir& toolchain_gen_dir() const { | 64 const SourceDir& toolchain_gen_dir() const { |
| 79 return toolchain_gen_dir_; | 65 return toolchain_gen_dir_; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 99 void set_greedy_target_generation(bool gtg) { | 85 void set_greedy_target_generation(bool gtg) { |
| 100 greedy_target_generation_ = gtg; | 86 greedy_target_generation_ = gtg; |
| 101 } | 87 } |
| 102 | 88 |
| 103 private: | 89 private: |
| 104 const BuildSettings* build_settings_; | 90 const BuildSettings* build_settings_; |
| 105 | 91 |
| 106 Label toolchain_label_; | 92 Label toolchain_label_; |
| 107 Label default_toolchain_label_; | 93 Label default_toolchain_label_; |
| 108 | 94 |
| 109 TargetOS target_os_; | |
| 110 | |
| 111 mutable ImportManager import_manager_; | 95 mutable ImportManager import_manager_; |
| 112 | 96 |
| 113 // The subdirectory inside the build output for this toolchain. For the | 97 // The subdirectory inside the build output for this toolchain. For the |
| 114 // default toolchain, this will be empty (since the deafult toolchain's | 98 // default toolchain, this will be empty (since the deafult toolchain's |
| 115 // output directory is the same as the build directory). When nonempty, this | 99 // output directory is the same as the build directory). When nonempty, this |
| 116 // is guaranteed to end in a slash. | 100 // is guaranteed to end in a slash. |
| 117 OutputFile toolchain_output_subdir_; | 101 OutputFile toolchain_output_subdir_; |
| 118 | 102 |
| 119 // Full source file path to the toolchain output directory. | 103 // Full source file path to the toolchain output directory. |
| 120 SourceDir toolchain_output_dir_; | 104 SourceDir toolchain_output_dir_; |
| 121 | 105 |
| 122 SourceDir toolchain_gen_dir_; | 106 SourceDir toolchain_gen_dir_; |
| 123 | 107 |
| 124 Scope base_config_; | 108 Scope base_config_; |
| 125 | 109 |
| 126 bool greedy_target_generation_; | 110 bool greedy_target_generation_; |
| 127 | 111 |
| 128 DISALLOW_COPY_AND_ASSIGN(Settings); | 112 DISALLOW_COPY_AND_ASSIGN(Settings); |
| 129 }; | 113 }; |
| 130 | 114 |
| 131 #endif // TOOLS_GN_SETTINGS_H_ | 115 #endif // TOOLS_GN_SETTINGS_H_ |
| OLD | NEW |