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_CONFIG_VALUES_H_ 6 #define TOOLS_GN_CONFIG_VALUES_H_ 7 8 #include <string> 9 #include <vector> 10 11 #include "gn/lib_file.h" 12 #include "gn/source_dir.h" 13 #include "gn/source_file.h" 14 15 // Holds the values (include_dirs, defines, compiler flags, etc.) for a given 16 // config or target. 17 class ConfigValues { 18 public: 19 ConfigValues(); 20 ~ConfigValues(); 21 22 // Appends the values from the given config to this one. 23 void AppendValues(const ConfigValues& append); 24 25 #define STRING_VALUES_ACCESSOR(name) \ 26 const std::vector<std::string>& name() const { return name##_; } \ 27 std::vector<std::string>& name() { return name##_; } 28 #define DIR_VALUES_ACCESSOR(name) \ 29 const std::vector<SourceDir>& name() const { return name##_; } \ 30 std::vector<SourceDir>& name() { return name##_; } 31 32 // ================================================================= 33 // IMPORTANT: If you add a new one, be sure to update AppendValues() 34 // and command_desc.cc. 35 // ================================================================= 36 STRING_VALUES_ACCESSOR(arflags) STRING_VALUES_ACCESSOR(asmflags)37 STRING_VALUES_ACCESSOR(asmflags) 38 STRING_VALUES_ACCESSOR(cflags) 39 STRING_VALUES_ACCESSOR(cflags_c) 40 STRING_VALUES_ACCESSOR(cflags_cc) 41 STRING_VALUES_ACCESSOR(cflags_objc) 42 STRING_VALUES_ACCESSOR(cflags_objcc) 43 STRING_VALUES_ACCESSOR(defines) 44 DIR_VALUES_ACCESSOR(framework_dirs) 45 STRING_VALUES_ACCESSOR(frameworks) 46 STRING_VALUES_ACCESSOR(weak_frameworks) 47 DIR_VALUES_ACCESSOR(include_dirs) 48 STRING_VALUES_ACCESSOR(ldflags) 49 DIR_VALUES_ACCESSOR(lib_dirs) 50 STRING_VALUES_ACCESSOR(rustflags) 51 STRING_VALUES_ACCESSOR(rustenv) 52 STRING_VALUES_ACCESSOR(swiftflags) 53 // ================================================================= 54 // IMPORTANT: If you add a new one, be sure to update AppendValues() 55 // and command_desc.cc. 56 // ================================================================= 57 58 #undef STRING_VALUES_ACCESSOR 59 #undef DIR_VALUES_ACCESSOR 60 61 const std::vector<SourceFile>& inputs() const { return inputs_; } inputs()62 std::vector<SourceFile>& inputs() { return inputs_; } 63 libs()64 const std::vector<LibFile>& libs() const { return libs_; } libs()65 std::vector<LibFile>& libs() { return libs_; } 66 externs()67 const std::vector<std::pair<std::string, LibFile>>& externs() const { 68 return externs_; 69 } externs()70 std::vector<std::pair<std::string, LibFile>>& externs() { return externs_; } 71 has_precompiled_headers()72 bool has_precompiled_headers() const { 73 return !precompiled_header_.empty() || !precompiled_source_.is_null(); 74 } precompiled_header()75 const std::string& precompiled_header() const { return precompiled_header_; } set_precompiled_header(const std::string & f)76 void set_precompiled_header(const std::string& f) { precompiled_header_ = f; } precompiled_source()77 const SourceFile& precompiled_source() const { return precompiled_source_; } set_precompiled_source(const SourceFile & f)78 void set_precompiled_source(const SourceFile& f) { precompiled_source_ = f; } 79 80 private: 81 std::vector<std::string> arflags_; 82 std::vector<std::string> asmflags_; 83 std::vector<std::string> cflags_; 84 std::vector<std::string> cflags_c_; 85 std::vector<std::string> cflags_cc_; 86 std::vector<std::string> cflags_objc_; 87 std::vector<std::string> cflags_objcc_; 88 std::vector<std::string> defines_; 89 std::vector<SourceDir> include_dirs_; 90 std::vector<SourceDir> framework_dirs_; 91 std::vector<std::string> frameworks_; 92 std::vector<std::string> weak_frameworks_; 93 std::vector<SourceFile> inputs_; 94 std::vector<std::string> ldflags_; 95 std::vector<SourceDir> lib_dirs_; 96 std::vector<LibFile> libs_; 97 std::vector<std::string> rustflags_; 98 std::vector<std::string> rustenv_; 99 std::vector<std::string> swiftflags_; 100 std::vector<std::pair<std::string, LibFile>> externs_; 101 // If you add a new one, be sure to update AppendValues(). 102 103 std::string precompiled_header_; 104 SourceFile precompiled_source_; 105 }; 106 107 #endif // TOOLS_GN_CONFIG_VALUES_H_ 108