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

Go to the SVN repository for this file.

1 #ifndef PROJECT_TREE_BUILDER__PROJ_TREE_BUILDER__HPP
2 #define PROJECT_TREE_BUILDER__PROJ_TREE_BUILDER__HPP
3 
4 /* $Id: proj_tree_builder.hpp 84672 2018-11-28 16:02:09Z gouriano $
5  * ===========================================================================
6  *
7  * PUBLIC DOMAIN NOTICE
8  * National Center for Biotechnology Information
9  *
10  * This software/database is a "United States Government Work" under the
11  * terms of the United States Copyright Act. It was written as part of
12  * the author's official duties as a United States Government employee and
13  * thus cannot be copyrighted. This software/database is freely available
14  * to the public for use. The National Library of Medicine and the U.S.
15  * Government have not placed any restriction on its use or reproduction.
16  *
17  * Although all reasonable efforts have been taken to ensure the accuracy
18  * and reliability of the software and data, the NLM and the U.S.
19  * Government do not and cannot warrant the performance or results that
20  * may be obtained by using this software or data. The NLM and the U.S.
21  * Government disclaim all warranties, express or implied, including
22  * warranties of performance, merchantability or fitness for any particular
23  * purpose.
24  *
25  * Please cite the author in any work or product based on this material.
26  *
27  * ===========================================================================
28  *
29  * Author: Viatcheslav Gorelenkov
30  *
31  */
32 
33 #include "proj_item.hpp"
34 #include "proj_tree.hpp"
35 
36 #include <set>
37 #include "resolver.hpp"
38 
39 #include <corelib/ncbienv.hpp>
40 
42 
43 
44 // Traits classes - creation helpers for CProjectTreeBuilder:
45 
46 /////////////////////////////////////////////////////////////////////////////
47 ///
48 /// SMakeProjectT --
49 ///
50 /// Base traits and policies.
51 ///
52 /// Common traits and policies for all project types.
53 
55 {
57 
58  struct SMakeInInfo
59  {
60  typedef enum {
72  eMsvc
74 
76  const list<string>& names,
77  EMakeFileType maketype)
78  :m_Type (type),
80  m_MakeType(maketype)
81  {
82  }
83 
85  list<string> m_ProjNames;
87  };
88 
89  static CProjItem::TProjType GetProjType(const string& base_dir,
90  const string& projname,
92 
93  typedef list<SMakeInInfo> TMakeInInfoList;
94  static void AnalyzeMakeIn(const CSimpleMakeFileContents& makein_contents,
96 
97 
98  static string CreateMakeAppLibFileName(const string& base_dir,
99  const string& projname,
101 
102  static void CreateFullPathes (const string& dir,
103  const list<string> files,
104  list<string>* full_pathes);
105 
106  static string GetOneIncludeDir (const string& flag,
107  const string& token);
108 
109 
110  static void CreateIncludeDirs (const list<string>& cpp_flags,
111  const string& source_base_dir,
112  list<string>* include_dirs);
113 
114  static void CreateDefines (const list<string>& cpp_flags,
115  list<string>* defines);
116 
117 
118  static void Create3PartyLibs (const list<string>& libs_flags,
119  const list<string>& expected_flags,
120  list<string>* libs_list,
121  const string* mkname = NULL);
122 
123  static void DoResolveDefs (CSymResolver& resolver,
125  const set<string>& keys);
126 
127  static bool IsMakeInFile (const string& name);
128 
129  static bool IsMakeLibFile (const string& name);
130 
131  static bool IsMakeDllFile (const string& name);
132 
133  static bool IsMakeAppFile (const string& name);
134 
135  static bool IsUserProjFile (const string& name);
136 
137  static void VerifyLibDepends ( list<CProjKey>& depends_ids,
138  const string& mkname,
139  list<string>& liborder,
140  const set<string>* libs_3party = nullptr,
141  list<string>* expected_3party = nullptr);
142 
143  static void ConvertLibDepends (const list<string>& depends_libs,
144  list<CProjKey>* depends_ids,
145  const string* mkname = NULL,
146  list<string>* expected_3party = NULL);
147 
148  static void ConvertLibDependsMacro (const list<string>& depends,
149  list<string>& depends_libs);
150 
151  static bool IsConfigurableDefine (const string& define);
152  static string StripConfigurableDefine (const string& define);
153 
154  static bool HasConfigurableDefine (const string& define);
155  static string ExtractConfigurableDefine (const string& define);
156 };
157 
158 
159 
160 /////////////////////////////////////////////////////////////////////////////
161 ///
162 /// SAppProjectT --
163 ///
164 /// APP_PROJ traits and policies.
165 ///
166 /// Traits and policies specific for APP_PROJ.
167 
169 {
170  static void CreateNcbiCToolkitLibs(const CSimpleMakeFileContents& makefile,
171  list<string>* libs_list);
172 
173  static CProjKey DoCreate(const string& source_base_dir,
174  const string& proj_name,
175  const string& applib_mfilepath,
176  const TFiles& makeapp,
178  EMakeFileType maketype);
179 };
180 
181 
182 /////////////////////////////////////////////////////////////////////////////
183 ///
184 /// SLibProjectT --
185 ///
186 /// LIB_PROJ traits and policies.
187 ///
188 /// Traits and policies specific for LIB_PROJ.
189 
191 {
192  static CProjKey DoCreate(const string& source_base_dir,
193  const string& proj_name,
194  const string& applib_mfilepath,
195  const TFiles& makeapp,
197  EMakeFileType maketype);
198 
199  static CProjKey DoCreateDataSpec(
200  const string& source_base_dir,
201  const string& proj_name,
202  const string& proj_id,
204  EMakeFileType maketype);
205 };
206 
208 {
209  static CProjKey DoCreate(const string& source_base_dir,
210  const string& proj_name,
211  const string& applib_mfilepath,
212  const TFiles& makeapp,
214  EMakeFileType maketype);
215 };
216 
217 CProjItem CreateUtilityProjectItem( const string& prj_dir, const string& name);
218 
219 /////////////////////////////////////////////////////////////////////////////
220 ///
221 /// SAsnProjectT --
222 ///
223 /// Base traits and policies for project with datatool-generated source files.
224 ///
225 /// Common traits and policies for projects with datatool-generated sources.
226 
228 {
230 
231  static CProjKey DoCreate(const string& source_base_dir,
232  const string& proj_name,
233  const string& applib_mfilepath,
234  const TFiles& makeapp,
235  const TFiles& makelib,
237  const SMakeProjectT::SMakeInInfo& makeinfo);
238 
239  enum TAsnType {
242  eMultiple
243  };
244 
245  static TAsnType GetAsnProjectType(const string& applib_mfilepath,
246  const TFiles& makeapp,
247  const TFiles& makelib);
248 };
249 
250 
251 /////////////////////////////////////////////////////////////////////////////
252 ///
253 /// SAsnProjectSingleT --
254 ///
255 /// Traits and policies for project one ASN/DTD file.
256 ///
257 /// Traits and policies specific for project with one ASN/DTD file.
258 
260 {
261  static CProjKey DoCreate(const string& source_base_dir,
262  const string& proj_name,
263  const string& applib_mfilepath,
264  const TFiles& makeapp,
265  const TFiles& makelib,
267  const SMakeProjectT::SMakeInInfo& makeinfo);
268 };
269 
270 
271 /////////////////////////////////////////////////////////////////////////////
272 ///
273 /// SAsnProjectMultipleT --
274 ///
275 /// Traits and policies for project multiple ASN/DTD files.
276 ///
277 /// Traits and policies specific for project with several ASN/DTD files.
278 
280 {
281  static CProjKey DoCreate(const string& source_base_dir,
282  const string& proj_name,
283  const string& applib_mfilepath,
284  const TFiles& makeapp,
285  const TFiles& makelib,
287  const SMakeProjectT::SMakeInInfo& makeinfo);
288 };
289 
290 
291 /////////////////////////////////////////////////////////////////////////////
292 ///
293 /// SUserProjectT --
294 ///
295 /// Traits and policies for user project makefiles
296 ///
297 /// Traits and policies specific for user-generated projects
298 
300 {
301  static CProjKey DoCreate(const string& source_base_dir,
302  const string& proj_name,
303  const string& applib_mfilepath,
304  const TFiles& makemsvc,
306  EMakeFileType maketype);
307 };
308 
309 
310 /////////////////////////////////////////////////////////////////////////////
311 ///
312 /// CProjectTreeBuilder --
313 ///
314 /// Builder class for project tree.
315 ///
316 /// Builds tree, resolvs macrodefines and adds dependents projects.
317 
319 {
320 public:
322 
323  // IN LIB APP
324 // typedef STriple<TFiles, TFiles, TFiles> TMakeFiles;
325 
326  struct SMakeFiles
327  {
333  };
334 
335 
336  /// Build project tree and include all projects this tree depends upon
337  static void BuildProjectTree(const IProjectFilter* filter,
338  const string& root_src_path,
340  static bool VerifyBuildOrder(const CProjItem& item,
341  list<string> dependencies,
342  const CProjectItemsTree& tree);
343 private:
344  /// Build one project tree and do not resolve (include) depends
345  static void BuildOneProjectTree(const IProjectFilter* filter,
346  const string& root_src_path,
348 
349  static void ProcessDir (const string& dir_name,
350  bool is_root,
351  const IProjectFilter* filter,
352  SMakeFiles* makefiles,
353  EMakeFileType maketype,
354  const CSimpleMakeFileContents* parent);
355 
356  static void ProcessMakeInFile (const string& file_name,
357  SMakeFiles* makefiles,
359  const CSimpleMakeFileContents* parent);
360 
361  static void ProcessMakeLibFile (const string& file_name,
362  SMakeFiles* makefiles,
364  const CSimpleMakeFileContents* parent);
365 
366  static void ProcessMakeDllFile (const string& file_name,
367  SMakeFiles* makefiles,
369  const CSimpleMakeFileContents* parent);
370 
371  static void ProcessMakeAppFile (const string& file_name,
372  SMakeFiles* makefiles,
374  const CSimpleMakeFileContents* parent);
375 
376  static void ProcessUserProjFile(const string& file_name,
377  SMakeFiles* makefiles,
379  const CSimpleMakeFileContents* parent);
380 
381  static void ResolveDefs(CSymResolver& resolver, SMakeFiles& makefiles);
382 
383 
385 
386 };
387 
388 
390 
391 #endif //PROJECT_TREE_BUILDER__PROJ_TREE_BUILDER__HPP
CProjItem –.
Definition: proj_item.hpp:54
CProjKey –.
CProjectItemsTree –.
Definition: proj_tree.hpp:54
CProjectTreeBuilder –.
static bool VerifyBuildOrder(const CProjItem &item, list< string > dependencies, const CProjectItemsTree &tree)
static void ProcessDir(const string &dir_name, bool is_root, const IProjectFilter *filter, SMakeFiles *makefiles, EMakeFileType maketype, const CSimpleMakeFileContents *parent)
static void ProcessMakeLibFile(const string &file_name, SMakeFiles *makefiles, EMakeFileType type, const CSimpleMakeFileContents *parent)
static void BuildOneProjectTree(const IProjectFilter *filter, const string &root_src_path, CProjectItemsTree *tree)
Build one project tree and do not resolve (include) depends.
static void ProcessUserProjFile(const string &file_name, SMakeFiles *makefiles, EMakeFileType type, const CSimpleMakeFileContents *parent)
static void ResolveDefs(CSymResolver &resolver, SMakeFiles &makefiles)
static void AddDatatoolSourcesDepends(CProjectItemsTree *tree)
static void ProcessMakeAppFile(const string &file_name, SMakeFiles *makefiles, EMakeFileType type, const CSimpleMakeFileContents *parent)
static void ProcessMakeInFile(const string &file_name, SMakeFiles *makefiles, EMakeFileType type, const CSimpleMakeFileContents *parent)
static void BuildProjectTree(const IProjectFilter *filter, const string &root_src_path, CProjectItemsTree *tree)
Build project tree and include all projects this tree depends upon.
static void ProcessMakeDllFile(const string &file_name, SMakeFiles *makefiles, EMakeFileType type, const CSimpleMakeFileContents *parent)
map< string, CSimpleMakeFileContents > TFiles
CSimpleMakeFileContents –.
Utilits for Project Tree Builder:
Definition: proj_utils.hpp:43
const char * file_name[]
EMakeFileType
static const struct name_t names[]
#define NULL
Definition: ncbistd.hpp:225
#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
Defines unified interface to application:
CProjItem CreateUtilityProjectItem(const string &prj_dir, const string &name)
SAppProjectT –.
static CProjKey DoCreate(const string &source_base_dir, const string &proj_name, const string &applib_mfilepath, const TFiles &makeapp, CProjectItemsTree *tree, EMakeFileType maketype)
static void CreateNcbiCToolkitLibs(const CSimpleMakeFileContents &makefile, list< string > *libs_list)
SAsnProjectMultipleT –.
static CProjKey DoCreate(const string &source_base_dir, const string &proj_name, const string &applib_mfilepath, const TFiles &makeapp, const TFiles &makelib, CProjectItemsTree *tree, const SMakeProjectT::SMakeInInfo &makeinfo)
SAsnProjectSingleT –.
static CProjKey DoCreate(const string &source_base_dir, const string &proj_name, const string &applib_mfilepath, const TFiles &makeapp, const TFiles &makelib, CProjectItemsTree *tree, const SMakeProjectT::SMakeInInfo &makeinfo)
SAsnProjectT –.
static CProjKey DoCreate(const string &source_base_dir, const string &proj_name, const string &applib_mfilepath, const TFiles &makeapp, const TFiles &makelib, CProjectItemsTree *tree, const SMakeProjectT::SMakeInInfo &makeinfo)
CProjectItemsTree::TProjects TProjects
static TAsnType GetAsnProjectType(const string &applib_mfilepath, const TFiles &makeapp, const TFiles &makelib)
static CProjKey DoCreate(const string &source_base_dir, const string &proj_name, const string &applib_mfilepath, const TFiles &makeapp, CProjectItemsTree *tree, EMakeFileType maketype)
SLibProjectT –.
static CProjKey DoCreateDataSpec(const string &source_base_dir, const string &proj_name, const string &proj_id, CProjectItemsTree *tree, EMakeFileType maketype)
static CProjKey DoCreate(const string &source_base_dir, const string &proj_name, const string &applib_mfilepath, const TFiles &makeapp, CProjectItemsTree *tree, EMakeFileType maketype)
SMakeInInfo(TMakeinType type, const list< string > &names, EMakeFileType maketype)
SMakeProjectT –.
static bool IsMakeAppFile(const string &name)
static bool IsUserProjFile(const string &name)
static void DoResolveDefs(CSymResolver &resolver, CProjectItemsTree::TFiles &files, const set< string > &keys)
static void VerifyLibDepends(list< CProjKey > &depends_ids, const string &mkname, list< string > &liborder, const set< string > *libs_3party=nullptr, list< string > *expected_3party=nullptr)
static bool IsMakeDllFile(const string &name)
static bool IsConfigurableDefine(const string &define)
static void ConvertLibDepends(const list< string > &depends_libs, list< CProjKey > *depends_ids, const string *mkname=NULL, list< string > *expected_3party=NULL)
static string CreateMakeAppLibFileName(const string &base_dir, const string &projname, SMakeInInfo::TMakeinType type=SMakeInInfo::eUnknown)
static void Create3PartyLibs(const list< string > &libs_flags, const list< string > &expected_flags, list< string > *libs_list, const string *mkname=NULL)
list< SMakeInInfo > TMakeInInfoList
static void CreateIncludeDirs(const list< string > &cpp_flags, const string &source_base_dir, list< string > *include_dirs)
static void CreateDefines(const list< string > &cpp_flags, list< string > *defines)
static void AnalyzeMakeIn(const CSimpleMakeFileContents &makein_contents, TMakeInInfoList *info)
static string ExtractConfigurableDefine(const string &define)
static bool HasConfigurableDefine(const string &define)
static void ConvertLibDependsMacro(const list< string > &depends, list< string > &depends_libs)
static string GetOneIncludeDir(const string &flag, const string &token)
static string StripConfigurableDefine(const string &define)
static bool IsMakeInFile(const string &name)
static bool IsMakeLibFile(const string &name)
CProjectItemsTree::TFiles TFiles
static CProjItem::TProjType GetProjType(const string &base_dir, const string &projname, SMakeInInfo::TMakeinType type=SMakeInInfo::eUnknown)
static void CreateFullPathes(const string &dir, const list< string > files, list< string > *full_pathes)
SUserProjectT –.
static CProjKey DoCreate(const string &source_base_dir, const string &proj_name, const string &applib_mfilepath, const TFiles &makemsvc, CProjectItemsTree *tree, EMakeFileType maketype)
Definition: type.c:6
Modified on Sat May 18 11:37:58 2024 by modify_doxy.py rev. 669887