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

Go to the SVN repository for this file.

1 /* $Id: msvc_site.cpp 99237 2023-03-01 16:35:07Z ucko $
2  * ===========================================================================
3  *
4  * PUBLIC DOMAIN NOTICE
5  * National Center for Biotechnology Information
6  *
7  * This software/database is a "United States Government Work" under the
8  * terms of the United States Copyright Act. It was written as part of
9  * the author's official duties as a United States Government employee and
10  * thus cannot be copyrighted. This software/database is freely available
11  * to the public for use. The National Library of Medicine and the U.S.
12  * Government have not placed any restriction on its use or reproduction.
13  *
14  * Although all reasonable efforts have been taken to ensure the accuracy
15  * and reliability of the software and data, the NLM and the U.S.
16  * Government do not and cannot warrant the performance or results that
17  * may be obtained by using this software or data. The NLM and the U.S.
18  * Government disclaim all warranties, express or implied, including
19  * warranties of performance, merchantability or fitness for any particular
20  * purpose.
21  *
22  * Please cite the author in any work or product based on this material.
23  *
24  * ===========================================================================
25  *
26  * Author: Viatcheslav Gorelenkov
27  *
28  */
29 
30 #include <ncbi_pch.hpp>
31 #include "stl_msvc_usage.hpp"
32 #include "msvc_site.hpp"
33 #include "proj_builder_app.hpp"
34 #include "proj_tree_builder.hpp"
35 #include "msvc_prj_defines.hpp"
36 #include "ptb_err_codes.hpp"
37 
38 #include <algorithm>
39 
40 #include <corelib/ncbistr.hpp>
41 
43 
45 
46 
47 //-----------------------------------------------------------------------------
48 CMsvcSite::CMsvcSite(const string& reg_path)
49 {
50  m_RegPath = reg_path;
51  CNcbiIfstream istr(reg_path.c_str(), IOS_BASE::in | IOS_BASE::binary);
52  m_Registry.Read(istr);
53 
54  string str;
55 
57  // MSWin
58  // Provided requests
59  str = x_GetConfigureEntry("ProvidedRequests");
60  list<string> provided;
62  ITERATE (list<string>, it, provided) {
64  }
65  if (GetApp().GetBuildType().GetType() == CBuildType::eDll) {
66  m_ProvidedThing.insert("DLL");
67  }
68 
70  ITERATE (list<string>, it, provided) {
72  }
73 
74  // Not provided requests
75  str = x_GetConfigureEntry("NotProvidedRequests");
76  if (!str.empty()) {
77  list<string> not_provided;
79  ITERATE (list<string>, it, not_provided) {
81  }
82  }
83  // to override project_tree_builder.ini
84  // in env: NCBI_CONFIG__CONFIGURE__NOTPROVIDED=x,y
85  str = g_GetConfigString("Configure", "NotProvided", nullptr, nullptr);
86  if (!str.empty()) {
87  list<string> not_provided;
89  ITERATE (list<string>, it, not_provided) {
91  }
92  }
93 
94  string unix_cfg = m_Registry.Get("ProjectTree","MetaData");
95  if (!unix_cfg.empty()) {
96  string fileloc;
98  GetApp().m_Root,
99  GetApp().GetConfig().Get("ProjectTree", "src")),
100  CDirEntry::ConvertToOSPath(unix_cfg));
101  if (!CFile(fileloc).Exists() && !GetApp().m_ExtSrcRoot.empty()) {
103  GetApp().m_ExtSrcRoot,
104  GetApp().GetConfig().Get("ProjectTree", "src")),
105  CDirEntry::ConvertToOSPath(unix_cfg));
106  }
107  if (CFile(fileloc).Exists()) {
110  }
111  }
112  } else {
113  // unix
114  string unix_cfg = m_Registry.Get(CMsvc7RegSettings::GetMsvcSection(),"MetaData");
115  if (!unix_cfg.empty()) {
116  string fileloc;
117  if (!GetApp().m_BuildRoot.empty()) {
118  fileloc = CDirEntry::ConcatPath(GetApp().m_BuildRoot,unix_cfg);
119  }
120  if (fileloc.empty() || !CFile(fileloc).Exists()) {
121  fileloc = CDirEntry::ConcatPath( CDirEntry(GetApp().m_Solution).GetDir(),unix_cfg);
122  }
123  if (CFile(fileloc).Exists()) {
126  }
127  }
128 
129  CDir status_dir(GetApp().m_StatusDir);
130  CDir::TEntries files = status_dir.GetEntries("*.enabled");
131  ITERATE(CDir::TEntries, f, files) {
132  string name = (*f)->GetBase();
133  if (name[0] == '-') {
134  name = name.substr(1);
136  } else {
137  m_ProvidedThing.insert(name);
138  }
139  }
140  }
141 }
142 
144 {
145  string str;
146 
147  str = x_GetConfigureEntry("ComponentChoices");
148  list<string> comp_choices;
150 
152  // special cases
153  ITERATE(list<string>, p, comp_choices) {
154  const string& choice_str = *p;
155  string lib_id;
156  string lib_3party_id;
157  if ( NStr::SplitInTwo(choice_str, "/", lib_id, lib_3party_id) ) {
158  if (IsProvided(lib_3party_id))
159  {
160  m_NotProvidedThing.insert(lib_id);
161  }
162  } else {
164  "ComponentChoices: " << choice_str);
165  }
166  }
167  } else {
168  // unix
169  // special cases
170  ITERATE(list<string>, p, comp_choices) {
171  const string& choice_str = *p;
172  string lib_id;
173  string lib_3party_id;
174  if ( NStr::SplitInTwo(choice_str, "/", lib_id, lib_3party_id) ) {
175  if (IsProvided(lib_id) && IsProvided(lib_3party_id))
176  {
177  m_NotProvidedThing.insert(lib_3party_id);
178  }
179  } else {
181  "ComponentChoices: " << choice_str);
182  }
183  }
184  }
185 
186  // Lib choices
187  str = x_GetConfigureEntry("LibChoices");
188  list<string> lib_choices_list;
190  ITERATE(list<string>, p, lib_choices_list) {
191  const string& choice_str = *p;
192  string lib_id;
193  string lib_3party_id;
194  if ( NStr::SplitInTwo(choice_str, "/", lib_id, lib_3party_id) ) {
195  m_LibChoices.push_back(SLibChoice(*this, lib_id, lib_3party_id));
196  } else {
198  "Invalid LibChoices definition: " << choice_str);
199  }
200  }
201 }
202 
203 bool CMsvcSite::IsProvided(const string& thing, bool deep, const SConfigInfo* cfg) const
204 {
205  if (thing.empty()) {
206  return true;
207  }
208  if (thing[0] == '-') {
209  return !IsProvided( thing.c_str() + 1, deep);
210  }
211  if ( m_NotProvidedThing.find(thing) != m_NotProvidedThing.end() ) {
212  return false;
213  }
214  if ( m_ProvidedThing.find(thing) != m_ProvidedThing.end() ) {
215  return true;
216  }
217  if (!deep) {
218  string section("__EnabledUserRequests");
219  if (GetApp().m_CustomConfiguration.DoesValueContain(
220  section, thing, false)) {
221  return true;
222  }
223  bool env = g_GetConfigFlag(section.c_str(), thing.c_str(), NULL, false);
224  if (env) {
225  string value;
227  if (!value.empty()) {
228  value += " ";
229  }
230  value += thing;
232  return true;
233  }
234  return false;
235  }
236 
237  bool res =
239  IsDescribed(thing) : false;
240  if ( res) {
241  list<string> components;
242  GetComponents(thing, &components);
243  if (components.empty()) {
244  components.push_back(thing);
245  }
246  if (cfg != nullptr) {
247  res = true;
248  ITERATE(list<string>, p, components) {
249  const string& component = *p;
250  SLibInfo lib_info;
251  GetLibInfo(component, *cfg, &lib_info);
252  res = IsLibOk(lib_info);
253  }
254  } else {
255  // in at least one configuration all components must be ok
256  ITERATE(list<SConfigInfo>, config , GetApp().GetRegSettings().m_ConfigInfo) {
257  res = true;
258  ITERATE(list<string>, p, components) {
259  const string& component = *p;
260  SLibInfo lib_info;
261  GetLibInfo(component, *config, &lib_info);
262  res = IsLibOk(lib_info);
263  if ( !res ) {
264  break;
265  }
266  }
267  if (res) {
268  break;
269  }
270  }
271  }
272  }
273  return res;
274 }
275 
276 bool CMsvcSite::IsBanned(const string& thing) const
277 {
278  return !thing.empty() &&
280 }
281 
282 bool CMsvcSite::IsDescribed(const string& section) const
283 {
284  return m_Registry.HasEntry(section) ||
285  m_Registry.HasEntry(section + "." +
287 }
288 
289 
290 void CMsvcSite::GetComponents(const string& entry,
291  list<string>* components) const
292 {
293  components->clear();
294  NStr::Split(m_Registry.Get(entry, "Component"), " ,\t", *components, NStr::fSplit_MergeDelimiters | NStr::fSplit_Truncate);
295 }
296 
297 string CMsvcSite::ProcessMacros(string raw_data, bool preserve_unresolved) const
298 {
299  string data(raw_data), raw_macro, macro, definition;
300  string::size_type start, end, done = 0;
301  while ((start = data.find("$(", done)) != string::npos) {
302  end = data.find(")", start);
303  if (end == string::npos) {
305  "Malformatted macro definition: " + raw_data);
306  return data;
307  }
308  raw_macro = data.substr(start,end-start+1);
309  if (CSymResolver::IsDefine(raw_macro)) {
310  macro = CSymResolver::StripDefine(raw_macro);
311  if (macro == "incdir") {
312  definition = GetApp().m_IncDir;
313  } else if (macro == "rootdir") {
314  definition = GetApp().GetProjectTreeInfo().m_Root;
315  } else {
316  if (!GetApp().m_CustomConfiguration.GetValue(macro,definition)) {
317  definition = x_GetConfigureEntry(macro);
318  }
319  }
320  if (definition.empty() && preserve_unresolved) {
321  // preserve unresolved macros
322  done = end;
323  } else {
324  data = NStr::Replace(data, raw_macro, definition);
325  }
326  } else {
328  }
329  }
330  return data;
331 }
332 
333 void CMsvcSite::GetLibInfo(const string& lib,
334  const SConfigInfo& config, SLibInfo* libinfo) const
335 {
336  string libinfokey(lib + "|" + config.GetConfigFullName());
338  li = m_AllLibInfo.find(libinfokey);
339  if (li != m_AllLibInfo.end()) {
340  *libinfo = li->second;
341  return;
342  }
343 
344  string section(lib);
346  section += '.';
348  if (!IsDescribed(section)) {
349  section = lib;
350  }
351  }
352  libinfo->Clear();
353  libinfo->valid = IsDescribed(section);
354  if (!libinfo->valid) {
355  libinfo->valid = IsProvided(lib, false);
356  } else {
357  string include_str = ToOSPath(
358  ProcessMacros(GetOpt(m_Registry, section, "INCLUDE", config),false));
360 
361  string defines_str = GetOpt(m_Registry, section, "DEFINES", config);
363 
364  libinfo->m_LibPath = ToOSPath(
365  ProcessMacros(GetOpt(m_Registry, section, "LIBPATH", config),false));
366  libinfo->m_BinPath = ToOSPath(
367  ProcessMacros(GetOpt(m_Registry, section, "BINPATH", config),false));
368 
369  string libs_str = GetOpt(m_Registry, section, "LIB", config);
371 
372  libs_str = GetOpt(m_Registry, section, "STDLIB", config);
374 
375  string macro_str = GetOpt(m_Registry, section, "MACRO", config);
377 
378  string files_str = ProcessMacros(GetOpt(m_Registry, section, "FILES", config),false);
379  list<string> tmp;
381  ITERATE( list<string>, f, tmp) {
382  libinfo->m_Files.push_back( ToOSPath(*f));
383  }
384  }
385 
386  libinfo->m_libinfokey = libinfokey;
387  libinfo->m_good = IsLibOk(*libinfo);
388  PTB_INFO("Component " << libinfokey << ": " << (libinfo->m_good ? "good" : "bad"));
390 }
391 
392 
393 bool CMsvcSite::IsLibEnabledInConfig(const string& lib,
394  const SConfigInfo& config) const
395 {
396  string section(lib);
398  section += '.';
400  }
401  if (!m_Registry.HasEntry(section)) {
402  return true;
403  }
404  string enabled_configs_str = m_Registry.Get(section, "CONFS");
405  if (enabled_configs_str.empty()) {
406  return true;
407  }
408  list<string> enabled_configs;
409  NStr::Split(enabled_configs_str,
411 
412  return find(enabled_configs.begin(),
413  enabled_configs.end(),
414  config.m_Name) != enabled_configs.end();
415 }
416 
417 
418 bool CMsvcSite::ResolveDefine(const string& define, string& resolved) const
419 {
421  if (m_UnixMakeDef.GetValue(define,resolved)) {
422  return true;
423  }
424  }
425 // resolved = m_Registry.Get("Defines", define);
426  resolved = x_GetDefinesEntry(define);
427  if (resolved.empty()) {
428  if (m_Registry.HasEntry("Defines", define)) {
429  return true;
430  }
432  if (m_UnixMakeDef.GetValue(define,resolved)) {
433  list<string> lst, res;
435  ITERATE(list<string>, l, lst) {
438  if (!resolved.empty()) {
439  res.push_back(resolved);
440  continue;
441  }
442  }
443  res.push_back(*l);
444  }
445  resolved = NStr::Join(res, " ");
446  return true;
447  }
448  }
449  return false;
450  }
451  resolved = ProcessMacros(resolved);
452  return true;
453 }
454 
455 
457 {
458  return x_GetConfigureEntry("DefinesPath");
459 }
460 
461 
462 void CMsvcSite::GetConfigureDefines(list<string>* defines) const
463 {
464  defines->clear();
467 }
468 
469 void CMsvcSite::CollectRequires(const list<string>& reqs) const
470 {
471  m_Requires.insert(reqs.begin(), reqs.end());
472 }
473 
474 void CMsvcSite::GetRequiresInfo(const SConfigInfo& config, list<string>& list_enabled, list<string>& list_disabled) const
475 {
476  for (const string& req : m_Requires) {
477  if ( (IsProvided(req, true, &config) || IsProvided(req, false, &config)) && IsLibEnabledInConfig(req, config)) {
478  list_enabled.push_back(req);
479  } else {
480  list_disabled.push_back(req);
481  }
482  }
483 }
484 
485 bool CMsvcSite::IsLibWithChoice(const string& lib_id) const
486 {
487  ITERATE(list<SLibChoice>, p, m_LibChoices) {
488  const SLibChoice& choice = *p;
489  if (lib_id == choice.m_LibId)
490  return true;
491  }
492  return false;
493 }
494 
495 bool CMsvcSite::Is3PartyLib(const string& lib_id) const
496 {
497  ITERATE(list<SLibChoice>, p, m_LibChoices) {
498  const SLibChoice& choice = *p;
499  if (lib_id == choice.m_LibId) {
500  return choice.m_Choice == e3PartyLib;
501  }
502  }
503  return false;
504 }
505 
506 bool CMsvcSite::Is3PartyLibWithChoice(const string& lib3party_id) const
507 {
508  ITERATE(list<SLibChoice>, p, m_LibChoices) {
509  const SLibChoice& choice = *p;
510  if (lib3party_id == choice.m_3PartyLib)
511  return true;
512  }
513  return false;
514 }
515 
516 
518  :m_Choice(eUnknown)
519 {
520 }
521 
522 
524  const string& lib,
525  const string& lib_3party)
526  :m_LibId (lib),
527  m_3PartyLib(lib_3party)
528 {
531  // special case: lzo is always 3rd party lib
532  if (lib == "lzo") {
533  return;
534  }
535  ITERATE(list<SConfigInfo>, p, GetApp().GetRegSettings().m_ConfigInfo) {
536  const SConfigInfo& config = *p;
537  SLibInfo lib_info;
538  site.GetLibInfo(m_3PartyLib, config, &lib_info);
539 
540  if ( !site.IsLibOk(lib_info) ) {
541  m_Choice = eLib;
542  break;
543  }
544  }
545  } else {
546  m_Choice = site.IsProvided(lib_3party) ? e3PartyLib : eLib;
547  }
548  PTB_INFO("LibChoice " << lib << "/" << lib_3party << " = " << (m_Choice == e3PartyLib ? lib_3party : lib));
549 }
550 
551 
553 {
554  ITERATE(list<SLibChoice>, p, m_LibChoices) {
555 
556  const SLibChoice& choice = *p;
557  if (choice.m_LibId == lib_id)
558  return choice.m_Choice;
559  }
560  return eUnknown;
561 }
562 
564  const string& lib3party_id, const SConfigInfo& cfg_info) const
565 {
566  ITERATE(list<SLibChoice>, p, m_LibChoices) {
567  const SLibChoice& choice = *p;
568  if (choice.m_3PartyLib == lib3party_id) {
569  if (GetApp().GetBuildType().GetType() == CBuildType::eDll) {
570  return choice.m_Choice;
571  } else {
572  SLibInfo lib_info;
573  GetLibInfo(lib3party_id, cfg_info, &lib_info);
574  return IsLibOk(lib_info,true) ? e3PartyLib : eLib;
575  }
576  }
577  }
578  return eUnknown;
579 }
580 
581 
583  const string& cpp_flags_define, list<string>* abs_includes) const
584 {
585  abs_includes->clear();
586 
587  string include_str = m_Registry.Get("LibChoicesIncludes",
588  cpp_flags_define);
589  if (!include_str.empty()) {
590  abs_includes->push_back("$(" + cpp_flags_define + ")");
591  }
592 }
593 
595  const string& cpp_flags_define, const SConfigInfo& cfg_info,
596  list<string>* abs_includes) const
597 {
598  abs_includes->clear();
599  string include_str = m_Registry.Get("LibChoicesIncludes",
600  cpp_flags_define);
601  //split on parts
602  list<string> parts;
604 
605  string lib_id;
606  ITERATE(list<string>, p, parts) {
607  if ( lib_id.empty() )
608  lib_id = *p;
609  else {
610  SLibChoice choice = GetLibChoiceForLib(lib_id);
611  SLibInfo lib_info;
612  GetLibInfo(choice.m_3PartyLib, cfg_info, &lib_info);
613  bool b3;
614  if (GetApp().GetBuildType().GetType() == CBuildType::eDll) {
615  b3 = choice.m_Choice == e3PartyLib;
616  if (lib_id == "lzo") {
617  b3 = IsLibOk(lib_info, true);
618  }
619  } else {
620  b3 = IsLibOk(lib_info, true);
621  }
622  if (b3) {
623  copy(lib_info.m_IncludeDir.begin(),
624  lib_info.m_IncludeDir.end(), back_inserter(*abs_includes));
625  } else {
626  const string& rel_include_path = *p;
627  if (*p != ".") {
628  string abs_include_path =
630  abs_include_path =
631  CDirEntry::ConcatPath(abs_include_path, rel_include_path);
632  abs_include_path = CDirEntry::NormalizePath(abs_include_path);
633  abs_includes->push_back(abs_include_path);
634  }
635  }
636  lib_id.erase();
637  }
638  }
639 }
640 
641 void CMsvcSite::GetLibInclude(const string& lib_id,
642  const SConfigInfo& cfg_info, list<string>* includes) const
643 {
644  includes->clear();
645  if (CSymResolver::IsDefine(lib_id)) {
646  GetLibChoiceIncludes( CSymResolver::StripDefine(lib_id), cfg_info, includes);
647  return;
648  }
649  SLibInfo lib_info;
650  GetLibInfo(lib_id, cfg_info, &lib_info);
651  if ( IsLibOk(lib_info, true) ) {
652 // includes->push_back(lib_info.m_IncludeDir);
653  copy(lib_info.m_IncludeDir.begin(),
654  lib_info.m_IncludeDir.end(), back_inserter(*includes));
655  return;
656  } else {
657  if (!lib_info.IsEmpty()) {
659  lib_id << "|" << cfg_info.GetConfigFullName()
660  << " unavailable: library include ignored: "
661  << NStr::Join(lib_info.m_IncludeDir,";"));
662  }
663  }
664 }
665 
667 {
668  ITERATE(list<SLibChoice>, p, m_LibChoices) {
669 
670  const SLibChoice& choice = *p;
671  if (choice.m_LibId == lib_id)
672  return choice;
673  }
674  return SLibChoice();
675 
676 }
677 
679 {
680  ITERATE(list<SLibChoice>, p, m_LibChoices) {
681  const SLibChoice& choice = *p;
682  if (choice.m_3PartyLib == lib3party_id)
683  return choice;
684  }
685  return SLibChoice();
686 }
687 
688 
690 {
691  return m_Registry.Get("DefaultResource", "app");
692 }
693 
694 
695 void CMsvcSite::GetThirdPartyLibsToInstall(list<string>* libs) const
696 {
697  libs->clear();
698 
699  string libs_str = x_GetConfigureEntry("ThirdPartyLibsToInstall");
701 }
702 
703 
705 {
706  return x_GetConfigureEntry("ThirdPartyLibsBinPathSuffix");
707 }
708 
710 {
711  return ToOSPath(x_GetConfigureEntry("ThirdPartyLibsBinSubDir"));
712 }
713 
714 void CMsvcSite::SetThirdPartyLibBin(const string& lib, const string& bin)
715 {
716  m_ThirdPartyLibBin[lib] = bin;
717 }
718 
719 string CMsvcSite::GetThirdPartyLibBin(const string& lib) const
720 {
722  return m_ThirdPartyLibBin.find(lib)->second;
723  }
724  return kEmptyStr;
725 }
726 
727 void CMsvcSite::GetStandardFeatures(list<string>& features) const
728 {
729  features.clear();
730  NStr::Split(x_GetConfigureEntry("StandardFeatures"),
732 }
733 
734 void CMsvcSite::GetConfigurableRequests(list<string>& features) const
735 {
736  features.clear();
737  NStr::Split(x_GetConfigureEntry("ConfigurableRequests"),
739 }
740 
741 //-----------------------------------------------------------------------------
742 bool CMsvcSite::x_DirExists(const string& dir_name)
743 {
745  if (it == sm_DirExists.end()) {
746  bool exists = CDirEntry(dir_name).Exists();
747  it = sm_DirExists.insert
748  (TDirectoryExistenceMap::value_type(dir_name, exists)).first;
749  }
750  return it->second;
751 }
752 
753 string CMsvcSite::GetConfigureEntry(const string& entry) const
754 {
755  return ProcessMacros(x_GetConfigureEntry(entry));
756 }
757 string CMsvcSite::GetDefinesEntry(const string& entry) const
758 {
759  return ProcessMacros(x_GetDefinesEntry(entry));
760 }
761 
762 string CMsvcSite::x_GetConfigureEntry(const string& entry) const
763 {
764  string str;
766  if (str.empty()) {
768  if (str.empty()) {
769  str = m_Registry.Get("Configure", entry);
770  }
771  }
772  return str;
773 }
774 
775 string CMsvcSite::x_GetDefinesEntry(const string& entry) const
776 {
777  string str;
779  if (str.empty()) {
781  if (str.empty()) {
782  str = m_Registry.Get("Defines", entry);
783  }
784  }
785  return str;
786 }
787 
788 string CMsvcSite::GetPlatformInfo(const string& sysname,
789  const string& type, const string& orig) const
790 {
791  string section("PlatformSynonyms_");
792  section += sysname;
793  string str = m_Registry.Get( section, type);
794  string result(orig), syn, res;
795  if (!str.empty() && NStr::SplitInTwo(str, ":", syn, res)) {
796  list< string > entries;
798  if (find(entries.begin(), entries.end(), orig) != entries.end()) {
799  result = res;
800  }
801  }
802  return result;
803 }
804 
805 bool CMsvcSite::IsCppflagDescribed(const string& raw_value) const
806 {
807  if (NStr::StartsWith(raw_value, "-I")) {
808  return true;
809  }
810  if (!CSymResolver::IsDefine(raw_value)) {
811  return false;
812  }
813  string stripped = CSymResolver::StripDefine(FilterDefine(raw_value));
814  string tmp = m_Registry.Get("LibChoicesIncludes", stripped);
815  if (!tmp.empty()) {
816  return true;
817  }
818  tmp = x_GetDefinesEntry(stripped);
819  if (!tmp.empty()) {
820  return true;
821  }
822  return false;
823 }
824 
825 
826 bool CMsvcSite::IsLibOk(const SLibInfo& lib_info, bool silent) const
827 {
829  if (li != m_AllLibInfo.end()) {
830  return lib_info.m_good;
831  }
832  silent = false;
833 
834  if ( !lib_info.valid /*|| lib_info.IsEmpty()*/ )
835  return false;
836 #ifndef PSEUDO_XCODE
837  if ( !lib_info.m_IncludeDir.empty() ) {
838  ITERATE(list<string>, i, lib_info.m_IncludeDir) {
839  if (!x_DirExists(*i) ) {
840  if (!silent) {
842  "INCLUDE path not found");
843  }
844  return false;
845  }
846  }
847  }
848 #endif
849  if ( !lib_info.m_LibPath.empty() &&
850  !x_DirExists(lib_info.m_LibPath) ) {
851  if (!silent) {
853  "LIB path not found");
854  }
855  return false;
856  }
857  if ( !lib_info.m_LibPath.empty()) {
859  ITERATE(list<string>, p, lib_info.m_Libs) {
860  string lib = *p;
861  if (NStr::StartsWith(lib, "-l")) {
862  NStr::ReplaceInPlace(lib, "-l", "lib");
863  string lib_path_abs = CDirEntry::ConcatPath(lib_info.m_LibPath, lib);
864  if ( !lib_path_abs.empty() &&
865  !x_DirExists(lib_path_abs+".a") &&
866  !x_DirExists(lib_path_abs+".dylib") ) {
867  if (!silent) {
868  PTB_WARNING_EX(lib_path_abs, ePTB_PathNotFound,
869  "LIB path not found");
870  }
871  return false;
872  }
873 
874  }
875  }
876  } else {
877  ITERATE(list<string>, p, lib_info.m_Libs) {
878  const string& lib = *p;
879  string lib_path_abs = CDirEntry::ConcatPath(lib_info.m_LibPath, lib);
880  if ( !lib_path_abs.empty() &&
881  !x_DirExists(lib_path_abs) ) {
882  if (!silent) {
883  PTB_WARNING_EX(lib_path_abs, ePTB_PathNotFound,
884  "LIB path not found");
885  }
886  return false;
887  }
888  }
889  }
890  }
891  if ( !lib_info.m_Files.empty()) {
892  bool group_exists = false;
893  ITERATE(list<string>, g, lib_info.m_Files) {
894  list<string> tmp;
896  bool file_exists = true;
897  ITERATE( list<string>, p, tmp) {
898  string file = *p;
900  file = CDirEntry::ConcatPath(GetApp().GetProjectTreeInfo().m_Root, file);
901  }
902  if ( !x_DirExists(file) ) {
903  file_exists = false;
904  if (!GetApp().GetExtSrcRoot().empty()) {
905  file = *p;
907  file = CDirEntry::ConcatPath(GetApp().GetExtSrcRoot(), file);
908  }
909  file_exists = x_DirExists(file);
910  }
911  }
912  if (!file_exists) {
913  if (!silent) {
915  "file not found");
916  }
917  break;
918  }
919  }
920  group_exists = group_exists || file_exists;
921  }
922  if (!group_exists) {
923  return false;
924  }
925  }
926 
927  return true;
928 }
929 
930 void CMsvcSite::ProcessMacros(const list<SConfigInfo>& configs)
931 {
932  list<string> macros;
934 
935  ITERATE(list<string>, m, macros) {
936  const string& macro = *m;
937  if (!IsDescribed(macro)) {
938  // add empty value
939  PTB_ERROR_EX(kEmptyStr,ePTB_MacroUndefined,"Macro " << macro << " is not described");
940  }
941  list<string> components;
942  GetComponents(macro, &components);
943  bool res = false;
944  ITERATE(list<string>, p, components) {
945  const string& component = *p;
947  ITERATE(list<SConfigInfo>, n, configs) {
948  const SConfigInfo& config = *n;
949  SLibInfo lib_info;
950  GetLibInfo(component, config, &lib_info);
951  if ( IsLibOk(lib_info) ) {
952  res = true;
953  } else {
954  if (!lib_info.IsEmpty()) {
955  PTB_WARNING_EX(kEmptyStr, ePTB_MacroUndefined, "Macro " << macro
956  << " cannot be resolved for "
957  << component << "|" << config.GetConfigFullName());
958  }
959 // res = false;
960 // break;
961  }
962  }
963  } else {
964  res = IsProvided(component);
965  if (!res) {
966  break;
967  }
968  }
969  }
970  if (res) {
971  m_Macros.AddDefinition(macro, m_Registry.Get(macro, "Value"));
972  } else {
973  m_Macros.AddDefinition(macro, m_Registry.Get(macro, "DefValue"));
974  }
975  }
976 }
977 
978 string CMsvcSite::ToOSPath(const string& path)
979 {
980  string xpath(path);
981  char separator = CDirEntry::GetPathSeparator();
982 #ifdef PSEUDO_XCODE
983  separator = '/';
984 #endif
985  for (size_t i = 0; i < xpath.length(); i++) {
986  char c = xpath[i];
987  if ( (c == '\\' || c == '/') && c != separator) {
988  xpath[i] = separator;
989  }
990  }
991  return xpath;
992 }
993 
994 
CDirEntry –.
Definition: ncbifile.hpp:262
CDir –.
Definition: ncbifile.hpp:1695
CFile –.
Definition: ncbifile.hpp:1604
static EMsvcPlatform GetMsvcPlatform(void)
static string GetMsvcSection(void)
static string GetMsvcRegSection(void)
CMsvcSite –.
Definition: msvc_site.hpp:131
ELibChoice GetChoiceForLib(const string &lib_id) const
Definition: msvc_site.cpp:552
bool IsDescribed(const string &section) const
Is section present in site registry?
Definition: msvc_site.cpp:282
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
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
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 m_CustomConfiguration
const SProjectTreeInfo & GetProjectTreeInfo(void)
bool HasEntry(const string &section, const string &name=kEmptyStr) const
void Read(CNcbiIstream &is)
string Get(const string &section, const string &name) const
static void LoadFrom(const string &file_path, CSimpleMakeFileContents *fc)
void AddDefinition(const string &key, const string &value)
bool GetValue(const string &key, string &value) const
void SetValueSeparator(const string &sep)
void AddDefinition(const string &key, const string &value)
Definition: resolver.cpp:293
static string StripDefine(const string &define)
Definition: resolver.cpp:75
static bool IsDefine(const string &param)
Definition: resolver.cpp:258
const_iterator end() const
Definition: map.hpp:152
iterator_bool insert(const value_type &val)
Definition: map.hpp:165
const_iterator find(const key_type &key) const
Definition: map.hpp:153
iterator_bool insert(const value_type &val)
Definition: set.hpp:149
const_iterator find(const key_type &key) const
Definition: set.hpp:137
const_iterator end() const
Definition: set.hpp:136
The NCBI C++ standard methods for dealing with std::string.
static int silent
Definition: done_handling.c:30
static const char * str(char *buf, int n)
Definition: stats.c:84
static HENV env
Definition: transaction2.c:38
static char tmp[3200]
Definition: utf8.c:42
char data[12]
Definition: iconv.c:80
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
#define NULL
Definition: ncbistd.hpp:225
static string NormalizePath(const string &path, EFollowLinks follow_links=eIgnoreLinks)
Normalize a path.
Definition: ncbifile.cpp:820
TEntries GetEntries(const string &mask=kEmptyStr, TGetEntriesFlags flags=0) const
Get directory entries based on the specified "mask".
Definition: ncbifile.cpp:3846
static bool IsAbsolutePath(const string &path)
Check if a "path" is absolute for the current OS.
Definition: ncbifile.cpp:508
virtual bool Exists(void) const
Check the entry existence.
Definition: ncbifile.cpp:2325
static string ConvertToOSPath(const string &path)
Convert "path" on any OS to the current OS-dependent path.
Definition: ncbifile.cpp:745
static char GetPathSeparator(void)
Get path separator symbol specific for the current platform.
Definition: ncbifile.cpp:433
static string ConcatPath(const string &first, const string &second)
Concatenate two parts of the path for the current OS.
Definition: ncbifile.cpp:776
list< TEntry > TEntries
Definition: ncbifile.hpp:1750
@ eUnknown
Definition: app_popup.hpp:72
string g_GetConfigString(const char *section, const char *variable, const char *env_var_name, const char *default_value, CParamBase::EParamSource *src=nullptr)
Helper functions for getting values from registry/environment.
Definition: ncbi_param.cpp:397
bool g_GetConfigFlag(const char *section, const char *variable, const char *env_var_name, bool default_value)
Get boolean configuration value.
Definition: ncbi_param.cpp:133
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
IO_PREFIX::ifstream CNcbiIfstream
Portable alias for ifstream.
Definition: ncbistre.hpp:439
#define kEmptyStr
Definition: ncbistr.hpp:123
static list< string > & Split(const CTempString str, const CTempString delim, list< string > &arr, TSplitFlags flags=0, vector< SIZE_TYPE > *token_pos=NULL)
Split a string using specified delimiters.
Definition: ncbistr.cpp:3461
static string Join(const TContainer &arr, const CTempString &delim)
Join strings using the specified delimiter.
Definition: ncbistr.hpp:2697
static string & Replace(const string &src, const string &search, const string &replace, string &dst, SIZE_TYPE start_pos=0, SIZE_TYPE max_replace=0, SIZE_TYPE *num_replace=0)
Replace occurrences of a substring within a string.
Definition: ncbistr.cpp:3314
static bool StartsWith(const CTempString str, const CTempString start, ECase use_case=eCase)
Check if a string starts with a specified prefix value.
Definition: ncbistr.hpp:5412
static bool SplitInTwo(const CTempString str, const CTempString delim, string &str1, string &str2, TSplitFlags flags=0)
Split a string into two pieces using the specified delimiters.
Definition: ncbistr.cpp:3554
static string & ReplaceInPlace(string &src, const string &search, const string &replace, SIZE_TYPE start_pos=0, SIZE_TYPE max_replace=0, SIZE_TYPE *num_replace=0)
Replace occurrences of a substring within a string.
Definition: ncbistr.cpp:3405
@ fSplit_Truncate
Definition: ncbistr.hpp:2501
@ fSplit_Tokenize
All delimiters are merged and trimmed, to get non-empty tokens only.
Definition: ncbistr.hpp:2508
@ fSplit_CanQuote
Definition: ncbistr.hpp:2506
@ fSplit_MergeDelimiters
Merge adjacent delimiters.
Definition: ncbistr.hpp:2498
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
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 provided
FILE * file
int i
yy_size_t n
#define LIST_SEPARATOR_LIBS
#define LIST_SEPARATOR
Separator for list values in registry.
string GetOpt(const CPtbRegistry &registry, const string &section, const string &opt, const string &config)
const TYPE & Get(const CNamedParameterList *param)
constexpr bool empty(list< Ts... >) noexcept
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
ESERV_Site site
std::istream & in(std::istream &in_, double &x_)
void copy(Njn::Matrix< S > *matrix_, const Njn::Matrix< T > &matrix0_)
Definition: njn_matrix.hpp:613
double f(double x_, const double &y_)
Definition: njn_root.hpp:188
CProjBulderApp & GetApp(void)
access to App singleton
#define PTB_ERROR_EX(file, err_code, msg)
#define PTB_INFO(msg)
@ ePTB_FileNotFound
@ ePTB_ConfigurationError
@ ePTB_PathNotFound
@ ePTB_MacroUndefined
#define PTB_WARNING_EX(file, err_code, msg)
string FilterDefine(const string &define)
Definition: resolver.cpp:326
SConfigInfo –.
string GetConfigFullName(void) const
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
void Clear(void)
Definition: msvc_site.hpp:107
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
static bool IsConfigurableDefine(const string &define)
static string StripConfigurableDefine(const string &define)
string m_Root
Root of the project tree.
Definition: proj_utils.hpp:58
string m_Include
branch of tree
Definition: proj_utils.hpp:68
Definition: type.c:6
int g(Seg_Gsm *spe, Seq_Mtf *psm, Thd_Gsm *tdg)
Definition: thrddgri.c:44
done
Definition: token1.c:1
else result
Definition: token2.c:20
static wxAcceleratorEntry entries[3]
Modified on Mon May 20 05:04:59 2024 by modify_doxy.py rev. 669887