• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2016 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_ECLIPSE_WRITER_H_
6 #define TOOLS_GN_ECLIPSE_WRITER_H_
7 
8 #include <iosfwd>
9 #include <map>
10 #include <set>
11 #include <string>
12 #include <vector>
13 
14 class BuildSettings;
15 class Builder;
16 class Err;
17 class Target;
18 
19 class EclipseWriter {
20  public:
21   static bool RunAndWriteFile(const BuildSettings* build_settings,
22                               const Builder& builder,
23                               Err* err);
24 
25  private:
26   EclipseWriter(const BuildSettings* build_settings,
27                 const Builder& builder,
28                 std::ostream& out);
29   ~EclipseWriter();
30 
31   void Run();
32 
33   // Populates |include_dirs_| with the include dirs of all the targets for the
34   // default toolchain.
35   void GetAllIncludeDirs();
36 
37   // Populates |defines_| with the defines of all the targets for the default
38   // toolchain.
39   void GetAllDefines();
40 
41   // Returns true if |target| uses the default toolchain.
42   bool UsesDefaultToolchain(const Target* target) const;
43 
44   // Writes the XML settings file.
45   void WriteCDTSettings();
46 
47   const BuildSettings* build_settings_;
48   const Builder& builder_;
49 
50   // The output stream for the settings file.
51   std::ostream& out_;
52 
53   // Eclipse languages for which the include dirs and defines apply.
54   std::vector<std::string> languages_;
55 
56   // The include dirs of all the targets which use the default toolchain.
57   std::set<std::string> include_dirs_;
58 
59   // The defines of all the targets which use the default toolchain.
60   std::map<std::string, std::string> defines_;
61 
62   EclipseWriter(const EclipseWriter&) = delete;
63   EclipseWriter& operator=(const EclipseWriter&) = delete;
64 };
65 
66 #endif  // TOOLS_GN_ECLIPSE_WRITER_H_
67