1 // Copyright (c) 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_QT_CREATOR_WRITER_H_
6 #define TOOLS_GN_QT_CREATOR_WRITER_H_
7 
8 #include <set>
9 #include <string>
10 
11 #include "base/files/file_path.h"
12 #include "base/macros.h"
13 #include "tools/gn/err.h"
14 #include "tools/gn/target.h"
15 
16 class Builder;
17 class BuildSettings;
18 
19 class QtCreatorWriter {
20  public:
21   static bool RunAndWriteFile(const BuildSettings* build_settings,
22                               const Builder& builder,
23                               Err* err,
24                               const std::string& root_target);
25 
26  private:
27   QtCreatorWriter(const BuildSettings* build_settings,
28                   const Builder& builder,
29                   const base::FilePath& project_prefix,
30                   const std::string& root_target_name);
31   ~QtCreatorWriter();
32 
33   void Run();
34 
35   bool DiscoverTargets();
36   void HandleTarget(const Target* target);
37 
38   void CollectDeps(const Target* target);
39   void AddToSources(const Target::FileList& files);
40   void GenerateFile(const base::FilePath::CharType* suffix,
41                     const std::set<std::string>& items);
42 
43   const BuildSettings* build_settings_;
44   const Builder& builder_;
45   base::FilePath project_prefix_;
46   std::string root_target_name_;
47   std::set<const Target*> targets_;
48   std::set<std::string> sources_;
49   std::set<std::string> includes_;
50   std::set<std::string> defines_;
51   Err err_;
52 
53   DISALLOW_COPY_AND_ASSIGN(QtCreatorWriter);
54 };
55 
56 #endif  // TOOLS_GN_QT_CREATOR_WRITER_H_
57