Logo ROOT  
Reference Guide
TModuleGenerator.h
Go to the documentation of this file.
1 // @(#)root/utils:$Id$
2 // Author: Axel Naumann, 2-13-07-02
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2013, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 ////////////////////////////////////////////////////////////////////////////////
13 //
14 // PCM writer.
15 //
16 ////////////////////////////////////////////////////////////////////////////////
17 
18 #ifndef ROOT_TModuleGenerator
19 #define ROOT_TModuleGenerator
20 
21 #include <ostream>
22 #include <sstream>
23 #include <fstream>
24 #include <string>
25 #include <vector>
26 
27 namespace clang {
28  class CompilerInstance;
29  class SourceManager;
30 }
31 
32 namespace ROOT {
33 
34 //______________________________________________________________________________
36  public:
42  };
43 
44  TModuleGenerator(clang::CompilerInstance *CI,
45  bool inlineHeader,
46  const std::string &shLibFileName,
47  bool isInPCH);
49 
50  // FIXME: remove once PCH is gone.
51  bool IsPCH() const {
52  return fIsPCH;
53  }
54  void ParseArgs(const std::vector<std::string> &args);
55 
56  const std::string &GetDictionaryName() const {
57  return fDictionaryName;
58  }
59 
60  const std::string &GetDemangledDictionaryName() const {
62  }
63 
64  const std::string &GetModuleFileName() const {
65  return fModuleFileName;
66  }
67  const std::string &GetModuleDirName() const {
68  return fModuleDirName;
69  }
70 
71  int GetErrorCount() const {
72  return fErrorCount;
73  }
74 
75  const std::string &GetUmbrellaName() const {
76  return fUmbrellaName;
77  }
78  const std::string &GetContentName() const {
79  return fContentName;
80  }
81 
82  const std::vector<std::string> &GetHeaders() const {
83  return fHeaders;
84  }
85 
86  const std::vector<std::string> &GetIncludePaths() const {
87  return fCompI;
88  }
89 
90  std::ostream &WritePPDefines(std::ostream &out) const;
91  std::ostream &WritePPUndefines(std::ostream &out) const;
92 
93  void WriteRegistrationSource(std::ostream &out, const std::string &fwdDeclnArgsToKeepString,
94  const std::string &headersClassesMapString, const std::string &fwdDeclsString,
95  const std::string &extraIncludes, bool hasCxxModule) const;
96  void WriteContentHeader(std::ostream &out) const;
97  void WriteUmbrellaHeader(std::ostream &out) const;
98 
99  private:
100  void WriteRegistrationSourceImpl(std::ostream& out,
101  const std::string &dictName,
102  const std::string &demangledDictName,
103  const std::vector<std::string> &headerArray,
104  const std::vector<std::string> &includePathArray,
105  const std::string &fwdDeclStringRAW,
106  const std::string &fwdDeclnArgsToKeepString,
107  const std::string &payloadCodeWrapped,
108  const std::string &headersClassesMapString,
109  const std::string &extraIncludes,
110  bool hasCxxModule) const;
111 
112  void ConvertToCppString(std::string &text) const;
113 
114  std::ostream &WritePPIncludes(std::ostream &out) const;
115 
116  std::ostream &WritePPCode(std::ostream &out) const {
117  // Write defines, undefiles, includes, corrsponding to a rootcling
118  // invocation with -c -DFOO -UBAR header.h.
119  WritePPDefines(out);
120  WritePPUndefines(out);
121  return WritePPIncludes(out);
122  }
123 
124  std::ostream &WriteHeaderArray(std::ostream &out) const {
125  // Write "header1.h",\n"header2.h",\n0\n
126  return WriteStringVec(fHeaders, out);
127  }
128  std::ostream &WriteIncludePathArray(std::ostream &out) const {
129  // Write "./include",\n"/usr/include",\n0\n
130  return WriteStringVec(fCompI, out);
131  }
132  std::ostream &WriteDefinesArray(std::ostream &out) const {
133  // Write "DEFINED",\n"NAME=\"VALUE\"",\n0\n
134  return WriteStringPairVec(fCompD, out);
135  }
136  std::ostream &WriteUndefinesArray(std::ostream &out) const {
137  // Write "UNDEFINED",\n"NAME",\n0\n
138  return WriteStringVec(fCompU, out);
139  }
140 
141  bool FindHeader(const std::string& hdrName, std::string& hdrFullPath) const;
142 
143  typedef std::vector<std::pair<std::string, std::string> > StringPairVec_t;
144 
145  ESourceFileKind GetSourceFileKind(const char *filename) const;
146  std::ostream &WriteStringVec(const std::vector<std::string> &vec,
147  std::ostream &out) const;
148  std::ostream &WriteStringPairVec(const StringPairVec_t &vecP,
149  std::ostream &out) const;
150 
151  clang::CompilerInstance *fCI;
152  bool fIsPCH;
153  bool fIsInPCH; // whether the headers of this module are part of the PCH.
155 
156  std::string fDictionaryName; // Name of the dictionary, e.g. "Base"
157  std::string fDemangledDictionaryName; // Demangled name of the dictionary
158  std::string fModuleFileName; // PCM file name
159  std::string fModuleDirName; // PCM output directory
160  std::string fUmbrellaName; // name of umbrella header in PCM
161  std::string fContentName; // name of content description header in PCM
162 
163  std::vector<std::string> fHeaders; // exported headers in PCM
164  std::string fLinkDefFile; // The name of the linkdef file
165  std::vector<std::string> fCompI; // -I; needed only for ACLiC without PCMs
166 
167  StringPairVec_t fCompD; // -Dfirst=second
168  std::vector<std::string> fCompU; // -Ufirst
169  mutable int fErrorCount;
170  };
171 
172 } // namespace ROOT
173 
174 #endif // ROOT_TModuleGenerator
void WriteRegistrationSourceImpl(std::ostream &out, const std::string &dictName, const std::string &demangledDictName, const std::vector< std::string > &headerArray, const std::vector< std::string > &includePathArray, const std::string &fwdDeclStringRAW, const std::string &fwdDeclnArgsToKeepString, const std::string &payloadCodeWrapped, const std::string &headersClassesMapString, const std::string &extraIncludes, bool hasCxxModule) const
clang::CompilerInstance * fCI
const std::string & GetDictionaryName() const
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn&#39;t allow to forward declare tb...
Definition: StringConv.hxx:21
void WriteContentHeader(std::ostream &out) const
Write a header file describing the content of this module through a series of variables inside the na...
const std::vector< std::string > & GetIncludePaths() const
std::ostream & WriteStringPairVec(const StringPairVec_t &vecP, std::ostream &out) const
std::vector< std::string > fHeaders
const std::string & GetDemangledDictionaryName() const
std::ostream & WriteIncludePathArray(std::ostream &out) const
TModuleGenerator(clang::CompilerInstance *CI, bool inlineHeader, const std::string &shLibFileName, bool isInPCH)
const std::string & GetModuleFileName() const
std::ostream & WritePPUndefines(std::ostream &out) const
Write #ifdef FOO undef FOO#endif.
std::ostream & WriteUndefinesArray(std::ostream &out) const
std::vector< std::pair< std::string, std::string > > StringPairVec_t
std::ostream & WritePPDefines(std::ostream &out) const
Write #ifndef FOO define FOO=bar#endif.
const std::vector< std::string > & GetHeaders() const
std::ostream & WriteHeaderArray(std::ostream &out) const
std::ostream & WritePPCode(std::ostream &out) const
void ConvertToCppString(std::string &text) const
ESourceFileKind GetSourceFileKind(const char *filename) const
Check whether the file&#39;s extension is compatible with C or C++.
void WriteUmbrellaHeader(std::ostream &out) const
Write a header file pulling in the content of this module through a series of #defined, #undefs and #includes.
TText * text
std::ostream & WriteStringVec(const std::vector< std::string > &vec, std::ostream &out) const
const std::string & GetUmbrellaName() const
bool FindHeader(const std::string &hdrName, std::string &hdrFullPath) const
Return true if the header is found in the include paths in this case also fill the full path variable...
std::vector< std::string > fCompU
const std::string & GetContentName() const
void ParseArgs(const std::vector< std::string > &args)
Parse -I -D -U headers.h SomethingLinkdef.h.
std::string fDemangledDictionaryName
const std::string & GetModuleDirName() const
std::ostream & WritePPIncludes(std::ostream &out) const
Write #include "header1.h" #include "header2.h" or, if inlining of headers is requested, dump the content of the files.
std::ostream & WriteDefinesArray(std::ostream &out) const
void WriteRegistrationSource(std::ostream &out, const std::string &fwdDeclnArgsToKeepString, const std::string &headersClassesMapString, const std::string &fwdDeclsString, const std::string &extraIncludes, bool hasCxxModule) const
std::vector< std::string > fCompI