summaryrefslogtreecommitdiff
path: root/chromium/tools/gn/eclipse_writer.h
blob: e15254fbadbbb36e1e0e177eb8904aa82cc68edf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef TOOLS_GN_ECLIPSE_WRITER_H_
#define TOOLS_GN_ECLIPSE_WRITER_H_

#include <iosfwd>
#include <map>
#include <set>
#include <string>
#include <vector>

#include "base/macros.h"

class BuildSettings;
class Builder;
class Err;
class Target;

class EclipseWriter {
 public:
  static bool RunAndWriteFile(const BuildSettings* build_settings,
                              const Builder& builder,
                              Err* err);

 private:
  EclipseWriter(const BuildSettings* build_settings,
                const Builder& builder,
                std::ostream& out);
  ~EclipseWriter();

  void Run();

  // Populates |include_dirs_| with the include dirs of all the targets for the
  // default toolchain.
  void GetAllIncludeDirs();

  // Populates |defines_| with the defines of all the targets for the default
  // toolchain.
  void GetAllDefines();

  // Returns true if |target| uses the default toolchain.
  bool UsesDefaultToolchain(const Target* target) const;

  // Writes the XML settings file.
  void WriteCDTSettings();

  const BuildSettings* build_settings_;
  const Builder& builder_;

  // The output stream for the settings file.
  std::ostream& out_;

  // Eclipse languages for which the include dirs and defines apply.
  std::vector<std::string> languages_;

  // The include dirs of all the targets which use the default toolchain.
  std::set<std::string> include_dirs_;

  // The defines of all the targets which use the default toolchain.
  std::map<std::string, std::string> defines_;

  DISALLOW_COPY_AND_ASSIGN(EclipseWriter);
};

#endif  // TOOLS_GN_ECLIPSE_WRITER_H_