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

Go to the SVN repository for this file.

1 #ifndef PROJECT_TREE_BUILDER_MSVC_SITE__HPP
2 #define PROJECT_TREE_BUILDER_MSVC_SITE__HPP
3 /* $Id: msvc_site.hpp 99237 2023-03-01 16:35:07Z ucko $
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 <set>
33 #include "msvc_prj_utils.hpp"
34 #include "resolver.hpp"
35 #include <corelib/ncbienv.hpp>
37 
38 /////////////////////////////////////////////////////////////////////////////
39 ///
40 /// SLibInfo --
41 ///
42 /// Abstraction of lib description in site.
43 ///
44 /// Provides information about
45 /// additional include dir, library path and libs list.
46 
47 struct SLibInfo
48 {
49  bool valid;
50  list<string> m_IncludeDir;
51  list<string> m_LibDefines;
52  string m_LibPath;
53  string m_BinPath;
54  list<string> m_Libs;
55  list<string> m_StdLibs;
56  list<string> m_Macro;
57  list<string> m_Files;
58  string m_libinfokey;
59  bool m_good;
60 
61  SLibInfo(void)
62  {
63  valid = false;
64  m_good = false;
65  }
67  {
68  valid = info.valid;
69  m_IncludeDir = info.m_IncludeDir;
70  m_LibDefines = info.m_LibDefines;
71  m_LibPath = info.m_LibPath;
72  m_BinPath = info.m_BinPath;
73  m_Libs = info.m_Libs;
74  m_StdLibs = info.m_StdLibs;
75  m_Macro = info.m_Macro;
76  m_Files = info.m_Files;
77  m_libinfokey = info.m_libinfokey;
78  m_good = info.m_good;
79  }
81  {
82  valid = info.valid;
83  m_IncludeDir = info.m_IncludeDir;
84  m_LibDefines = info.m_LibDefines;
85  m_LibPath = info.m_LibPath;
86  m_BinPath = info.m_BinPath;
87  m_Libs = info.m_Libs;
88  m_StdLibs = info.m_StdLibs;
89  m_Macro = info.m_Macro;
90  m_Files = info.m_Files;
91  m_libinfokey = info.m_libinfokey;
92  m_good = info.m_good;
93  return *this;
94  }
95  bool IsEmpty(void) const
96  {
97  return valid &&
98  m_IncludeDir.empty() &&
99  m_LibDefines.empty() &&
100  m_LibPath.empty() &&
101  m_BinPath.empty() &&
102  m_Libs.empty() &&
103  m_StdLibs.empty() &&
104  m_Macro.empty() &&
105  m_Files.empty();
106  }
107  void Clear(void)
108  {
109  valid = false;
110  m_IncludeDir.clear();
111  m_LibDefines.clear();
112  m_LibPath.erase();
113  m_BinPath.erase();
114  m_Libs.clear();
115  m_StdLibs.clear();
116  m_Macro.clear();
117  m_Files.clear();
118  }
119 };
120 
121 /////////////////////////////////////////////////////////////////////////////
122 ///
123 /// CMsvcSite --
124 ///
125 /// Abstraction of user site for building of C++ projects.
126 ///
127 /// Provides information about libraries availability as well as implicit
128 /// exclusion of some branches from project tree.
129 
131 {
132 public:
133  CMsvcSite(const string& reg_path);
134 
135  void InitializeLibChoices(void);
136  // Is REQUIRES provided?
137  bool IsProvided(const string& thing, bool deep=true, const SConfigInfo* cfg = nullptr) const;
138 
139  bool IsBanned(const string& thing) const;
140 
141  /// Get components from site
142  void GetComponents(const string& entry, list<string>* components) const;
143 
144  /// Is section present in site registry?
145  bool IsDescribed(const string& section) const;
146 
147  string ProcessMacros(string data, bool preserve_unresolved=true) const;
148  // Get library (LIBS) description
149  void GetLibInfo(const string& lib,
150  const SConfigInfo& config, SLibInfo* libinfo) const;
151  // Is this lib available in certain config
152  bool IsLibEnabledInConfig(const string& lib,
153  const SConfigInfo& config) const;
154 
155  // Resolve define (now from CPPFLAGS)
156  bool ResolveDefine(const string& define, string& resolved) const;
157 
158  // Configure related:
159  // Path from tree root to file where configure defines must be.
160  string GetConfigureDefinesPath(void) const;
161  // What we have to define:
162  void GetConfigureDefines (list<string>* defines) const;
163 
164  void CollectRequires(const list<string>& reqs) const;
165  void GetRequiresInfo(const SConfigInfo& config, list<string>& list_enabled, list<string>& list_disabled) const;
166 
167  // Lib Choices related:
168  enum ELibChoice {
171  e3PartyLib
172  };
173  struct SLibChoice
174  {
175  SLibChoice(void);
176 
177  SLibChoice(const CMsvcSite& site,
178  const string& lib,
179  const string& lib_3party);
180 
182  string m_LibId;
183  string m_3PartyLib;
184  };
185  bool IsLibWithChoice (const string& lib_id) const;
186  bool Is3PartyLib (const string& lib_id) const;
187  bool Is3PartyLibWithChoice (const string& lib3party_id) const;
188 
189  ELibChoice GetChoiceForLib (const string& lib_id) const;
190  ELibChoice GetChoiceFor3PartyLib(const string& lib3party_id,
191  const SConfigInfo& cfg_info) const;
192 
193  void GetLibChoiceIncludes(const string& cpp_flags_define,
194  list<string>* abs_includes) const;
195  void GetLibChoiceIncludes(const string& cpp_flags_define,
196  const SConfigInfo& cfg_info,
197  list<string>* abs_includes) const;
198  void GetLibInclude(const string& lib_id,
199  const SConfigInfo& cfg_info,
200  list<string>* includes) const;
201 
202  SLibChoice GetLibChoiceForLib (const string& lib_id) const;
203  SLibChoice GetLibChoiceFor3PartyLib (const string& lib3party_id) const;
204 
205 
206 
207  string GetAppDefaultResource(void) const;
208 
209 
210  void GetThirdPartyLibsToInstall (list<string>* libs) const;
211  string GetThirdPartyLibsBinPathSuffix(void) const;
212  string GetThirdPartyLibsBinSubDir (void) const;
213  void SetThirdPartyLibBin(const string& lib, const string& bin);
214  string GetThirdPartyLibBin(const string& lib) const;
215 
216  void GetStandardFeatures (list<string>& features) const;
217  void GetConfigurableRequests (list<string>& features) const;
218 
219  void ProcessMacros (const list<SConfigInfo>& configs);
220  const CSymResolver& GetMacros(void) const
221  {
222  return m_Macros;
223  }
224 
225  bool IsLibOk(const SLibInfo& lib_info, bool silent = false) const;
226 
227  static string ToOSPath(const string& path);
228 
229  string GetConfigureEntry(const string& entry) const;
230  string GetDefinesEntry(const string& entry) const;
231  string GetPlatformInfo(const string& sysname,
232  const string& type, const string& orig) const;
233  bool IsCppflagDescribed(const string& value) const;
234 
235 private:
236  string m_RegPath;
239 
243 
244  list<SLibChoice> m_LibChoices;
245 
249 
250  /// cache of directories and their existence
253  static bool x_DirExists(const string& dir_name);
254  string x_GetConfigureEntry(const string& entry) const;
255  string x_GetDefinesEntry(const string& entry) const;
256 
257  /// Prohibited to:
258  CMsvcSite(void);
261 };
262 
264 
265 #endif //PROJECT_TREE_BUILDER_MSVC_SITE__HPP
CMsvcSite –.
Definition: msvc_site.hpp:131
ELibChoice GetChoiceForLib(const string &lib_id) const
Definition: msvc_site.cpp:552
CMsvcSite & operator=(const CMsvcSite &)
bool IsDescribed(const string &section) const
Is section present in site registry?
Definition: msvc_site.cpp:282
map< string, bool > TDirectoryExistenceMap
cache of directories and their existence
Definition: msvc_site.hpp:251
bool IsLibWithChoice(const string &lib_id) const
Definition: msvc_site.cpp:485
void GetLibInclude(const string &lib_id, const SConfigInfo &cfg_info, list< string > *includes) const
Definition: msvc_site.cpp:641
CSymResolver m_Macros
Definition: msvc_site.hpp:246
void SetThirdPartyLibBin(const string &lib, const string &bin)
Definition: msvc_site.cpp:714
static TDirectoryExistenceMap sm_DirExists
Definition: msvc_site.hpp:252
map< string, SLibInfo > m_AllLibInfo
Definition: msvc_site.hpp:247
string GetThirdPartyLibBin(const string &lib) const
Definition: msvc_site.cpp:719
void GetStandardFeatures(list< string > &features) const
Definition: msvc_site.cpp:727
CSimpleMakeFileContents m_UnixMakeDef
Definition: msvc_site.hpp:238
CMsvcSite(void)
Prohibited to:
CPtbRegistry m_Registry
Definition: msvc_site.hpp:237
string GetThirdPartyLibsBinSubDir(void) const
Definition: msvc_site.cpp:709
bool IsLibEnabledInConfig(const string &lib, const SConfigInfo &config) const
Definition: msvc_site.cpp:393
string GetAppDefaultResource(void) const
Definition: msvc_site.cpp:689
CMsvcSite(const CMsvcSite &)
void CollectRequires(const list< string > &reqs) const
Definition: msvc_site.cpp:469
set< string > m_NotProvidedThing
Definition: msvc_site.hpp:241
SLibChoice GetLibChoiceFor3PartyLib(const string &lib3party_id) const
Definition: msvc_site.cpp:678
map< string, string > m_ThirdPartyLibBin
Definition: msvc_site.hpp:248
string x_GetDefinesEntry(const string &entry) const
Definition: msvc_site.cpp:775
string GetDefinesEntry(const string &entry) const
Definition: msvc_site.cpp:757
void GetThirdPartyLibsToInstall(list< string > *libs) const
Definition: msvc_site.cpp:695
string GetPlatformInfo(const string &sysname, const string &type, const string &orig) const
Definition: msvc_site.cpp:788
bool IsLibOk(const SLibInfo &lib_info, bool silent=false) const
Definition: msvc_site.cpp:826
static string ToOSPath(const string &path)
Definition: msvc_site.cpp:978
string x_GetConfigureEntry(const string &entry) const
Definition: msvc_site.cpp:762
string GetConfigureDefinesPath(void) const
Definition: msvc_site.cpp:456
string ProcessMacros(string data, bool preserve_unresolved=true) const
Definition: msvc_site.cpp:297
void GetRequiresInfo(const SConfigInfo &config, list< string > &list_enabled, list< string > &list_disabled) const
Definition: msvc_site.cpp:474
bool IsProvided(const string &thing, bool deep=true, const SConfigInfo *cfg=nullptr) const
Definition: msvc_site.cpp:203
set< string > m_ProvidedThing
Definition: msvc_site.hpp:240
void GetLibInfo(const string &lib, const SConfigInfo &config, SLibInfo *libinfo) const
Definition: msvc_site.cpp:333
list< SLibChoice > m_LibChoices
Definition: msvc_site.hpp:244
bool IsCppflagDescribed(const string &value) const
Definition: msvc_site.cpp:805
ELibChoice GetChoiceFor3PartyLib(const string &lib3party_id, const SConfigInfo &cfg_info) const
Definition: msvc_site.cpp:563
bool ResolveDefine(const string &define, string &resolved) const
Definition: msvc_site.cpp:418
string GetThirdPartyLibsBinPathSuffix(void) const
Definition: msvc_site.cpp:704
static bool x_DirExists(const string &dir_name)
Definition: msvc_site.cpp:742
bool Is3PartyLib(const string &lib_id) const
Definition: msvc_site.cpp:495
void InitializeLibChoices(void)
Definition: msvc_site.cpp:143
set< string > m_Requires
Definition: msvc_site.hpp:242
void GetConfigureDefines(list< string > *defines) const
Definition: msvc_site.cpp:462
const CSymResolver & GetMacros(void) const
Definition: msvc_site.hpp:220
string GetConfigureEntry(const string &entry) const
Definition: msvc_site.cpp:753
void GetComponents(const string &entry, list< string > *components) const
Get components from site.
Definition: msvc_site.cpp:290
bool Is3PartyLibWithChoice(const string &lib3party_id) const
Definition: msvc_site.cpp:506
void GetLibChoiceIncludes(const string &cpp_flags_define, list< string > *abs_includes) const
Definition: msvc_site.cpp:582
bool IsBanned(const string &thing) const
Definition: msvc_site.cpp:276
void GetConfigurableRequests(list< string > &features) const
Definition: msvc_site.cpp:734
string m_RegPath
Definition: msvc_site.hpp:236
SLibChoice GetLibChoiceForLib(const string &lib_id) const
Definition: msvc_site.cpp:666
CSimpleMakeFileContents –.
static int silent
Definition: done_handling.c:30
char data[12]
Definition: iconv.c:80
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
where boath are integers</td > n< td ></td > n</tr > n< tr > n< td > tse</td > n< td > optional</td > n< td > String</td > n< td class=\"description\"> TSE option controls what blob is orig
static MDB_envinfo info
Definition: mdb_load.c:37
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
ESERV_Site site
Defines unified interface to application:
SConfigInfo –.
SLibInfo –.
Definition: msvc_site.hpp:48
string m_libinfokey
Definition: msvc_site.hpp:58
list< string > m_IncludeDir
Definition: msvc_site.hpp:50
bool IsEmpty(void) const
Definition: msvc_site.hpp:95
bool valid
Definition: msvc_site.hpp:49
list< string > m_Libs
Definition: msvc_site.hpp:54
list< string > m_StdLibs
Definition: msvc_site.hpp:55
string m_BinPath
Definition: msvc_site.hpp:53
SLibInfo(void)
Definition: msvc_site.hpp:61
void Clear(void)
Definition: msvc_site.hpp:107
SLibInfo & operator=(const SLibInfo &info)
Definition: msvc_site.hpp:80
SLibInfo(const SLibInfo &info)
Definition: msvc_site.hpp:66
list< string > m_LibDefines
Definition: msvc_site.hpp:51
bool m_good
Definition: msvc_site.hpp:59
list< string > m_Macro
Definition: msvc_site.hpp:56
list< string > m_Files
Definition: msvc_site.hpp:57
string m_LibPath
Definition: msvc_site.hpp:52
Definition: type.c:6
Modified on Wed Jul 17 13:21:18 2024 by modify_doxy.py rev. 669887