NCBI C++ ToolKit
msvc_makefile.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 #ifndef PROJECT_TREE_BULDER__MSVC_MAKEFILE__HPP
2 #define PROJECT_TREE_BULDER__MSVC_MAKEFILE__HPP
3 /* $Id: msvc_makefile.hpp 84817 2018-12-14 15:04:17Z gouriano $
4  * ===========================================================================
5  *
6  * PUBLIC DOMAIN NOTICE
7  * National Center for Biotechnology Information
8  *
9  * This software/database is a "United States Government Work" under the
10  * terms of the United States Copyright Act. It was written as part of
11  * the author's official duties as a United States Government employee and
12  * thus cannot be copyrighted. This software/database is freely available
13  * to the public for use. The National Library of Medicine and the U.S.
14  * Government have not placed any restriction on its use or reproduction.
15  *
16  * Although all reasonable efforts have been taken to ensure the accuracy
17  * and reliability of the software and data, the NLM and the U.S.
18  * Government do not and cannot warrant the performance or results that
19  * may be obtained by using this software or data. The NLM and the U.S.
20  * Government disclaim all warranties, express or implied, including
21  * warranties of performance, merchantability or fitness for any particular
22  * purpose.
23  *
24  * Please cite the author in any work or product based on this material.
25  *
26  * ===========================================================================
27  *
28  * Author: Viatcheslav Gorelenkov
29  *
30  */
31 #include "ptb_registry.hpp"
32 #include "proj_item.hpp"
33 #include "msvc_prj_utils.hpp"
34 #include <corelib/ncbiobj.hpp>
35 
36 #include <corelib/ncbienv.hpp>
38 
39 ///
40 /// Interface of master msvc makefile
42 {
43 public:
44  virtual ~IMsvcMetaMakefile() {}
45 
46  virtual string GetConfigurationOpt (const string& opt,
47  const SConfigInfo& config) const = 0;
48 
49  virtual string GetCompilerOpt (const string& opt,
50  const SConfigInfo& config) const = 0;
51 
52  virtual string GetLinkerOpt (const string& opt,
53  const SConfigInfo& config) const = 0;
54 
55  virtual string GetLibrarianOpt(const string& opt,
56  const SConfigInfo& config) const = 0;
57 
58  virtual string GetResourceCompilerOpt
59  (const string& opt,
60  const SConfigInfo& config) const = 0;
61 
62 };
63 
64 ///
65 /// Interface of msvc project makefile
67 {
68 public:
69  virtual ~IMsvcProjectMakefile() {}
70  virtual bool IsExcludeProject (bool default_val) const = 0;
71 
73  (const SConfigInfo& config,
74  list<string>* files) const = 0;
75 
76  virtual void GetAdditionalLIB (const SConfigInfo& config,
77  list<string>* lib_ids) const = 0;
78 
79  virtual void GetExcludedSourceFiles
80  (const SConfigInfo& config,
81  list<string>* files) const = 0;
82 
83  virtual void GetExcludedLIB (const SConfigInfo& config,
84  list<string>* lib_ids) const = 0;
85 
87  (const SConfigInfo& config,
88  list<string>* files) const = 0;
89 
90  virtual void GetHeadersInInclude
91  (const SConfigInfo& config,
92  list<string>* files) const = 0;
93 
94  virtual void GetHeadersInSrc
95  (const SConfigInfo& config,
96  list<string>* files) const = 0;
97 
98  virtual void GetInlinesInInclude
99  (const SConfigInfo& config,
100  list<string>* files) const = 0;
101 
102  virtual void GetInlinesInSrc
103  (const SConfigInfo& config,
104  list<string>* files) const = 0;
105 
106  virtual void GetCustomBuildInfo
107  (list<SCustomBuildInfo>* info) const = 0;
108 
109  virtual void GetResourceFiles (const SConfigInfo& config,
110  list<string>* files) const = 0;
111 
112  virtual void GetExtraFiles (map<string, list<string> >* files) const = 0;
113 
114 };
115 
116 
117 /////////////////////////////////////////////////////////////////////////////
118 ///
119 /// CMsvcMetaMakefile --
120 ///
121 /// Abstraction of global settings for building of C++ projects.
122 ///
123 /// Provides information about default compiler, linker and librarian
124 /// settinngs.
125 
126 
127 
128 class CMsvcMetaMakefile : public CObject,
129  public IMsvcMetaMakefile
130 {
131 public:
132  CMsvcMetaMakefile(const string& file_path);
133 
134 
135  bool IsEmpty (void) const;
136 
137 
138  static string TranslateOpt(const string& value, const string& section, const string& opt);
139  static string TranslateCommand(const string& value);
140  // IMsvcMetaMakefile
141  virtual string GetConfigurationOpt (const string& opt,
142  const SConfigInfo& config) const;
143 
144  virtual string GetCompilerOpt (const string& opt,
145  const SConfigInfo& config) const;
146 
147  virtual string GetLinkerOpt (const string& opt,
148  const SConfigInfo& config) const;
149 
150  virtual string GetLibrarianOpt(const string& opt,
151  const SConfigInfo& config) const;
152 
153  virtual string GetResourceCompilerOpt
154  (const string& opt,
155  const SConfigInfo& config) const;
156 
157  string GetConfigOpt(
158  const string& section, const string& opt,
159  const SConfigInfo& config) const;
160 
161  bool IsPchEnabled (void) const;
162  string GetUsePchThroughHeader (const string& project_id,
163  const string& source_file_full_path,
164  const string& tree_src_dir) const;
165  string GetPchUsageDefine (void) const;
166  string GetDefaultPch(void) const
167  {
168  return GetPchInfo().m_DefaultPch;
169  }
170 
171 
172 protected:
175  string m_FilePath;
176 
177  struct SPchInfo
178  {
179  bool m_UsePch;
180 
183 
184  typedef list<string> TDontUsePch;
186 
187  string m_DefaultPch;
189  };
190  const SPchInfo& GetPchInfo(void) const;
191 
192 private:
193  unique_ptr<SPchInfo> m_PchInfo;
194 
197 };
198 
199 
200 /////////////////////////////////////////////////////////////////////////////
201 ///
202 /// CMsvcProjectMakefile --
203 ///
204 /// Abstraction of project MSVC specific settings
205 ///
206 /// Provides information about project include/exclude to build,
207 /// additional/excluded files and project specific compiler, linker
208 /// and librarian settinngs.
209 
211  public IMsvcProjectMakefile
212 {
213 public:
214  CMsvcProjectMakefile(const string& file_path, bool compound=false);
215 
216  string GetGUID(void) const;
217  bool Redefine(const string& value, list<string>& redef) const;
218  bool Redefine(const list<string>& value, list<string>& redef) const;
219  void Append( list<string>& values, const string& def) const;
220  void Append( list<string>& values, const list<string>& def) const;
221 
222  // IMsvcProjectMakefile
223  virtual bool IsExcludeProject (bool default_val) const;
224 
225  virtual void GetAdditionalSourceFiles(const SConfigInfo& config,
226  list<string>* files) const;
227 
228  virtual void GetAdditionalLIB (const SConfigInfo& config,
229  list<string>* lib_ids) const;
230 
231  virtual void GetExcludedSourceFiles (const SConfigInfo& config,
232  list<string>* files) const;
233 
234  virtual void GetExcludedLIB (const SConfigInfo& config,
235  list<string>* lib_ids) const;
236 
237  virtual void GetAdditionalIncludeDirs(const SConfigInfo& config,
238  list<string>* files) const;
239 
240  virtual void GetHeadersInInclude (const SConfigInfo& config,
241  list<string>* files) const;
242 
243  virtual void GetHeadersInSrc (const SConfigInfo& config,
244  list<string>* files) const;
245 
246  virtual void GetInlinesInInclude (const SConfigInfo& config,
247  list<string>* files) const;
248 
249  virtual void GetInlinesInSrc (const SConfigInfo& config,
250  list<string>* files) const;
251 
252  virtual void GetCustomBuildInfo (list<SCustomBuildInfo>* info) const;
253 
254  virtual void GetResourceFiles (const SConfigInfo& config,
255  list<string>* files) const;
256 
257  virtual void GetExtraFiles (map<string, list<string> >* files) const;
258 
259  void GetCustomScriptInfo (SCustomScriptInfo& info, const string& section) const;
260 
261 
263  bool m_Compound; // ie, consists of hosted components (DLL)
264 
265 private:
266  void x_GetHeaders(const SConfigInfo& config, const string& entry,
267  list<string>* files) const;
268 
269  //Prohibited to
273 };
274 
275 
276 ///
277 /// Abstraction of rule for generation of project settings
278 /// based on component usage
279 
281 {
282 public:
283  CMsvcProjectRuleMakefile(const string& file_path, bool compound);
284 
285  int GetRulePriority(const SConfigInfo& config) const;
286 
287 private:
288  //Prohibited to
292 };
293 
294 
295 ///
296 /// Combining of rules and project makefile
298  public IMsvcProjectMakefile
299 {
300 public:
302  const CMsvcProjectMakefile* project_makefile,
303  const string& rules_basedir,
304  const list<string> requires_list);
305 
306  virtual ~CMsvcCombinedProjectMakefile(void);
307 
308  // IMsvcMetaMakefile
309  virtual string GetConfigurationOpt (const string& opt,
310  const SConfigInfo& config) const;
311 
312  virtual string GetCompilerOpt (const string& opt,
313  const SConfigInfo& config) const;
314 
315  virtual string GetLinkerOpt (const string& opt,
316  const SConfigInfo& config) const;
317 
318  virtual string GetLibrarianOpt(const string& opt,
319  const SConfigInfo& config) const;
320 
321  virtual string GetResourceCompilerOpt
322  (const string& opt,
323  const SConfigInfo& config) const;
324 
325  // IMsvcProjectMakefile
326  virtual bool IsExcludeProject (bool default_val) const;
327 
328  virtual void GetAdditionalSourceFiles(const SConfigInfo& config,
329  list<string>* files) const;
330 
331  virtual void GetAdditionalLIB (const SConfigInfo& config,
332  list<string>* lib_ids) const;
333 
334  virtual void GetExcludedSourceFiles (const SConfigInfo& config,
335  list<string>* files) const;
336 
337  virtual void GetExcludedLIB (const SConfigInfo& config,
338  list<string>* lib_ids) const;
339 
340  virtual void GetAdditionalIncludeDirs(const SConfigInfo& config,
341  list<string>* files) const;
342 
343  virtual void GetHeadersInInclude (const SConfigInfo& config,
344  list<string>* files) const;
345 
346  virtual void GetHeadersInSrc (const SConfigInfo& config,
347  list<string>* files) const;
348 
349  virtual void GetInlinesInInclude (const SConfigInfo& config,
350  list<string>* files) const;
351 
352  virtual void GetInlinesInSrc (const SConfigInfo& config,
353  list<string>* files) const;
354 
355  virtual void GetCustomBuildInfo (list<SCustomBuildInfo>* info) const;
356 
357  virtual void GetResourceFiles (const SConfigInfo& config,
358  list<string>* files) const;
359 
360  virtual void GetExtraFiles (map<string, list<string> >* files) const;
361 
362 
363  void GetCustomScriptInfo (SCustomScriptInfo& info, const string& section) const;
364 
365 private:
368 
370  typedef list<TRule> TRules;
372 
373 
374  //Prohibited to
379 };
380 
381 
382 
383 /// Create project makefile name
384 string CreateMsvcProjectMakefileName(const string& project_name,
386 string CreateMsvcProjectMakefileName(const CProjItem& project);
387 
388 
389 
390 /// Get option with taking into account 2 makefiles : matafile and project_file
391 
392 /// Configuration
393 string GetConfigurationOpt (const IMsvcMetaMakefile& meta_file,
394  const IMsvcMetaMakefile& project_file,
395  const string& opt,
396  const SConfigInfo& config);
397 
398 /// Compiler
399 string GetCompilerOpt (const IMsvcMetaMakefile& meta_file,
400  const IMsvcMetaMakefile& project_file,
401  const string& opt,
402  const SConfigInfo& config);
403 
404 /// Linker
405 string GetLinkerOpt (const IMsvcMetaMakefile& meta_file,
406  const IMsvcMetaMakefile& project_file,
407  const string& opt,
408  const SConfigInfo& config);
409 
410 /// Librarian
411 string GetLibrarianOpt (const IMsvcMetaMakefile& meta_file,
412  const IMsvcMetaMakefile& project_file,
413  const string& opt,
414  const SConfigInfo& config);
415 
416 /// ResourceCompiler
417 string GetResourceCompilerOpt(const IMsvcMetaMakefile& meta_file,
418  const IMsvcMetaMakefile& project_file,
419  const string& opt,
420  const SConfigInfo& config);
421 
423 
424 #endif //PROJECT_TREE_BULDER__MSVC_MAKEFILE__HPP
Combining of rules and project makefile.
virtual void GetInlinesInSrc(const SConfigInfo &config, list< string > *files) const
virtual void GetCustomBuildInfo(list< SCustomBuildInfo > *info) const
virtual string GetCompilerOpt(const string &opt, const SConfigInfo &config) const
const CMsvcProjectMakefile * TProjectMakefile
virtual void GetExcludedLIB(const SConfigInfo &config, list< string > *lib_ids) const
virtual void GetHeadersInInclude(const SConfigInfo &config, list< string > *files) const
TProjectMakefile m_ProjectMakefile
virtual void GetAdditionalIncludeDirs(const SConfigInfo &config, list< string > *files) const
virtual void GetInlinesInInclude(const SConfigInfo &config, list< string > *files) const
CMsvcCombinedProjectMakefile & operator=(const CMsvcCombinedProjectMakefile &)
virtual void GetResourceFiles(const SConfigInfo &config, list< string > *files) const
virtual string GetConfigurationOpt(const string &opt, const SConfigInfo &config) const
virtual string GetResourceCompilerOpt(const string &opt, const SConfigInfo &config) const
virtual string GetLibrarianOpt(const string &opt, const SConfigInfo &config) const
CMsvcCombinedProjectMakefile(const CMsvcCombinedProjectMakefile &)
virtual void GetExcludedSourceFiles(const SConfigInfo &config, list< string > *files) const
virtual bool IsExcludeProject(bool default_val) const
virtual void GetExtraFiles(map< string, list< string > > *files) const
void GetCustomScriptInfo(SCustomScriptInfo &info, const string &section) const
virtual ~CMsvcCombinedProjectMakefile(void)
virtual void GetAdditionalLIB(const SConfigInfo &config, list< string > *lib_ids) const
virtual string GetLinkerOpt(const string &opt, const SConfigInfo &config) const
CRef< CMsvcProjectRuleMakefile > TRule
virtual void GetAdditionalSourceFiles(const SConfigInfo &config, list< string > *files) const
virtual void GetHeadersInSrc(const SConfigInfo &config, list< string > *files) const
CMsvcMetaMakefile –.
CPtbRegistry m_MakeFile
virtual string GetCompilerOpt(const string &opt, const SConfigInfo &config) const
CMsvcMetaMakefile & operator=(const CMsvcMetaMakefile &)
bool IsPchEnabled(void) const
CMsvcMetaMakefile(const CMsvcMetaMakefile &)
const SPchInfo & GetPchInfo(void) const
string GetDefaultPch(void) const
bool IsEmpty(void) const
virtual string GetResourceCompilerOpt(const string &opt, const SConfigInfo &config) const
virtual string GetLinkerOpt(const string &opt, const SConfigInfo &config) const
string GetUsePchThroughHeader(const string &project_id, const string &source_file_full_path, const string &tree_src_dir) const
virtual string GetLibrarianOpt(const string &opt, const SConfigInfo &config) const
string GetPchUsageDefine(void) const
static string TranslateOpt(const string &value, const string &section, const string &opt)
CMsvcMetaMakefile(const string &file_path)
static string TranslateCommand(const string &value)
virtual string GetConfigurationOpt(const string &opt, const SConfigInfo &config) const
unique_ptr< SPchInfo > m_PchInfo
string GetConfigOpt(const string &section, const string &opt, const SConfigInfo &config) const
CMsvcProjectMakefile –.
virtual void GetHeadersInInclude(const SConfigInfo &config, list< string > *files) const
virtual bool IsExcludeProject(bool default_val) const
virtual void GetResourceFiles(const SConfigInfo &config, list< string > *files) const
bool Redefine(const string &value, list< string > &redef) const
void x_GetHeaders(const SConfigInfo &config, const string &entry, list< string > *files) const
virtual void GetAdditionalIncludeDirs(const SConfigInfo &config, list< string > *files) const
virtual void GetCustomBuildInfo(list< SCustomBuildInfo > *info) const
virtual void GetInlinesInInclude(const SConfigInfo &config, list< string > *files) const
string GetGUID(void) const
virtual void GetHeadersInSrc(const SConfigInfo &config, list< string > *files) const
virtual void GetInlinesInSrc(const SConfigInfo &config, list< string > *files) const
CMsvcProjectMakefile(const CMsvcProjectMakefile &)
void Append(list< string > &values, const string &def) const
CMsvcProjectMakefile & operator=(const CMsvcProjectMakefile &)
virtual void GetAdditionalLIB(const SConfigInfo &config, list< string > *lib_ids) const
virtual void GetAdditionalSourceFiles(const SConfigInfo &config, list< string > *files) const
void GetCustomScriptInfo(SCustomScriptInfo &info, const string &section) const
virtual void GetExtraFiles(map< string, list< string > > *files) const
virtual void GetExcludedLIB(const SConfigInfo &config, list< string > *lib_ids) const
virtual void GetExcludedSourceFiles(const SConfigInfo &config, list< string > *files) const
Abstraction of rule for generation of project settings based on component usage.
CMsvcProjectRuleMakefile & operator=(const CMsvcProjectRuleMakefile &)
int GetRulePriority(const SConfigInfo &config) const
CMsvcProjectRuleMakefile(const CMsvcProjectRuleMakefile &)
CObject –.
Definition: ncbiobj.hpp:180
CProjItem –.
Definition: proj_item.hpp:54
CRef –.
Definition: ncbiobj.hpp:618
Interface of master msvc makefile.
virtual string GetResourceCompilerOpt(const string &opt, const SConfigInfo &config) const =0
virtual string GetCompilerOpt(const string &opt, const SConfigInfo &config) const =0
virtual string GetLibrarianOpt(const string &opt, const SConfigInfo &config) const =0
virtual string GetLinkerOpt(const string &opt, const SConfigInfo &config) const =0
virtual string GetConfigurationOpt(const string &opt, const SConfigInfo &config) const =0
virtual ~IMsvcMetaMakefile()
Interface of msvc project makefile.
virtual void GetInlinesInSrc(const SConfigInfo &config, list< string > *files) const =0
virtual void GetAdditionalIncludeDirs(const SConfigInfo &config, list< string > *files) const =0
virtual void GetExcludedLIB(const SConfigInfo &config, list< string > *lib_ids) const =0
virtual void GetExcludedSourceFiles(const SConfigInfo &config, list< string > *files) const =0
virtual void GetCustomBuildInfo(list< SCustomBuildInfo > *info) const =0
virtual ~IMsvcProjectMakefile()
virtual void GetResourceFiles(const SConfigInfo &config, list< string > *files) const =0
virtual void GetInlinesInInclude(const SConfigInfo &config, list< string > *files) const =0
virtual void GetAdditionalLIB(const SConfigInfo &config, list< string > *lib_ids) const =0
virtual void GetExtraFiles(map< string, list< string > > *files) const =0
virtual void GetAdditionalSourceFiles(const SConfigInfo &config, list< string > *files) const =0
virtual void GetHeadersInSrc(const SConfigInfo &config, list< string > *files) const =0
virtual void GetHeadersInInclude(const SConfigInfo &config, list< string > *files) const =0
virtual bool IsExcludeProject(bool default_val) const =0
Definition: map.hpp:338
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
static MDB_envinfo info
Definition: mdb_load.c:37
string GetLibrarianOpt(const IMsvcMetaMakefile &meta_file, const IMsvcMetaMakefile &project_file, const string &opt, const SConfigInfo &config)
Librarian.
string GetResourceCompilerOpt(const IMsvcMetaMakefile &meta_file, const IMsvcMetaMakefile &project_file, const string &opt, const SConfigInfo &config)
ResourceCompiler.
string GetConfigurationOpt(const IMsvcMetaMakefile &meta_file, const IMsvcMetaMakefile &project_file, const string &opt, const SConfigInfo &config)
Get option with taking into account 2 makefiles : matafile and project_file.
string GetCompilerOpt(const IMsvcMetaMakefile &meta_file, const IMsvcMetaMakefile &project_file, const string &opt, const SConfigInfo &config)
Compiler.
string GetLinkerOpt(const IMsvcMetaMakefile &meta_file, const IMsvcMetaMakefile &project_file, const string &opt, const SConfigInfo &config)
Linker.
string CreateMsvcProjectMakefileName(const string &project_name, CProjItem::TProjType type)
Create project makefile name.
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
Defines unified interface to application:
Portable reference counted smart and weak pointers using CWeakRef, CRef, CObject and CObjectEx.
map< string, string > TSubdirPchfile
SConfigInfo –.
Definition: type.c:6
Modified on Wed Sep 04 15:03:30 2024 by modify_doxy.py rev. 669887