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