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

Go to the SVN repository for this file.

1 #ifndef PROJECT_TREE_BULDER__PROJ_BUILDER_APP__HPP
2 #define PROJECT_TREE_BULDER__PROJ_BUILDER_APP__HPP
3 
4 /* $Id: proj_builder_app.hpp 84663 2018-11-27 18:22:00Z ucko $
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 <corelib/ncbiapp.hpp>
34 #include <corelib/ncbienv.hpp>
35 #include <corelib/ncbiargs.hpp>
36 #include <corelib/ncbifile.hpp>
37 #include "proj_utils.hpp"
38 #include "file_contents.hpp"
39 #include "resolver.hpp"
40 #include "msvc_prj_utils.hpp"
41 #include "msvc_site.hpp"
42 #include "msvc_makefile.hpp"
43 #include "msvc_dlls_info.hpp"
44 #include "proj_tree_builder.hpp"
45 
46 
48 
49 /////////////////////////////////////////////////////////////////////////////
50 ///
51 /// CProjBulderApp --
52 ///
53 /// Abstraction of proj_tree_builder application.
54 ///
55 /// Singleton implementation.
56 
58 {
59 public:
60 
61 
62  /// ShortCut for enums
63  int EnumOpt(const string& enum_name, const string& enum_val) const;
64 
65  /// Singleton
66  friend CProjBulderApp& GetApp(void);
67 
68 
69 private:
70  CProjBulderApp(void);
71 
72  virtual void Init(void);
73  virtual int Run (void);
74  virtual void Exit(void);
75 
76  /// Parse program arguments.
77  void ParseArguments(void);
78  void VerifyArguments(void);
79 
80  //TFiles m_FilesMakeIn;
81  //TFiles m_FilesMakeLib;
82  //TFiles m_FilesMakeApp;
83 
85  void DumpFiles(const TFiles& files, const string& filename) const;
86 
87  unique_ptr<CMsvc7RegSettings> m_MsvcRegSettings;
88  unique_ptr<CMsvcSite> m_MsvcSite;
89  unique_ptr<CMsvcMetaMakefile> m_MsvcMetaMakefile;
90 
91  unique_ptr<SProjectTreeInfo> m_ProjectTreeInfo;
92 
93  unique_ptr<CBuildType> m_BuildType;
94 
95 // unique_ptr<CMsvcDllsInfo> m_DllsInfo;
96 
97  unique_ptr<CProjectItemsTree> m_WholeTree;
98 
99  unique_ptr<CDllSrcFilesDistr> m_DllSrcFilesDistr;
100 
103 
108  list<string> m_AbsDirs;
109  list<string> m_GeneratedFiles;
110  list<string> m_ProjWatchers;
111  list<string> m_CustomMetaData;
112  list<string> m_CustomConfH;
114 
115 public:
116 
117  string m_Root;
118  string m_Subtree;
119  string m_Solution;
120  string m_StatusDir;
121  string m_IncDir;
122  bool m_Dll;
129  string m_BuildRoot;
130  string m_ExtSrcRoot;
131  string m_ProjTags;
136  bool m_Dtdep;
138  bool m_LibDep;
139  int m_Ide;
140  string m_Arch;
141 
145 
151 
155 
156 public:
157  bool UseAbsolutePath(const string& path) const;
158  void AddCustomMetaData(const string& file);
159  void GetMetaDataFiles(list<string>* files) const;
160 
161  void AddCustomConfH(const string& file);
162  void GetCustomConfH(list<string>* files) const;
163 
164 
165  const CMsvc7RegSettings& GetRegSettings (void);
166 
167  const CMsvcSite& GetSite (void);
168 
169  const CMsvcMetaMakefile& GetMetaMakefile (void);
170 
172 
173  const CBuildType& GetBuildType (void);
174 
175  const string& GetBuildRoot (void) const
176  {
177  return m_BuildRoot;
178  }
179  const string& GetExtSrcRoot (void) const
180  {
181  return m_ExtSrcRoot;
182  }
183  const CProjectItemsTree& GetWholeTree (void);
185  {
186  return m_CurrentBuildTree;
187  }
189  {
190  return m_IncompleteBuildTree;
191  }
192 
194 
195  string GetDataspecProjId (void) const;
196  string GetDatatoolId (void) const;
197  string GetDatatoolPathForApp (void) const;
198  string GetDatatoolPathForLib (void) const;
199  string GetDatatoolCommandLine (void) const;
200 
201  string GetProjectTreeRoot(void) const;
202  bool IsAllowedProjectTag(const CProjItem& project, const string* filter = NULL) const;
203  string ProcessLocationMacros(string data);
204  string GetConfigureMacro(string data);
205  bool IsScanningWholeTree(void) const {return m_ScanningWholeTree;}
206  void SetFail(int exit_code=1) {m_ExitCode=exit_code;}
207  void RegisterSuspiciousProject(const CProjKey& proj);
208  void RegisterGeneratedFile( const string& file);
210  const string& project, const string& dir, const string& watcher);
213 
214  string GetUtilityProjectsDir(void) const;
215  string GetUtilityProjectsSrcDir(void);
216  void SetConfFileData(const string& src, const string& dest);
217 
218  string GetBuildDir(void);
219 
221 private:
222  void LoadProjectTags(const string& filename);
223  bool FindDepGraph(const string& root, list<string>& found) const;
224  void LoadDepGraph(const string& filename);
225  void CollectDep(const string& libname, const string& depname);
226  void RankDepGraph(void);
227  bool InsertDep(vector< set<string> >& graph, const string& dep, list<string>& done);
228 
229  void GetBuildConfigs (list<SConfigInfo>* configs);
230  void GenerateMsvcProjects(CProjectItemsTree& projects_tree);
231  void GenerateMacProjects(CProjectItemsTree& projects_tree);
233  set<string>& dep, set<string>& visited,
236  void GenerateUnixProjects(CProjectItemsTree& projects_tree);
237  void CreateFeaturesAndPackagesFiles(const list<SConfigInfo>* configs,
238  list<string>& enabled, list<string>& disabled);
239  void GenerateSummary(const list<SConfigInfo> configs,
240  const list<string>& enabled, const list<string>& disabled);
241  void CreateCheckList(const list<SConfigInfo>* configs,
242  CProjectItemsTree& projects_tree);
243  void ReportGeneratedFiles(void);
244  void ReportProjectWatchers(void);
245 
246  bool ConfirmConfiguration(void);
247  bool Gui_ConfirmConfiguration(void);
248 
249 public:
250  bool Gui_ConfirmProjects(CProjectItemsTree& projects_tree);
251 };
252 
253 
254 /// access to App singleton
255 
256 CProjBulderApp& GetApp(void);
257 
258 
259 /////////////////////////////////////////////////////////////////////////////
260 ///
261 /// CProjBulderAppException --
262 ///
263 /// Exception class.
264 ///
265 /// proj_tree_builder specific exceptions.
266 
268 {
269 public:
270  enum EErrCode {
279  };
280  virtual const char* GetErrCodeString(void) const override {
281  switch ( GetErrCode() ) {
282  case eFileCreation:
283  return "Can not create file";
284  case eEnumValue:
285  return "Bad or missing enum value";
286  case eFileOpen:
287  return "Can not open file";
288  case eProjectType:
289  return "Unknown project type";
290  case eBuildConfiguration:
291  return "Unknown build configuration";
292  case eMetaMakefile:
293  return "Bad or missed metamakefile";
295  return "Path to configure defines file is empty";
296  case eUnknownProjectTag:
297  return "Unregistered project tag";
298  default:
300  }
301  }
303 };
304 
305 
307 
308 #endif //PROJECT_TREE_BULDER__PROJ_BUILDER_APP__HPP
Utility class for distinguish between static and dll builds.
Distribution if source files by lib projects Uses in dll project to separate source files to groups b...
CMsvc7RegSettings –.
CMsvcMetaMakefile –.
CMsvcSite –.
Definition: msvc_site.hpp:131
CProjBulderAppException –.
NCBI_EXCEPTION_DEFAULT(CProjBulderAppException, CException)
virtual const char * GetErrCodeString(void) const override
Get error code interpreted as text.
CProjBulderApp –.
string GetDatatoolId(void) const
unique_ptr< CMsvcSite > m_MsvcSite
set< string > m_Frameworks
unique_ptr< CDllSrcFilesDistr > m_DllSrcFilesDistr
void CreateFeaturesAndPackagesFiles(const list< SConfigInfo > *configs, list< string > &enabled, list< string > &disabled)
virtual void Init(void)
Initialize the application.
void ReportProjectWatchers(void)
void UpdateDepGraph(CProjectTreeBuilder::TFiles &files)
void GetBuildConfigs(list< SConfigInfo > *configs)
bool IsAllowedProjectTag(const CProjItem &project, const string *filter=NULL) const
void ParseArguments(void)
Parse program arguments.
void AddCustomMetaData(const string &file)
const CBuildType & GetBuildType(void)
bool InsertDep(vector< set< string > > &graph, const string &dep, list< string > &done)
string GetBuildDir(void)
CSimpleMakeFileContents m_CustomConfiguration
bool FindDepGraph(const string &root, list< string > &found) const
bool Gui_ConfirmProjects(CProjectItemsTree &projects_tree)
Definition: ptb_gui.cpp:220
friend CProjBulderApp & GetApp(void)
Singleton.
unique_ptr< CProjectItemsTree > m_WholeTree
list< string > m_AbsDirs
map< string, string > m_CompositeProjectTags
void GenerateUnixProjects(CProjectItemsTree &projects_tree)
string GetDatatoolPathForLib(void) const
virtual void Exit(void)
Cleanup on application exit.
const CProjectItemsTree * GetCurrentBuildTree(void) const
void GetCustomConfH(list< string > *files) const
int EnumOpt(const string &enum_name, const string &enum_val) const
ShortCut for enums.
map< string, list< string > > m_3PartyLibraryOrder
void ReportGeneratedFiles(void)
void GenerateMsvcProjects(CProjectItemsTree &projects_tree)
unique_ptr< SProjectTreeInfo > m_ProjectTreeInfo
string GetDataspecProjId(void) const
map< string, set< string > > m_GraphDepIncludes
void GenerateMacProjects(CProjectItemsTree &projects_tree)
CDllSrcFilesDistr & GetDllFilesDistr(void)
virtual int Run(void)
Run the application.
unique_ptr< CMsvcMetaMakefile > m_MsvcMetaMakefile
void CollectDep(const string &libname, const string &depname)
set< string > m_RegisteredProjectTags
const CMsvcMetaMakefile & GetMetaMakefile(void)
string GetUtilityProjectsDir(void) const
map< string, size_t > m_GraphDepRank
const CProjectItemsTree * GetIncompleteBuildTree(void) const
list< string > m_CustomConfH
set< string > m_3PartyLibs
string GetDatatoolPathForApp(void) const
void RegisterGeneratedFile(const string &file)
bool ConfirmConfiguration(void)
Definition: ptb_gui.cpp:147
map< string, list< string > > m_LibraryOrder
void GenerateSummary(const list< SConfigInfo > configs, const list< string > &enabled, const list< string > &disabled)
void SetFail(int exit_code=1)
void VerifyArguments(void)
string GetUtilityProjectsSrcDir(void)
void RegisterSuspiciousProject(const CProjKey &proj)
list< string > m_ProjWatchers
void SetConfFileData(const string &src, const string &dest)
void RegisterProjectWatcher(const string &project, const string &dir, const string &watcher)
void ExcludeUnrequestedProjects(CProjectItemsTree &tree) const
void AddCustomConfH(const string &file)
const SProjectTreeInfo & GetProjectTreeInfo(void)
void GetMetaDataFiles(list< string > *files) const
string GetConfigureMacro(string data)
bool UseAbsolutePath(const string &path) const
string ProcessLocationMacros(string data)
const CProjectItemsTree & GetWholeTree(void)
void DumpFiles(const TFiles &files, const string &filename) const
string GetDatatoolCommandLine(void) const
const CMsvc7RegSettings & GetRegSettings(void)
const CProjectItemsTree * m_IncompleteBuildTree
list< string > m_GeneratedFiles
void ExcludeProjectsByTag(CProjectItemsTree &tree) const
unique_ptr< CBuildType > m_BuildType
map< string, set< string > > m_GraphDepFlags
list< string > m_CustomMetaData
void LoadDepGraph(const string &filename)
map< string, CSimpleMakeFileContents > TFiles
const string & GetBuildRoot(void) const
bool IsScanningWholeTree(void) const
set< CProjKey > m_SuspiciousProj
void LoadProjectTags(const string &filename)
unique_ptr< CMsvc7RegSettings > m_MsvcRegSettings
void CreateCheckList(const list< SConfigInfo > *configs, CProjectItemsTree &projects_tree)
map< string, set< string > > m_GraphDepPrecedes
bool Gui_ConfirmConfiguration(void)
Definition: ptb_gui.cpp:165
const string & GetExtSrcRoot(void) const
void CollectLibToLibDependencies(CProjectItemsTree &projects_tree, set< string > &dep, set< string > &visited, CProjectItemsTree::TProjects::const_iterator &lib, CProjectItemsTree::TProjects::const_iterator &lib_dep)
const CMsvcSite & GetSite(void)
const CProjectItemsTree * m_CurrentBuildTree
string GetProjectTreeRoot(void) const
CProjItem –.
Definition: proj_item.hpp:54
CProjKey –.
CProjectItemsTree –.
Definition: proj_tree.hpp:54
CSimpleMakeFileContents –.
char data[12]
Definition: iconv.c:80
#define NULL
Definition: ncbistd.hpp:225
TErrCode GetErrCode(void) const
Get error code.
Definition: ncbiexpt.cpp:453
EErrCode
Error types that an application can generate.
Definition: ncbiexpt.hpp:884
virtual const char * GetErrCodeString(void) const
Get error code interpreted as text.
Definition: ncbiexpt.cpp:444
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
FILE * file
Defines the CNcbiApplication and CAppException classes for creating NCBI applications.
Defines command line argument related classes.
Defines unified interface to application:
Defines classes: CDirEntry, CFile, CDir, CSymLink, CMemoryFile, CFileUtil, CFileLock,...
CProjBulderApp & GetApp(void)
access to App singleton
Abstraction of project tree general information.
Definition: proj_utils.hpp:56
done
Definition: token1.c:1
Modified on Fri Sep 20 14:58:19 2024 by modify_doxy.py rev. 669887