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

Go to the SVN repository for this file.

1 /* $Id: proj_builder_app.cpp 100437 2023-07-31 17:44:43Z gouriano $
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 "proj_builder_app.hpp"
32 #include "proj_item.hpp"
33 #include "proj_tree_builder.hpp"
34 #include "msvc_prj_utils.hpp"
35 #include "msvc_prj_generator.hpp"
36 #include "mac_prj_generator.hpp"
37 #include "msvc_sln_generator.hpp"
39 #include "proj_utils.hpp"
40 #include "msvc_configure.hpp"
41 #include "msvc_prj_defines.hpp"
43 #include "proj_projects.hpp"
44 #include "configurable_file.hpp"
45 #include "ptb_err_codes.hpp"
46 #include <corelib/ncbitime.hpp>
47 #include <corelib/expr.hpp>
48 
49 #include <common/test_assert.h> /* This header must go last */
50 
51 
52 // special task
53 #define DO_PATCHTREEMAKEFILES 0
54 
56 
57 
58 /////////////////////////////////////////////////////////////////////////////
59 ///
60 /// Windows-specific command-line logger
61 /// This is used to format error output in such a way that the Windows error
62 /// logger can pick this up
63 
65 {
66 public:
67 
69  {
70  m_OrigHandler.reset(GetDiagHandler(true));
72  if (app) {
74  } else {
75  m_AppName = "unknown_app";
76  }
77  }
78 
80  {
81  }
82 
83  /// post a message
84  void Post(const SDiagMessage& msg)
85  {
86  if (m_OrigHandler.get()) {
87  m_OrigHandler->Post(msg);
88  }
89 
91  if (!msg.m_Buffer) {
92  str.assign(kEmptyStr.c_str(),0);
93  }
94 
95  /// screen for error message level data only
96  /// MSVC doesn't handle the other parts
97  switch (msg.m_Severity) {
98  case eDiag_Error:
99  case eDiag_Critical:
100  case eDiag_Fatal:
101  case eDiag_Warning:
102  break;
103 
104  case eDiag_Info:
105  case eDiag_Trace:
106  if (msg.m_ErrCode == ePTB_NoError) {
107  /// simple pass-through to stderr
108  if (strlen(msg.m_File) != 0) {
109  cerr << msg.m_File << ": ";
110  }
111  cerr << str << endl;
112  return;
113  }
114  break;
115  }
116 
117  /// REQUIRED: origin
118  if (strlen(msg.m_File) == 0) {
119  cerr << m_AppName;
120  } else {
121  cerr << msg.m_File;
122  }
123  if (msg.m_Line) {
124  cerr << "(" << msg.m_Line << ")";
125  }
126  cerr << ": ";
127 
128  /// OPTIONAL: subcategory
129  //cerr << m_AppName << " ";
130 
131  /// REQUIRED: category
132  /// the MSVC system understands only 'error' and 'warning'
133  switch (msg.m_Severity) {
134  case eDiag_Error:
135  case eDiag_Critical:
136  case eDiag_Fatal:
137  cerr << "error ";
138  break;
139 
140  case eDiag_Warning:
141  cerr << "warning ";
142  break;
143 
144  case eDiag_Info:
145  case eDiag_Trace:
146  /// FIXME: find out how to get this in the messages tab
147  cerr << "info ";
148  break;
149  }
150 
151  /// REQUIRED: error code
152  cerr << msg.m_ErrCode << ": ";
153 
154  /// OPTIONAL: text
155  cerr << str << endl;
156  }
157 
158 private:
159  unique_ptr<CDiagHandler> m_OrigHandler;
160 
161  /// the original diagnostics handler
162  string m_AppName;
163 
164 };
165 
166 /////////////////////////////////////////////////////////////////////////////
167 
168 
169 // When defined, this environment variable
170 // instructs PTB to exclude CONFIGURE, INDEX, and HIERARCHICAL VIEW
171 // projects
172 const char* s_ptb_skipconfig = "__PTB__SKIP__CONFIG__";
173 
174 #ifdef COMBINED_EXCLUDE
176 {
178  bool operator() (const TValueType& item) const
179  {
180  const CProjItem& project = item.second;
181  CMsvcPrjProjectContext prj_context(project);
182  const list<string> implicit_exclude_dirs =
184  ITERATE(list<string>, p, implicit_exclude_dirs) {
185  const string& dir = *p;
186  if ( IsSubdir(dir, project.m_SourcesBaseDir) ) {
187  // implicitly excluded from build
188  return prj_context.GetMsvcProjectMakefile().IsExcludeProject
189  (true);
190  }
191  }
192  // implicitly included to build
193  return prj_context.GetMsvcProjectMakefile().IsExcludeProject(false);
194  }
195 };
196 
197 
198 struct PIsExcludedMakefileIn
199 {
200  typedef CProjectItemsTree::TProjects::value_type TValueType;
201 
202  PIsExcludedMakefileIn(const string& root_src_dir)
203  :m_RootSrcDir(CDirEntry::NormalizePath(root_src_dir))
204  {
205  ProcessDir(root_src_dir);
206  }
207 
208  bool operator() (const TValueType& item) const
209  {
210  const CProjItem& project = item.second;
211 
212  const list<string> implicit_exclude_dirs =
214  ITERATE(list<string>, p, implicit_exclude_dirs) {
215  const string& dir = *p;
216  if ( IsSubdir(dir, project.m_SourcesBaseDir) ) {
217  // implicitly excluded from build
218  return !IsExcplicitlyIncluded(project.m_SourcesBaseDir);
219  }
220  }
221  return false;
222  }
223 
224 private:
225  string m_RootSrcDir;
226 
227  typedef map<string, AutoPtr<CPtbRegistry> > TMakefiles;
228  TMakefiles m_Makefiles;
229 
230  void ProcessDir(const string& dir_name)
231  {
232  CDir dir(dir_name);
233  CDir::TEntries contents = dir.GetEntries("*");
234  ITERATE(CDir::TEntries, i, contents) {
235  string name = (*i)->GetName();
236  if ( name == "." || name == ".." ||
237  name == string(1,CDir::GetPathSeparator()) ) {
238  continue;
239  }
240  string path = (*i)->GetPath();
241 
242  if ( (*i)->IsFile() &&
243  name == "Makefile.in.msvc" ) {
244  m_Makefiles[path] =
246  (new CPtbRegistry(CNcbiIfstream(path.c_str(),
247  IOS_BASE::in | IOS_BASE::binary)));
248  }
249  else if ( (*i)->IsDir() ) {
250 
251  ProcessDir(path);
252  }
253  }
254  }
255 
256  bool IsExcplicitlyIncluded(const string& project_base_dir) const
257  {
258  string dir = project_base_dir;
259  for(;;) {
260 
261  if (dir == m_RootSrcDir)
262  return false;
263  string path = CDirEntry::ConcatPath(dir, "Makefile.in.msvc");
264  TMakefiles::const_iterator p =
265  m_Makefiles.find(path);
266  if ( p != m_Makefiles.end() ) {
267  string val =
268  (p->second)->GetString("Common", "ExcludeProject");
269  if (val == "FALSE")
270  return true;
271  }
272 
273  dir = CDirEntry::ConcatPath(dir, "..");
274  dir = CDirEntry::NormalizePath(dir);
275  }
276 
277  return false;
278  }
279 };
280 
281 
282 template <class T1, class T2, class V> class CCombine
283 {
284 public:
285  CCombine(const T1& t1, const T2& t2)
286  :m_T1(t1), m_T2(t2)
287  {
288  }
289  bool operator() (const V& v) const
290  {
291  return m_T1(v) && m_T2(v);
292  }
293 private:
294  const T1 m_T1;
295  const T2 m_T2;
296 };
297 #else
298 // not def COMBINED_EXCLUDE
300 {
302  bool operator() (const TValueType& item) const
303  {
304  const CProjItem& project = item.second;
305  CMsvcPrjProjectContext prj_context(project);
306  const list<string> implicit_exclude_dirs =
308  ITERATE(list<string>, p, implicit_exclude_dirs) {
309  const string& dir = *p;
310  if ( IsSubdir(dir, project.m_SourcesBaseDir) ) {
311  // implicitly excluded from build
312  if (prj_context.GetMsvcProjectMakefile().IsExcludeProject(true)) {
314  "Excluded: project " << project.m_Name
315  << " by ProjectTree/ImplicitExclude");
316  return true;
317  }
318  return false;
319  }
320  }
321  // implicitly included into build
322  if (prj_context.GetMsvcProjectMakefile().IsExcludeProject(false)) {
324  "Excluded: project " << project.m_Name
325  << " by Makefile." << project.m_Name << ".*."
326  << GetApp().GetRegSettings().m_MakefilesExt);
327  return true;
328  }
329  return false;
330  }
331 };
332 
333 #endif
334 
336 {
338  bool operator() (const TValueType& item) const
339  {
340  const CProjItem& project = item.second;
341  string unmet;
342  if ( project.m_ProjType != CProjKey::eDataSpec &&
343  !GetApp().IsAllowedProjectTag(project) ) {
344  string unmet( NStr::Join(project.m_ProjTags,","));
346  "Excluded due to proj_tag; this project tags: " << unmet);
347  return true;
348  }
349  return false;
350  }
351 };
352 
354 {
356  bool operator() (const TValueType& item) const
357  {
358  const CProjItem& project = item.second;
359  if (project.m_ProjType != CProjKey::eDll &&
360  project.m_ProjType != CProjKey::eDataSpec &&
361  !GetApp().m_CustomConfiguration.DoesValueContain(
362  "__AllowedProjects",
363  CreateProjectName(CProjKey(project.m_ProjType, project.m_ID)), true)) {
365  "Excluded by user request");
366  return true;
367  }
368  return false;
369 
370  }
371 };
372 
374 {
376  bool operator() (const TValueType& item) const
377  {
378  string unmet;
379  const CProjItem& project = item.second;
380  if ( !CMsvcPrjProjectContext::IsRequiresOk(project, &unmet) ) {
382  "Excluded due to unmet requirement: "
383  << unmet);
384  return true;
385  }
386  return false;
387 
388  }
389 };
390 
392 {
394  bool operator() (const TValueType& item) const
395  {
396  const CProjItem& project = item.second;
397  if (project.m_External) {
399  "Excluded unused external");
400  return true;
401  }
402  return false;
403  }
404 };
405 
406 
407 //-----------------------------------------------------------------------------
409 {
410  SetVersion( CVersionInfo(4,12,3) );
411  m_ScanningWholeTree = false;
412  m_Dll = false;
413  m_AddMissingLibs = false;
414  m_ScanWholeTree = true;
415  m_TweakVTuneR = false;
416  m_TweakVTuneD = false;
417  m_AddUnicode = false;
418  m_CurrentBuildTree = 0;
420  m_ProjTagCmnd = false;
421  m_ConfirmCfg = false;
422  m_AllDllBuild = false;
423  m_InteractiveCfg = false;
424  m_Dtdep = false;
425  m_AddMissingDep = false;
426  m_LibDep = false;
427  m_Ide = 0;
428  m_ExitCode = 0;
429 }
430 
431 
433 {
434  string logfile = GetLogFile();
435  if (CDirEntry(logfile).Exists()) {
437  }
439  if (logfile != "STDERR") {
441  }
442  }
443  // Create command-line argument descriptions class
444  unique_ptr<CArgDescriptions> arg_desc(new CArgDescriptions);
445 
446  // Specify USAGE context
447  string context;
449  context = "MSVC ";
450 /*
451  context += CMsvc7RegSettings::GetProjectFileFormatVersion() +
452  " (" + CMsvc7RegSettings::GetMsvcPlatformName() + ")";
453 */
455  context = "XCODE ";
456 /*
457  context += CMsvc7RegSettings::GetMsvcVersionName() +
458  " (" + CMsvc7RegSettings::GetMsvcPlatformName() + ")";
459 */
460  } else {
462  }
463  context += " projects tree builder application";
464  arg_desc->SetUsageContext(GetArguments().GetProgramBasename(),context);
465 
466  // Programm arguments:
467 
468  arg_desc->AddPositional("root",
469  "Root directory of the build tree. "\
470  "This directory ends with \"c++\".",
472 
473  arg_desc->AddPositional("subtree",
474  "Subtree, or a file with a list of subtrees to build."\
475  " Examples: src/corelib/ scripts/projects/ncbi_cpp.lst",
477 
478  arg_desc->AddPositional("solution",
479  "MSVC Solution to build.",
481 
482  arg_desc->AddFlag ("dll",
483  "Dll(s) will be built instead of static libraries.",
484  true);
485 
486  arg_desc->AddFlag ("nobuildptb",
487  "Exclude \"build PTB\" step from CONFIGURE project.");
488 
489  arg_desc->AddFlag ("ext",
490  "Use external libraries instead of missing in-tree ones.");
491  arg_desc->AddFlag ("nws",
492  "Do not scan the whole source tree for missing projects.");
493  arg_desc->AddOptionalKey("extroot", "external_build_root",
494  "Subtree in which to look for external libraries.",
496 
497  arg_desc->AddOptionalKey("projtag", "project_tag",
498  "Expression. Include only projects that match."\
499  " Example: \"core && (test || !demo)\"",
501 
502 #if defined(NCBI_XCODE_BUILD) || defined(PSEUDO_XCODE)
503  arg_desc->AddOptionalKey("ide", "xcode_version",
504  "Target version of Xcode, for example: 30",
506  arg_desc->AddOptionalKey("arch", "architecture",
507  "Target architecture, for example: ppc, i386",
509 #elif defined(NCBI_COMPILER_MSVC)
510  arg_desc->AddOptionalKey("ide", "msvc_version",
511  "Target version of MS Visual Studio, for example: 1200, 1400, 1500",
513  arg_desc->AddOptionalKey("arch", "platform",
514  "Target platform, for example: Win32, x64",
516 #endif
517 
518  arg_desc->AddFlag ("cfg",
519  "Show GUI to confirm configuration parameters (MS Windows only).");
520  arg_desc->AddFlag ("i",
521  "Run interactively. Can only be used by PTB GUI shell!");
522  arg_desc->AddFlag ("dtdep",
523  "Add dependency on datatool where needed.");
524  arg_desc->AddFlag ("noadddep",
525  "Do not add missing dependencies.");
526  arg_desc->AddDefaultKey("libdep", "LibraryDependencies",
527  "Analyze dependencies and generate library info for linker on Unix",
529 
530  arg_desc->AddOptionalKey("args", "args_file",
531  "Read arguments from a file",
533 
534  // Setup arg.descriptions for this application
535  SetupArgDescriptions(arg_desc.release());
536 }
537 
538 
539 static
542 {
543  bool reported = false;
545  const CCyclicDepends::TDependsChain& cycle = *p;
546  bool real_cycle = false;
547  string host0, host;
549  host = tree[*m].m_DllHost;
550  if (m == cycle.begin()) {
551  host0 = host;
552  } else {
553  real_cycle = (host0 != host) || (host0.empty() && host.empty());
554  if (real_cycle) {
555  break;
556  }
557  }
558  }
559  if (!real_cycle) {
560  continue;
561  }
562  string str_chain("Dependency cycle found: ");
564  const CProjKey& proj_id = *n;
565  if (n != cycle.begin()) {
566  str_chain += " - ";
567  }
568  str_chain += proj_id.Id();
569  }
571  reported = true;
572  CCyclicDepends::TDependsChain::const_iterator i = cycle.end();
573  const CProjKey& last = *(--i);
574  const CProjKey& prev = *(--i);
575  if (last.Type() == CProjKey::eLib && prev.Type() == CProjKey::eLib) {
577  if (t != tree.end()) {
578  CProjItem item = t->second;
579  item.m_Depends.remove(last);
580  tree[prev] = item;
582  "Removing LIB dependency: " << prev.Id() << " - " << last.Id());
583  }
584  }
585  }
586  if (!reported) {
587  PTB_INFO("No dependency cycles found.");
588  }
589 }
590 
592 {
593  // Set error posting and tracing on maximum.
594 // SetDiagTrace(eDT_Enable);
597  PTB_INFO("Started at " + CTime(CTime::eCurrent).AsString());
598  PTB_INFO("Project tree builder version " + GetVersion().Print());
599 
600  CStopWatch sw;
601  sw.Start();
602 
603  // Get and check arguments
604  ParseArguments();
605  PTB_INFO("Project tags filter: " + m_ProjTags);
607  {
608  PTB_INFO("Cancelled by request.");
609  return 1;
610  }
611  else if (m_ConfirmCfg && !ConfirmConfiguration())
612  {
613  PTB_INFO("Cancelled by request.");
614  return 1;
615  }
616  VerifyArguments();
618 
619  // Configure
620  CMsvcConfigure configure;
621  configure.Configure(const_cast<CMsvcSite&>(GetSite()),
622  GetRegSettings().m_ConfigInfo,
623  m_IncDir);
624  m_AllDllBuild = GetSite().IsProvided("DLL_BUILD");
625 
626 #if DO_PATCHTREEMAKEFILES
627  // this is just a task; it is to be run very rarely
628  {
629  bool b = m_ScanWholeTree;
630  m_ScanWholeTree = true;
632  m_ScanWholeTree = b;
633  return 0;
634  }
635 #endif
636  // Build projects tree
637 
638 //#ifndef _DEBUG
639 // I need this to collect library relations data and metadata
640  {
641  bool b = m_ScanWholeTree;
642  m_ScanWholeTree = true;
643  GetWholeTree();
644  m_ScanWholeTree = b;
645  }
646 //#endif
647 
648  CProjectItemsTree projects_tree(GetProjectTreeInfo().m_Src);
650  GetProjectTreeInfo().m_Src,
651  &projects_tree);
652  if (m_ExitCode != 0) {
653  PTB_INFO("Cancelled by request.");
654  return m_ExitCode;
655  }
656  configure.CreateConfH(const_cast<CMsvcSite&>(GetSite()),
657  GetRegSettings().m_ConfigInfo,
658  m_IncDir);
659 
660  // MSVC specific part:
661  PTB_INFO("Checking project requirements...");
662  // Exclude some projects from build:
663 #ifdef COMBINED_EXCLUDE
664  {{
665  // Implicit/Exclicit exclude by msvc Makefiles.in.msvc
666  // and project .msvc makefiles.
667  PIsExcludedMakefileIn p_make_in(GetProjectTreeInfo().m_Src);
668  PIsExcludedByProjectMakefile p_project_makefile;
669  CCombine<PIsExcludedMakefileIn,
672  logical_combine(p_make_in, p_project_makefile);
673  EraseIf(projects_tree.m_Projects, logical_combine);
674  }}
675 #else
676  {{
677  // Implicit/Exclicit exclude by msvc Makefiles.in.msvc
678  PIsExcludedByProjectMakefile p_project_makefile;
679  EraseIf(projects_tree.m_Projects, p_project_makefile);
680  }}
681 
682 #endif
683  {{
684  // Project requires are not provided
685  EraseIf(projects_tree.m_Projects, PIsExcludedByRequires());
686  }}
687 
688  CProjectItemsTree dll_projects_tree;
689  bool dll = (GetBuildType().GetType() == CBuildType::eDll);
690  if (dll) {
691  PTB_INFO("Assembling DLLs...");
692 // AnalyzeDllData(projects_tree);
693  CreateDllBuildTree(projects_tree, &dll_projects_tree);
694  }
695  CProjectItemsTree& prj_tree = dll ? dll_projects_tree : projects_tree;
696  prj_tree.VerifyExternalDepends();
697  {{
698  // Erase obsolete external projects
700  }}
701  prj_tree.VerifyDataspecProj();
702 
703  PTB_INFO("Checking project inter-dependencies...");
705  CCyclicDepends::FindCyclesNew(prj_tree.m_Projects, &cycles);
706  s_ReportDependenciesStatus(cycles,projects_tree.m_Projects);
707 
708  if (!m_SuspiciousProj.empty()) {
710  if (prj_tree.m_Projects.find(*key) != prj_tree.m_Projects.end()) {
711  PTB_ERROR(prj_tree.m_Projects.find(*key)->second.GetPath(),
712  "More than one target with this name");
713  m_ExitCode = 1;
714  }
715  }
716  }
717  if (m_ExitCode != 0) {
718  string subtree = CDirEntry::ConcatPath(m_ProjectTreeInfo->m_Root, m_Subtree);
719  if (CDirEntry(subtree).IsFile()) {
720  return m_ExitCode;
721  }
722  m_ExitCode = 0;
723  }
724  PTB_INFO("Creating projects...");
726  GenerateMsvcProjects(prj_tree);
727  }
729  GenerateUnixProjects(prj_tree);
730  }
731  else {
732  GenerateMacProjects(prj_tree);
733  }
736  //
737  PTB_INFO("Done. Elapsed time = " << sw.Elapsed() << " seconds");
738  return m_ExitCode;
739 }
740 
742 {
743 #if NCBI_COMPILER_MSVC
744  PTB_INFO("Generating MSBuild projects...");
745 
746  bool dll = (GetBuildType().GetType() == CBuildType::eDll);
747  list<SConfigInfo> dll_configs;
748  const list<SConfigInfo>* configurations = 0;
749  bool skip_config = !GetEnvironment().Get(s_ptb_skipconfig).empty();
750  string str_config;
751 
752  if (dll) {
753  _TRACE("DLL build");
754  GetBuildConfigs(&dll_configs);
755  configurations = &dll_configs;
756  } else {
757  _TRACE("Static build");
758  configurations = &GetRegSettings().m_ConfigInfo;
759  }
760  {{
761  ITERATE(list<SConfigInfo>, p , *configurations) {
762  str_config += p->GetConfigFullName() + " ";
763  }
764  PTB_INFO("Building configurations: " << str_config);
765  }}
766 
767  m_CurrentBuildTree = &projects_tree;
768  if ( m_AddMissingLibs ) {
769  m_IncompleteBuildTree = &projects_tree;
770  }
771  // Projects
772  CMsvcProjectGenerator prj_gen(*configurations);
773  CMsvcProjectGenerator::GeneratePropertySheets();
775  prj_gen.Generate(p->second);
776  }
777 
778  //Utility projects dir
779  string utility_projects_dir = GetApp().GetUtilityProjectsDir();
780 
781  // MasterProject
782  CMsvcMasterProjectGenerator master_prj_gen(projects_tree,
783  *configurations,
784  utility_projects_dir);
785  if (!skip_config) {
786  master_prj_gen.SaveProject();
787  }
788 
789  // ConfigureProject
790  string output_dir = GetProjectTreeInfo().m_Compilers;
791  output_dir = CDirEntry::ConcatPath(output_dir,
792  GetRegSettings().m_CompilersSubdir);
793  output_dir = CDirEntry::ConcatPath(output_dir,
794  (m_BuildPtb && dll) ? "static" : GetBuildType().GetTypeStr());
795  output_dir = CDirEntry::ConcatPath(output_dir, "bin");
796  output_dir = CDirEntry::AddTrailingPathSeparator(output_dir);
797  CMsvcConfigureProjectGenerator configure_generator(
798  output_dir,
799  *configurations,
800  dll,
801  utility_projects_dir,
803  m_Subtree,
804  m_Solution,
805  m_BuildPtb);
806  if (!skip_config) {
807  configure_generator.SaveProject(false, &prj_gen);
808  configure_generator.SaveProject(true, &prj_gen);
809  }
810 
811  // INDEX dummy project
812  string index_prj_path = CDirEntry::ConcatPath(utility_projects_dir, "_INDEX_");
813  index_prj_path += CMsvc7RegSettings::GetVcprojExt();
814  string index_prj_guid, index_prj_name;
816  CVisualStudioProject xmlprj;
817  CreateUtilityProject(" INDEX, see here: ", *configurations, &xmlprj);
818  if (!skip_config) {
819  SaveIfNewer(index_prj_path, xmlprj);
820  index_prj_guid = xmlprj.GetAttlist().GetProjectGUID();
821  index_prj_name = xmlprj.GetAttlist().GetName();
822  }
823  }
824 
825  string utils[] = {"_DATASPEC_ALL_", "-DATASPEC-ALL-",
826  "_LIBS_ALL_", "-LIBS-ALL-",
827  "_BUILD_ALL_","-BUILD-ALL-"};
828  vector<string> utils_id;
829  int i = 0, num_util = 3;
830 
831  for (i = 0; i < num_util; ++i) {
832  string prj_file(utils[i*2]);
833  string prj_name(utils[i*2+1]);
835  NStr::ReplaceInPlace(prj_name,"-", "_");
836  }
837  string prj_path = CDirEntry::ConcatPath(utility_projects_dir, prj_file);
838  prj_path += CMsvc7RegSettings::GetVcprojExt();
839  utils_id.push_back(prj_path);
841  CVisualStudioProject xmlprj;
842  CreateUtilityProject(prj_name, *configurations, &xmlprj);
843  SaveIfNewer(prj_path, xmlprj);
844  utils_id.push_back(xmlprj.GetAttlist().GetProjectGUID());
845  utils_id.push_back(xmlprj.GetAttlist().GetName());
846  } else {
847  string prj_dir = GetApp().GetUtilityProjectsSrcDir();
848  CProjItem prj_item( CreateUtilityProjectItem(prj_dir, prj_name));
849  prj_gen.Generate(prj_item);
850  utils_id.push_back(prj_item.m_GUID);
851  utils_id.push_back(prj_item.m_Name);
852  }
853  }
854  if (m_ProjTags == "*") {
856  composite != m_CompositeProjectTags.end(); ++composite) {
857  string composite_name = "_TAG_" + composite->first;
858  string composite_filter = composite->second;
859 
860 
861  string prj_path = CDirEntry::ConcatPath(utility_projects_dir, composite_name);
862  prj_path += CMsvc7RegSettings::GetVcprojExt();
863  utils_id.push_back(prj_path);
865  CVisualStudioProject xmlprj;
866  CreateUtilityProject(composite_name, *configurations, &xmlprj);
867  SaveIfNewer(prj_path, xmlprj);
868  utils_id.push_back(xmlprj.GetAttlist().GetProjectGUID());
869  utils_id.push_back(xmlprj.GetAttlist().GetName());
870  } else {
871  string prj_dir = GetApp().GetUtilityProjectsSrcDir();
872  CProjItem prj_item( CreateUtilityProjectItem(prj_dir, composite_name));
873  prj_gen.Generate(prj_item);
874  utils_id.push_back(prj_item.m_GUID);
875  utils_id.push_back(prj_item.m_Name);
876  }
877  utils_id.push_back(composite_filter);
878  ++num_util;
879  }
880  }
881 
882  // Solution
883  CMsvcSolutionGenerator sln_gen(*configurations);
884  ITERATE(CProjectItemsTree::TProjects, p, projects_tree.m_Projects) {
885  sln_gen.AddProject(p->second);
886  }
887  if (!skip_config) {
888 
890  sln_gen.AddUtilityProject( master_prj_gen.GetPath(),
891  master_prj_gen.GetVisualStudioProject().GetAttlist().GetProjectGUID(),
892  master_prj_gen.GetVisualStudioProject().GetAttlist().GetName());
893 
894  sln_gen.AddUtilityProject( index_prj_path, index_prj_guid, index_prj_name);
895  }
896 
897  string cfg_path, cfg_guid, cfg_name;
898  configure_generator.GetVisualStudioProject(cfg_path, cfg_guid, cfg_name, false);
899  sln_gen.AddConfigureProject( cfg_path, cfg_guid, cfg_name);
900 
901  configure_generator.GetVisualStudioProject(cfg_path, cfg_guid, cfg_name, true);
902  sln_gen.AddConfigureProject( cfg_path, cfg_guid, cfg_name);
903  }
904 
905  int u = 0;
906  for (i = 0; i < num_util; ++i) {
907  switch (i) {
908  case 0:
909  sln_gen.AddAsnAllProject( utils_id[u], utils_id[u+1], utils_id[u+2]);
910  u += 3;
911  break;
912  case 1:
913  sln_gen.AddLibsAllProject( utils_id[u], utils_id[u+1], utils_id[u+2]);
914  u += 3;
915  break;
916  case 2:
917  sln_gen.AddBuildAllProject( utils_id[u], utils_id[u+1], utils_id[u+2]);
918  u += 3;
919  break;
920  default:
921  sln_gen.AddTagProject( utils_id[u], utils_id[u+1], utils_id[u+2], utils_id[u+3]);
922  u += 4;
923  break;
924  }
925  }
926 
927  sln_gen.SaveSolution(m_Solution);
928 
929  CreateCheckList(configurations, projects_tree);
930  list<string> enabled, disabled;
931  CreateFeaturesAndPackagesFiles(configurations, enabled, disabled);
932  GenerateSummary(*configurations, enabled, disabled);
933 #endif //NCBI_COMPILER_MSVC
934 }
935 
937 {
938 #if defined(NCBI_XCODE_BUILD) || defined(PSEUDO_XCODE)
939  PTB_INFO("Generating XCode projects...");
940 
941  bool dll = (GetBuildType().GetType() == CBuildType::eDll);
942  list<SConfigInfo> dll_configs;
943  const list<SConfigInfo>* configurations = 0;
944 // bool skip_config = !GetEnvironment().Get(s_ptb_skipconfig).empty();
945  string str_config;
946 
947  if (dll) {
948  _TRACE("DLL build");
949  GetBuildConfigs(&dll_configs);
950  configurations = &dll_configs;
951  } else {
952  _TRACE("Static build");
953  configurations = &GetRegSettings().m_ConfigInfo;
954  }
955  {{
956  ITERATE(list<SConfigInfo>, p , *configurations) {
957  str_config += p->GetConfigFullName() + " ";
958  }
959  PTB_INFO("Building configurations: " << str_config);
960  }}
961 
962  m_CurrentBuildTree = &projects_tree;
963  if ( m_AddMissingLibs ) {
964  m_IncompleteBuildTree = &projects_tree;
965  }
966  // Projects
967  CMacProjectGenerator prj_gen(*configurations, projects_tree);
968  prj_gen.Generate(m_Solution);
969 
970  CreateCheckList(configurations, projects_tree);
971  list<string> enabled, disabled;
972  CreateFeaturesAndPackagesFiles(configurations, enabled, disabled);
973  GenerateSummary(*configurations, enabled, disabled);
974 #endif
975 }
977  CProjectItemsTree& projects_tree,
978  set<string>& dep, set<string>& visited,
981 {
982  string lib_name(CreateProjectName(lib->first));
983  string lib_dep_name(CreateProjectName(lib_dep->first));
984  if (m_AllDllBuild) {
985  dep.insert(lib_dep_name);
986 // return;
987  }
988  if (visited.find(lib_dep_name) != visited.end() ||
989  lib_dep_name == lib_name) {
990  return;
991  }
992  visited.insert(lib_dep_name);
993  if (!lib_dep->second.m_DatatoolSources.empty() ||
994  !lib_dep->second.m_ExportHeaders.empty() ||
995  lib->second.m_UnconditionalDepends.find(lib_dep->first) !=
996  lib->second.m_UnconditionalDepends.end()) {
997  dep.insert(lib_dep_name);
998  }
999  ITERATE(list<CProjKey>, p, lib_dep->second.m_Depends) {
1000  if (p->Type() == CProjKey::eLib) {
1002  projects_tree.m_Projects.find(*p);
1003  if (n != projects_tree.m_Projects.end()) {
1004  CollectLibToLibDependencies(projects_tree, dep, visited, lib, n);
1005  }
1006  }
1007  }
1008 }
1009 
1011 {
1012  map< string, list< string > > path_to_target;
1013  string solution_dir(CDirEntry(m_Solution).GetDir());
1015  if (!ofs.is_open()) {
1017  return;
1018  }
1020  ofs << "# This file was generated by PROJECT_TREE_BUILDER v"
1021  << GetVersion().Print() << endl;
1022  ofs << "# on " << CTime(CTime::eCurrent).AsString() << endl << endl;
1023 
1024 // see CXX-950
1025 #if 0
1026  ofs << "# This is tricky part; it might work incorrectly on some platforms" << endl;
1027 // ofs << "MARK=$(shell date +%Y%m%d%H%M%S)" << endl;
1028  ofs << "MARK=$(if $(MARK2),,$(eval MARK2=$(shell date +%Y%m%d%H%M%S)))$(MARK2)" << endl;
1029  ofs << "MARK:sh =date +%Y%m%d%H%M%S" << endl;
1030  ofs << endl;
1031  ofs << "prefix=.ncbi.signal." << endl;
1032  ofs << "s=$(prefix)$(MARK)" << endl;
1033  ofs << "sign=rm -f $(prefix)*.$@; touch $(s).$@" << endl;
1034  ofs << endl;
1035 #endif
1036 
1037  ofs << "MINPUT=" << CDirEntry(m_Solution).GetName() << endl << endl;
1038  ofs << "# Use empty MTARGET to build a project;" << endl;
1039  ofs << "# MTARGET=clean - to clean, or MTARGET=purge - to purge" << endl;
1040  ofs << "MTARGET =" << endl << endl;
1041 
1042  if (m_ExtSrcRoot.empty()) {
1043  ofs << "top_srcdir=" << m_Root << endl;
1044  } else {
1045  ofs << "top_srcdir=" << m_ExtSrcRoot << endl;
1046  }
1047  ofs << "# Non-redundant flags (will be overridden for GNU Make to avoid" << endl;
1048  ofs << "# --jobserver-fds=* proliferation)" << endl;
1049  ofs << "MFLAGS_NR = $(MFLAGS)" << endl;
1050  ofs << "SKIP_PRELIMINARIES= sources= configurables=configurables.null" << endl;
1051 
1052 // all dirs -----------------------------------------------------------------
1053  list<string> all_dirs;
1054  ITERATE(CProjectItemsTree::TProjects, p, projects_tree.m_Projects) {
1055  if (p->first.Type() == CProjKey::eDataSpec) {
1056  continue;
1057  }
1058  all_dirs.push_back(
1060  GetProjectTreeInfo().m_Src,p->second.m_SourcesBaseDir)));
1061  }
1062  all_dirs.sort();
1063  all_dirs.unique();
1064  ofs << "all_dirs =";
1065  ITERATE(list<string>, p, all_dirs) {
1066  ofs << " \\" <<endl << " " << *p;
1067  }
1068  ofs << endl << endl;
1069 
1070  ofs << "include $(top_srcdir)/src/build-system/Makefile.is_gmake" << endl;
1071  ofs << "include $(top_srcdir)/src/build-system/Makefile.meta.$(is_gmake)" << endl;
1072  ofs << endl;
1073 
1074  string dotreal(".real");
1075  string dotfiles(".files");
1076 
1077 // all projects -------------------------------------------------------------
1078  ofs << "all_projects =";
1079  ITERATE(CProjectItemsTree::TProjects, p, projects_tree.m_Projects) {
1080  if (p->second.m_MakeType == eMakeType_Excluded ||
1081  p->second.m_MakeType == eMakeType_ExcludedByReq) {
1082  PTB_INFO("For reference only: " << CreateProjectName(p->first));
1083  continue;
1084  }
1085  if (p->first.Type() == CProjKey::eDataSpec) {
1086  continue;
1087  }
1088  ofs << " \\" <<endl << " " << CreateProjectName(p->first);
1089  }
1090  ofs << endl << endl;
1091 
1092  ofs << "ptb_all :" << endl
1093  << "\t$(MAKE) $(MFLAGS_NR) -f $(MINPUT) ptb_all" << dotreal
1094  << " MTARGET=$(MTARGET)";
1095  ofs << endl << endl;
1096  ofs << "ptb_all" << dotreal << " :" << " $(all_projects:%=%" << dotreal << ")";
1097  ofs << endl << endl;
1098 
1099 // all libs -----------------------------------------------------------------
1100  ofs << "all_libraries =";
1101  ITERATE(CProjectItemsTree::TProjects, p, projects_tree.m_Projects) {
1102  if (p->second.m_MakeType == eMakeType_Excluded ||
1103  p->second.m_MakeType == eMakeType_ExcludedByReq) {
1104  continue;
1105  }
1106  if (p->first.Type() == CProjKey::eLib ||
1107  p->first.Type() == CProjKey::eDll) {
1108  ofs << " \\" <<endl << " " << CreateProjectName(p->first);
1109  }
1110  }
1111  ofs << endl << endl;
1112 
1113  ofs << "all_libs :" << endl
1114  << "\t$(MAKE) $(MFLAGS_NR) -f $(MINPUT) all_libs" << dotreal
1115  << " MTARGET=$(MTARGET)";
1116  ofs << endl << endl;
1117  ofs << "all_libs" << dotreal << " :" << " $(all_libraries:%=%" << dotreal << ")";
1118  ofs << endl << endl;
1119 
1120 // all sources --------------------------------------------------------------
1121  ofs << "all_dataspec =";
1122  ITERATE(CProjectItemsTree::TProjects, p, projects_tree.m_Projects) {
1123  if (p->second.m_MakeType == eMakeType_Excluded ||
1124  p->second.m_MakeType == eMakeType_ExcludedByReq) {
1125  continue;
1126  }
1127  if (p->first.Type() == CProjKey::eDataSpec) {
1128  continue;
1129  }
1130  if (p->second.m_DatatoolSources.empty()) {
1131  continue;
1132  }
1133  ofs << " \\" <<endl << " " << CreateProjectName(p->first) << dotfiles;
1134  }
1135  ofs << endl << endl;
1136 
1137  ofs << "all_files :" << endl
1138  << "\t$(MAKE) $(MFLAGS_NR) -f $(MINPUT) all_files" << dotreal;
1139  ofs << endl << endl;
1140  ofs << "all_files" << dotreal << " :" << " $(all_dataspec:%=%" << dotreal << ")";
1141  ofs << endl << endl;
1142 
1143 // all apps -----------------------------------------------------------------
1144  ofs << "all_apps =";
1145  ITERATE(CProjectItemsTree::TProjects, p, projects_tree.m_Projects) {
1146  if (p->second.m_MakeType == eMakeType_Excluded ||
1147  p->second.m_MakeType == eMakeType_ExcludedByReq) {
1148  continue;
1149  }
1150  if (p->first.Type() == CProjKey::eApp) {
1151  ofs << " \\" <<endl << " " << CreateProjectName(p->first);
1152  }
1153  }
1154  ofs << endl << endl;
1155 
1156 // all Unix -------------------------------------------------------------
1157  ofs << "all_unix =";
1158  ITERATE(CProjectItemsTree::TProjects, p, projects_tree.m_Projects) {
1159  if (p->second.m_MakeType == eMakeType_Excluded ||
1160  p->second.m_MakeType == eMakeType_ExcludedByReq) {
1161  continue;
1162  }
1163  if (p->first.Type() == CProjKey::eMsvc) {
1164  ofs << " \\" <<endl << " " << CreateProjectName(p->first);
1165  }
1166  }
1167  ofs << endl << endl;
1168 
1169 // all excluded -------------------------------------------------------------
1170  ofs << "all_excluded =";
1171  ITERATE(CProjectItemsTree::TProjects, p, projects_tree.m_Projects) {
1172  if (p->first.Type() == CProjKey::eDataSpec) {
1173  continue;
1174  }
1175  if (p->second.m_MakeType == eMakeType_Excluded ||
1176  p->second.m_MakeType == eMakeType_ExcludedByReq) {
1177  ofs << " \\" <<endl << " " << CreateProjectName(p->first);
1178  }
1179  }
1180  ofs << endl << endl;
1181 
1182 // CompositeProjectTags -----------------------------------------------------
1183 // (add always)
1184  vector<string> existing_composite_names;
1186  m_CompositeProjectTags[*r] = *r;
1187  }
1188  /*if (m_ProjTags == "*")*/ {
1190  composite != m_CompositeProjectTags.end(); ++composite) {
1191  string composite_name = "TAG_" + composite->first;
1192  string composite_filter = composite->second;
1193  vector<string> matching;
1194 
1195  ITERATE(CProjectItemsTree::TProjects, p, projects_tree.m_Projects) {
1196  if (p->second.m_MakeType == eMakeType_Excluded ||
1197  p->second.m_MakeType == eMakeType_ExcludedByReq) {
1198  continue;
1199  }
1200  if (p->first.Type() == CProjKey::eDataSpec) {
1201  continue;
1202  }
1203  if (IsAllowedProjectTag(p->second, &composite_filter)) {
1204  matching.push_back( CreateProjectName(p->first));
1205  }
1206  }
1207  if (!matching.empty()) {
1208  existing_composite_names.push_back(composite_name);
1209  ofs << composite_name << "_projects =";
1210  ITERATE(vector<string>, c, matching) {
1211  ofs << " \\" <<endl << " " << *c;
1212  }
1213  ofs << endl << endl;
1214 
1215  ofs << composite_name << " :" << endl
1216  << "\t$(MAKE) $(MFLAGS_NR) -f $(MINPUT) " << composite_name << dotreal
1217  << " MTARGET=$(MTARGET)";
1218  ofs << endl << endl;
1219  ofs << composite_name << dotreal << " :" << " $("
1220  << composite_name << "_projects" << ":%=%" << dotreal << ")";
1221  ofs << endl << endl;
1222 
1223  }
1224  }
1225  }
1226 
1227 
1228 // help and list targets ----------------------------------------------------
1229  ofs << "help :"
1230  << endl << "\t@echo Build all projects"
1231  << endl << "\t@echo \" make -f $(MINPUT) -j 12 ptb_all\""
1232  << endl << "\t@echo Build a project, for example, xncbi.lib"
1233  << endl << "\t@echo \" make -f $(MINPUT) -j 12 xncbi.lib\""
1234  << endl << "\t@echo Clean project intermediate files"
1235  << endl << "\t@echo \" make -f $(MINPUT) -j 12 xncbi.lib MTARGET=clean\""
1236  << endl << "\t@echo Clean project intermediate and output files"
1237  << endl << "\t@echo \" make -f $(MINPUT) -j 12 xncbi.lib MTARGET=purge\""
1238  << endl << "\t@echo Target lists: "
1239  << endl << "\t@echo \" list-all - list all targets\""
1240  << endl << "\t@echo \" list-apps - list all applications\""
1241  << endl << "\t@echo \" list-libs - list all libraries\""
1242  << endl << "\t@echo \" list-unix - list all native Unix projects\""
1243  << endl << "\t@echo \" list-excluded - list 'excluded' targets\""
1244  << endl << "\t@echo \" list-tags - list composite targets\""
1245  << endl << "\t@echo \" list-tag-TagName - list all targets in a composite target TagName\"";
1246  ofs << endl << endl;
1247 
1248  ofs << "list-all :"
1249  << endl << "\t@echo"
1250  << endl << "\t@echo"
1251  << endl << "\t@echo --------------------------------------"
1252  << endl << "\t@echo APPLICATIONS"
1253  << endl << "\t@echo"
1254  << endl << "\t@for i in $(all_apps); do echo $$i; done"
1255  << endl << "\t@echo"
1256  << endl << "\t@echo"
1257  << endl << "\t@echo --------------------------------------"
1258  << endl << "\t@echo LIBRARIES"
1259  << endl << "\t@echo"
1260  << endl << "\t@for i in $(all_libraries); do echo $$i; done"
1261  << endl << "\t@echo"
1262  << endl << "\t@echo"
1263  << endl << "\t@echo --------------------------------------"
1264  << endl << "\t@echo UNIX PROJECTS"
1265  << endl << "\t@echo"
1266  << endl << "\t@for i in $(all_unix); do echo $$i; done";
1267 
1268  if (!existing_composite_names.empty()) {
1269  ofs
1270  << endl << "\t@echo"
1271  << endl << "\t@echo"
1272  << endl << "\t@echo --------------------------------------"
1273  << endl << "\t@echo COMPOSITE TARGETS"
1274  << endl << "\t@echo";
1275  ITERATE(vector<string>, c, existing_composite_names) {
1276  ofs << endl << "\t@echo " << *c;
1277  }
1278  }
1279  ofs
1280  << endl << "\t@echo"
1281  << endl << "\t@echo"
1282  << endl << "\t@echo --------------------------------------"
1283  << endl << "\t@echo DIRECTORIES"
1284  << endl << "\t@echo"
1285  << endl << "\t@for i in $(all_dirs); do echo $$i/; done";
1286  ofs << endl << endl;
1287  ofs << "list-apps :"
1288  << endl << "\t@for i in $(all_apps); do echo $$i; done";
1289  ofs << endl << endl;
1290  ofs << "list-libs :"
1291  << endl << "\t@for i in $(all_libraries); do echo $$i; done";
1292  ofs << endl << endl;
1293  ofs << "list-unix :"
1294  << endl << "\t@for i in $(all_unix); do echo $$i; done";
1295  ofs << endl << endl;
1296  ofs << "list-excluded :"
1297  << endl << "\t@for i in $(all_excluded); do echo $$i; done";
1298  ofs << endl << endl;
1299 
1300  ofs << "list-tags :";
1301  if (!existing_composite_names.empty()) {
1302  ITERATE(vector<string>, c, existing_composite_names) {
1303  ofs << endl << "\t@echo " << *c;
1304  }
1305  }
1306  ofs << endl << endl;
1307  ITERATE(vector<string>, c, existing_composite_names) {
1308  ofs << "list-tag-" << *c << " :"
1309  << endl << "\t@for i in $(" << *c << "_projects); do echo $$i; done";
1310  ofs << endl << endl;
1311  }
1312 
1313 // --------------------------------------------------------------------------
1314  string datatool_key;
1315  string datatool( GetDatatoolId() );
1316  set<string> dataspec_dirs;
1317  if (!datatool.empty()) {
1318  CProjKey t(CProjKey::eApp, datatool);
1319  if (projects_tree.m_Projects.find(t) != projects_tree.m_Projects.end()) {
1320  datatool_key = CreateProjectName(t);
1321  }
1322  }
1323 
1324  ITERATE(CProjectItemsTree::TProjects, p, projects_tree.m_Projects) {
1325 
1326  if (p->first.Type() == CProjKey::eDataSpec) {
1327  continue;
1328  }
1329 
1330  bool isLibrary = p->first.Type() == CProjKey::eLib;
1331  bool hasDataspec = !p->second.m_DatatoolSources.empty();
1332  string target, target_app, target_lib, target_user;
1333  list<string> dependencies;
1335 
1336  target = CreateProjectName(p->first);
1337  target_app = target_lib = target_user = "\"\"";
1338  if (p->first.Type() == CProjKey::eApp) {
1339  target_app = p->second.m_Name;
1340  } else if (p->first.Type() == CProjKey::eMsvc) {
1341  target_user = p->second.m_Name;
1342  } else if (p->first.Type() == CProjKey::eLib) {
1343  target_lib = p->second.m_Name;
1344  } else {
1345  target_lib = p->second.m_Name;
1346  }
1347  string rel_path = CDirEntry::CreateRelativePath(
1348  GetProjectTreeInfo().m_Src,p->second.m_SourcesBaseDir);
1349 
1350 // check for missing dependencies -------------------------------------------
1351  string error;
1352  if (p->second.m_MakeType != eMakeType_Expendable && m_BuildRoot.empty()) {
1353  ITERATE(set<CProjKey>, u, p->second.m_UnconditionalDepends) {
1354  CProjKey proj_key = *u;
1355  if (projects_tree.m_Projects.find(proj_key) ==
1356  projects_tree.m_Projects.end()) {
1357  bool depfound = false;
1358  string dll(GetDllHost(projects_tree, proj_key.Id()));
1359  if (!dll.empty()) {
1360  CProjKey id_alt(CProjKey::eDll,dll);
1361  depfound = (projects_tree.m_Projects.find(id_alt) !=
1362  projects_tree.m_Projects.end());
1363  }
1364  if (!depfound &&
1365  !SMakeProjectT::IsConfigurableDefine(proj_key.Id())) {
1366  error = "@echo ERROR: this project depends on missing " +
1367  CreateProjectName(proj_key);
1368  }
1369  }
1370  }
1371  }
1372 
1373 // collect dependencies -----------------------------------------------------
1374  set<string> lib_guid, visited;
1375  ITERATE(list<CProjKey>, i, p->second.m_Depends) {
1376 
1377  const CProjKey& id = *i;
1378  // exclude 3rd party libs
1379  if ( GetSite().IsLibWithChoice(id.Id()) ) {
1380  if ( GetSite().GetChoiceForLib(id.Id()) == CMsvcSite::e3PartyLib ) {
1381  continue;
1382  }
1383  }
1384  // exclude missing projects
1385  n = projects_tree.m_Projects.find(id);
1386  if (n == projects_tree.m_Projects.end()) {
1387 /*
1388  CProjKey id_alt(CProjKey::eDll,GetDllsInfo().GetDllHost(id.Id()));
1389  n = projects_tree.m_Projects.find(id_alt);
1390  if (n == projects_tree.m_Projects.end())
1391 */
1392  {
1393  if (!SMakeProjectT::IsConfigurableDefine(id.Id())) {
1395  "Project " + p->first.Id() + " depends on missing project " + id.Id());
1396  }
1397  continue;
1398  }
1399  }
1400  if (isLibrary) {
1401  CollectLibToLibDependencies(projects_tree, lib_guid, visited, p, n);
1402  continue;
1403  }
1404  dependencies.push_back(CreateProjectName(n->first));
1405  }
1406  copy(lib_guid.begin(), lib_guid.end(), back_inserter(dependencies));
1407  dependencies.sort();
1408  dependencies.unique();
1409  CProjectTreeBuilder::VerifyBuildOrder( p->second, dependencies, projects_tree);
1410 
1411  if (isLibrary && !m_AllDllBuild) {
1412  list<string> new_dependencies;
1413 // new_dependencies.push_back( target + dotfiles);
1414  ITERATE(list<string>, d, dependencies) {
1415  if (*d == datatool_key) {
1416  continue;
1417  }
1418  n = projects_tree.m_Projects.find(CreateProjKey(*d));
1419  if (n != projects_tree.m_Projects.end() &&
1420  !n->second.m_DatatoolSources.empty()) {
1421  new_dependencies.push_back(*d + dotfiles);
1422  continue;
1423  }
1424  new_dependencies.push_back(*d);
1425  }
1426  dependencies = new_dependencies;
1427  }
1428 
1429 // collect paths ------------------------------------------------------------
1430  if (p->first.Type() != CProjKey::eDataSpec) {
1431 
1432  path_to_target[rel_path].push_back(target);
1433  if (p->second.m_MakeType != eMakeType_Excluded &&
1434  p->second.m_MakeType != eMakeType_ExcludedByReq) {
1435  string stop_path(CDirEntry::AddTrailingPathSeparator("."));
1436  string parent_path, prev_parent(rel_path);
1437  for (;;) {
1438  parent_path = ParentDir(prev_parent);
1439 // see CXX-950
1440 #if 0
1441  path_to_target[parent_path].push_back(prev_parent + ".real");
1442 #else
1443  path_to_target[parent_path].push_back(prev_parent);
1444 #endif
1445  if (parent_path == stop_path) {
1446  break;
1447  }
1448  prev_parent = parent_path;
1449  }
1450  }
1451  }
1452 
1453 #if NCBI_COMPILER_MSVC
1454  rel_path = NStr::Replace(rel_path,"\\","/");
1455 #endif //NCBI_COMPILER_MSVC
1456 
1457 // see CXX-950
1458 #if 0
1459  ofs << target << " : " << rel_path << "$(s)." << target << ".real";
1460  ofs << endl << endl;
1461  ofs << rel_path << "$(s)." << target << ".real" << " :" << endl
1462  << "\t$(MAKE) $(MFLAGS_NR) -f $(MINPUT) " << target << ".real"
1463  << " MTARGET=$(MTARGET) MARK=$(MARK)";
1464  ofs << endl << endl;
1465  ofs << target << ".real" << " :";
1466  ITERATE(list<string>, d, dependencies) {
1467  ofs << " " << *d;
1468  }
1469  ofs << endl << "\t";
1470  if (!error.empty()) {
1471  ofs << error << endl << "\t@exit 1" << endl << "\t";
1472  }
1473  ofs << "+";
1474  if (p->second.m_MakeType == eMakeType_Expendable) {
1475  ofs << "-";
1476  }
1477  ofs << "cd " << rel_path << "; $(MAKE) $(MFLAGS_NR)"
1478  << " APP_PROJ=" << target_app
1479  << " LIB_PROJ=" << target_lib
1480  << " $(MTARGET)" << endl
1481  << "\t@" << "cd " << rel_path << "; $(sign)";
1482  ofs << endl << endl;
1483 #else
1484  ofs << target << " :" << endl
1485  << "\t$(MAKE) $(MFLAGS) -f $(MINPUT) " << target << dotreal
1486  << " MTARGET=$(MTARGET)";
1487  ofs << endl << endl;
1488  ofs << target << dotreal << " :";
1489 
1490  if (hasDataspec) {
1491  dataspec_dirs.insert(rel_path);
1492  }
1493  ITERATE(list<string>, d, dependencies) {
1494  if (*d == datatool_key) {
1495  dataspec_dirs.insert(rel_path);
1496  } else {
1497  ofs << " " << *d << dotreal;
1498  }
1499  }
1500  ofs << " " << rel_path << dotfiles << dotreal;
1501 
1502 
1503  ofs << endl << "\t";
1504  if (!error.empty()) {
1505  ofs << error << endl << "\t@exit 1" << endl << "\t";
1506  }
1507  ofs << "+";
1508  if (p->second.m_MakeType >= eMakeType_Expendable) {
1509  ofs << "-";
1510  }
1511  ofs << "cd " << rel_path << " && ";
1512  if (p->second.m_MakeType == eMakeType_Expendable) {
1513  ofs << " NCBI_BUT_EXPENDABLE=' (but expendable)'";
1514  }
1515  ofs << " $(MAKE) $(MFLAGS)"
1516  << " APP_PROJ=" << target_app
1517  << (p->second.m_IsMetallib ? " LIB_PROJ=\"\" METAL_PROJ=" : " LIB_PROJ=") << target_lib
1518  << " UNIX_PROJ=" << target_user
1519  << " $(MTARGET)";
1520  if (p->first.Type() != CProjKey::eMsvc) {
1521  ofs << " $(SKIP_PRELIMINARIES)";
1522  }
1523  ofs << endl << endl;
1524  #endif
1525  if (hasDataspec) {
1526  ofs << target << dotfiles << " :" << endl
1527  << "\t$(MAKE) $(MFLAGS) -f $(MINPUT) $(SKIP_PRELIMINARIES) "
1528  << target << dotfiles << dotreal;
1529  ofs << endl << endl;
1530  ofs << target << dotfiles << dotreal << " :";
1531  ofs << " " << rel_path << dotfiles << dotreal;
1532  ofs << endl << endl;
1533  }
1534 
1535 // recommended library order
1536  if (p->first.Type() == CProjKey::eApp || p->first.Type() == CProjKey::eDll) {
1537  const list<string>& liborder = m_LibraryOrder[ p->second.m_MkName];
1538  const list<string>& lib3order = m_3PartyLibraryOrder[ p->second.m_MkName];
1539  string filename(
1540  CDirEntry::ConcatPath(solution_dir,
1541  CDirEntry::CreateRelativePath( GetProjectTreeInfo().m_Src, p->second.GetPath() + ".libdep")));
1542  if (m_LibDep && (!liborder.empty() || !lib3order.empty())) {
1543  CNcbiOfstream ofs(filename.c_str(), IOS_BASE::out | IOS_BASE::trunc);
1544  if (ofs.is_open()) {
1545  if (!liborder.empty()) {
1546  ofs << "GENERATED_LIB_ORDER = -l" << NStr::Join(liborder," -l") << endl;
1547  }
1548  if (!lib3order.empty()) {
1549  ofs << "GENERATED_LIB3PARTY_ORDER =";
1550  ITERATE( list<string>, l3, lib3order) {
1551  if (l3->empty()) {
1552  continue;
1553  }
1554  ofs << " ";
1555  if (m_Frameworks.find(*l3) != m_Frameworks.end()) {
1556  ofs << "-framework ";
1557  } else if (m_3PartyLibs.find(*l3) != m_3PartyLibs.end()) {
1558  ofs << "-l";
1559  } else if (l3->at(0) != '-' &&
1560  l3->find_first_of("$/.") == string::npos) {
1561  ofs << "-l";
1562  }
1563  ofs << *l3;
1564  }
1565  ofs << endl;
1566  }
1567  }
1568  }
1569  else {
1570  CFile(filename).Remove();
1571  }
1572  }
1573  }
1574 
1575 // folder targets -----------------------------------------------------------
1576  map< string, list< string > >::const_iterator pt;
1577  for ( pt = path_to_target.begin(); pt != path_to_target.end(); ++pt) {
1578  string target(pt->first);
1579  ofs << ".PHONY : " << target << endl << endl;
1580  ofs << target << " :" << endl
1581  << "\t$(MAKE) $(MFLAGS_NR) -f $(MINPUT) " << target << dotreal
1582  << " MTARGET=$(MTARGET)";
1583  ofs << endl << endl;
1584  ofs << target << dotreal << " :";
1585  if (!pt->second.empty()) {
1586  list< string > tt(pt->second);
1587  tt.sort();
1588  tt.unique();
1589 // see CXX-950
1590 #if 0
1591  ofs << " " << NStr::Join( tt, " ");
1592 #else
1593  ofs << " " << NStr::Join( tt, dotreal + " ") << dotreal;
1594 #endif
1595  ofs << endl << endl;
1596  }
1597 
1598  ofs << target << dotfiles << " :" << endl
1599  << "\t$(MAKE) $(MFLAGS_NR) -f $(MINPUT) " << target << dotfiles << dotreal
1600  << " MTARGET=$(MTARGET)";
1601  ofs << endl << endl;
1602  ofs << target << dotfiles << dotreal << " :";
1603  if (m_Dtdep && !datatool_key.empty() &&
1604  dataspec_dirs.find(target) != dataspec_dirs.end()) {
1605  ofs << " " << datatool_key << dotreal;
1606  }
1607  ofs << endl << "\t";
1608  ofs << "-";
1609  ofs << "cd " << target << " && $(MAKE) $(MFLAGS) sources";
1610  ofs << endl << endl;
1611  }
1612 }
1613 
1614 
1616  const list<SConfigInfo>* configs,
1617  list<string>& list_enabled, list<string>& list_disabled)
1618 {
1619  PTB_INFO("Generating Features_And_Packages files...");
1620  // Create makefile path
1621  string base_path = GetProjectTreeInfo().m_Compilers;
1622  base_path = CDirEntry::ConcatPath(base_path,
1623  GetRegSettings().m_CompilersSubdir);
1624 
1625  base_path = CDirEntry::ConcatPath(base_path, GetBuildType().GetTypeStr());
1626  ITERATE(list<SConfigInfo>, c , *configs) {
1627  string file_path = CDirEntry::ConcatPath(base_path, c->GetConfigFullName());
1628  CDir(file_path).CreatePath();
1629  string enabled = CDirEntry::ConcatPath(file_path,
1630  "features_and_packages.txt");
1631  string disabled = CDirEntry::ConcatPath(file_path,
1632  "features_and_packages_disabled.txt");
1633 
1634  list<string> cfg_enabled, cfg_disabled;
1635  if (c->m_rtType == SConfigInfo::rtMultiThreaded) {
1636  cfg_enabled.push_back("MT");
1637  } else if (c->m_rtType == SConfigInfo::rtMultiThreadedDebug) {
1638  cfg_enabled.push_back("MT");
1639  cfg_enabled.push_back("Debug");
1640  } else if (c->m_rtType == SConfigInfo::rtMultiThreadedDLL) {
1641  cfg_enabled.push_back("MT");
1642  } else if (c->m_rtType == SConfigInfo::rtMultiThreadedDebugDLL) {
1643  cfg_enabled.push_back("MT");
1644  cfg_enabled.push_back("Debug");
1645  } else if (c->m_rtType == SConfigInfo::rtSingleThreaded) {
1646  } else if (c->m_rtType == SConfigInfo::rtSingleThreadedDebug) {
1647  cfg_enabled.push_back("Debug");
1648  }
1649  if (GetBuildType().GetType() == CBuildType::eDll) {
1650  cfg_enabled.push_back("DLL");
1651  }
1652  const set<string>& epackages =
1653  CMsvcPrjProjectContext::GetEnabledPackages(c->GetConfigFullName());
1654  cfg_enabled.insert(cfg_enabled.end(), epackages.begin(), epackages.end());
1655 
1656  list<string> std_features;
1657  GetSite().GetStandardFeatures(std_features);
1658  cfg_enabled.insert(cfg_enabled.end(), std_features.begin(), std_features.end());
1659 
1660  list<string> features;
1662  ITERATE(list<string>, s, features) {
1663  if (GetSite().IsProvided(*s)) {
1664  cfg_enabled.push_back(*s);
1665  } else {
1666  cfg_disabled.push_back(*s);
1667  }
1668  }
1669 
1670  const set<string>& dpackages =
1671  CMsvcPrjProjectContext::GetDisabledPackages(c->GetConfigFullName());
1672  cfg_disabled.insert(cfg_disabled.end(), dpackages.begin(), dpackages.end());
1673 
1674  GetSite().GetRequiresInfo(*c, cfg_enabled, cfg_disabled);
1675 
1676  list<string>::iterator i;
1677  for (i=cfg_enabled.begin(); i != cfg_enabled.end();) {
1678  if (i->at(0) == '-') {
1679  cfg_disabled.push_back( i->substr(1));
1680  list<string>::iterator j = i++;
1681  cfg_enabled.erase(j);
1682  } else {
1683  ++i;
1684  }
1685  }
1686  for (i=cfg_disabled.begin(); i != cfg_disabled.end();) {
1687  if (i->at(0) == '-') {
1688  cfg_enabled.push_back( i->substr(1));
1689  list<string>::iterator j = i++;
1690  cfg_disabled.erase(j);
1691  } else {
1692  ++i;
1693  }
1694  }
1695  cfg_enabled.sort();
1696  cfg_enabled.unique();
1697  cfg_disabled.sort();
1698  cfg_disabled.unique();
1699 
1700  CNcbiOfstream ofs(enabled.c_str(), IOS_BASE::out | IOS_BASE::trunc );
1701  if ( !ofs )
1702  NCBI_THROW(CProjBulderAppException, eFileCreation, enabled);
1703  GetApp().RegisterGeneratedFile( enabled );
1704  for (const string& e : cfg_enabled) {
1705  ofs << e << endl;
1706  }
1707 
1708  CNcbiOfstream ofsd(disabled.c_str(), IOS_BASE::out | IOS_BASE::trunc );
1709  if ( !ofsd )
1710  NCBI_THROW(CProjBulderAppException, eFileCreation, disabled);
1711  GetApp().RegisterGeneratedFile( disabled );
1712  for (const string& e : cfg_disabled) {
1713  ofsd << e << endl;
1714  }
1715 
1716  list_enabled.insert(list_enabled.end(), cfg_enabled.begin(), cfg_enabled.end());
1717  list_disabled.insert(list_disabled.end(), cfg_disabled.begin(), cfg_disabled.end());
1718  }
1719  list_enabled.sort();
1720  list_enabled.unique();
1721  list_disabled.sort();
1722  list_disabled.unique();
1723 }
1724 
1725 void CProjBulderApp::GenerateSummary(const list<SConfigInfo> configs,
1726  const list<string>& enabled, const list<string>& disabled)
1727 {
1728  if (!m_ConfSrc.empty() && !m_ConfDest.empty()) {
1729  string orig_ext = CDirEntry( CDirEntry(m_ConfSrc).GetBase() ).GetExt();
1730  ITERATE(list<SConfigInfo>, p , configs) {
1731  const SConfigInfo& cfg_info = *p;
1732  string file_dst_path;
1733  file_dst_path = m_ConfDest + "." +
1735  orig_ext;
1736  CreateConfigurableFile(m_ConfSrc, file_dst_path,
1737  cfg_info.GetConfigFullName());
1738  }
1739  }
1740 
1741  // summary
1743  PTB_INFO("===========================================================");
1744  PTB_INFO("SOLUTION: " << m_Solution);
1745  PTB_INFO("PROJECTS: " << CDirEntry::ConcatPath(m_ProjectTreeInfo->m_Root, m_Subtree));
1746  string str_config;
1747  for (const auto& cfg : configs) {
1748  str_config += " " + cfg.GetConfigFullName();
1749  }
1750  PTB_INFO("CONFIGURATIONS: " << str_config);
1751  PTB_INFO("FEATURES AND PACKAGES: ");
1752  string str_pkg = " enabled: ";
1753  ITERATE( list<string>, p, enabled) {
1754  if (str_pkg.length() > 70) {
1755  PTB_INFO(str_pkg);
1756  str_pkg = " ";
1757  }
1758  str_pkg += " ";
1759  str_pkg += *p;
1760  }
1761  if (!str_pkg.empty()) {
1762  PTB_INFO(str_pkg);
1763  }
1764  str_pkg = " disabled: ";
1765  ITERATE( list<string>, p, disabled) {
1766  if (str_pkg.length() > 70) {
1767  PTB_INFO(str_pkg);
1768  str_pkg = " ";
1769  }
1770  str_pkg += " ";
1771  str_pkg += *p;
1772  }
1773  if (!str_pkg.empty()) {
1774  PTB_INFO(str_pkg);
1775  }
1776  string str_path = GetProjectTreeInfo().m_Compilers;
1777  str_path = CDirEntry::ConcatPath(str_path,
1778  GetRegSettings().m_CompilersSubdir);
1779  str_path = CDirEntry::ConcatPath(str_path, GetBuildType().GetTypeStr());
1780 
1781  PTB_INFO(" ");
1782  PTB_INFO(" If a package is present in both lists,");
1783  PTB_INFO(" it is disabled in SOME configurations only");
1784  PTB_INFO(" For details see 'features_and_packages' files in");
1785  PTB_INFO(" " << str_path << "/%ConfigurationName%");
1786  PTB_INFO("===========================================================");
1787 }
1788 
1789 void CProjBulderApp::CreateCheckList(const list<SConfigInfo>* configs,
1790  CProjectItemsTree& projects_tree)
1791 {
1792  PTB_INFO("Generating check.sh.list files...");
1793  string output_dir(m_Solution);
1795  string::size_type n = output_dir.find_last_of('.');
1796  if (n != string::npos) {
1797  output_dir = output_dir.substr(0,n);
1798  }
1799  }
1800  output_dir += ".check";
1801  ITERATE(list<SConfigInfo>, c , *configs) {
1802  string cfg(c->GetConfigFullName());
1803  string file_path = CDirEntry::ConcatPath(output_dir, cfg);
1804  CDir dir(file_path);
1805  if (!dir.Exists()) {
1806  dir.CreatePath();
1807  }
1808  file_path = CDirEntry::ConcatPath(file_path, "check.sh.list");
1809  CNcbiOfstream ofs(file_path.c_str(), IOS_BASE::out | IOS_BASE::trunc );
1810  if ( !ofs )
1811  NCBI_THROW(CProjBulderAppException, eFileCreation, file_path);
1812  GetApp().RegisterGeneratedFile( file_path );
1813  list<string> all_cmd;
1814  ITERATE(CProjectItemsTree::TProjects, p, projects_tree.m_Projects) {
1815  const CProjItem& project = p->second;
1816  if (project.m_MakeType == eMakeType_Excluded ||
1817  project.m_MakeType == eMakeType_ExcludedByReq) {
1818  continue;
1819  }
1820  if (project.m_CheckConfigs.find(cfg) != project.m_CheckConfigs.end()) {
1821  ITERATE( list<string>, cmd, project.m_CheckInfo) {
1822  all_cmd.push_back(*cmd);
1823  }
1824  } else if (!project.m_CheckInfo.empty()) {
1825  PTB_INFO("Project: " << p->first.Id() << ": CHECK_CMD disabled in " << cfg);
1826  }
1827  }
1828  all_cmd.sort();
1829  all_cmd.unique();
1830  ITERATE(list<string>, cmd, all_cmd) {
1831  ofs << *cmd << endl;
1832  }
1833  }
1834 }
1835 
1837 {
1838  m_GeneratedFiles.sort();
1839  string file_path( m_Solution + "_generated_files.txt");
1840  string sep;
1841  sep += CDirEntry::GetPathSeparator();
1842  string root(m_Root);
1843  if (!CDirEntry::IsAbsolutePath(root)) {
1844  root = CDirEntry::ConcatPath(CDir::GetCwd(), root);
1845  }
1846  CNcbiOfstream ofs(file_path.c_str(), IOS_BASE::out | IOS_BASE::trunc );
1847  if (ofs.is_open()) {
1848  ITERATE( list<string>, f, m_GeneratedFiles) {
1849  string path(*f);
1850  if (!CDirEntry::IsAbsolutePath(path)) {
1851  path = CDirEntry::ConcatPath(CDir::GetCwd(), path);
1852  }
1853  path = CDirEntry::CreateRelativePath(root, path);
1854  ofs << NStr::ReplaceInPlace( path, sep, "/") << endl;
1855  }
1856  }
1857 }
1858 
1860 {
1861  m_ProjWatchers.sort();
1862  string file_path( m_Solution + "_watchers.txt");
1863  CNcbiOfstream ofs(file_path.c_str(), IOS_BASE::out | IOS_BASE::trunc );
1864  if (ofs.is_open()) {
1865  ITERATE( list<string>, f, m_ProjWatchers) {
1866  ofs << *f << endl;
1867  }
1868  }
1869 }
1870 
1872 {
1873 }
1874 
1875 
1877 {
1878  const CArgs& args = GetArgs();
1879  string root;
1880  bool extroot = false;
1881  bool argfile = false;
1882  string argsfile;
1883 
1884  if ( args["args"] ) {
1885  argsfile = args["args"].AsString();
1886  if (CDirEntry(argsfile).Exists()) {
1887  argfile = true;
1889  } else {
1890  NCBI_THROW(CProjBulderAppException, eFileOpen,
1891  argsfile + " not found");
1892  }
1893  }
1894 
1895  root = args["root"].AsString();
1896  if (root == "\"\"") {
1897  root = "";
1898  }
1899  if (argfile && root.empty()) {
1900  m_CustomConfiguration.GetPathValue("__arg_root", root);
1901  }
1903  root : CDirEntry::ConcatPath( CDir::GetCwd(), root);
1907 
1908  m_Subtree = args["subtree"].AsString();
1909  if (m_Subtree == "\"\"") {
1910  m_Subtree = "";
1911  }
1915  }
1916  m_Solution = CDirEntry::NormalizePath(args["solution"].AsString());
1917  if (m_Solution == "\"\"") {
1918  m_Solution = "";
1919  }
1920  if (!m_Solution.empty() && !CDirEntry::IsAbsolutePath(m_Solution)) {
1922  }
1923 
1924  if (argfile) {
1925  string v;
1926  if (GetConfigPath().empty() &&
1927  m_CustomConfiguration.GetPathValue("__arg_conffile", v)) {
1928  if (!CDirEntry::IsAbsolutePath(v)) {
1930  }
1931  LoadConfig(GetRWConfig(),&v);
1932  }
1933  string subtree;
1934  m_CustomConfiguration.GetPathValue("__arg_subtree", subtree);
1935  if (m_Subtree.empty()) {
1936  m_Subtree = subtree;
1937  } else if (m_Subtree != subtree) {
1938  m_CustomConfiguration.RemoveDefinition("__AllowedProjects");
1939  }
1940  if (m_Solution.empty()) {
1941  m_CustomConfiguration.GetPathValue("__arg_solution", m_Solution);
1944  }
1945  }
1946 
1947  if (m_CustomConfiguration.GetValue("__arg_dll", v)) {
1949  }
1950  if (m_CustomConfiguration.GetValue("__arg_nobuildptb", v)) {
1952  }
1953 
1954  if (m_CustomConfiguration.GetValue("__arg_ext", v)) {
1956  }
1957  if (m_CustomConfiguration.GetValue("__arg_nws", v)) {
1959  }
1960  extroot = m_CustomConfiguration.GetPathValue("__arg_extroot", m_BuildRoot);
1961  m_CustomConfiguration.GetValue("__arg_projtag", m_ProjTags);
1962 
1963 #if defined(NCBI_COMPILER_MSVC) || defined(NCBI_XCODE_BUILD) || defined(PSEUDO_XCODE)
1964  if (m_CustomConfiguration.GetValue("__arg_ide", v)) {
1965  m_Ide = NStr::StringToInt(v);
1966  }
1967  m_CustomConfiguration.GetValue("__arg_arch", m_Arch);
1968 #endif
1969 
1970  if (m_CustomConfiguration.GetValue("__arg_dtdep", v)) {
1972  }
1973  if (m_CustomConfiguration.GetValue("__arg_noadddep", v)) {
1975  }
1976  if (m_CustomConfiguration.GetValue("__arg_libdep", v)) {
1978  }
1979  } else {
1980  m_Dll = (bool)args["dll"];
1981  m_BuildPtb = !((bool)args["nobuildptb"]);
1982  m_AddMissingLibs = (bool)args["ext"];
1983  m_ScanWholeTree = !((bool)args["nws"]);
1984  extroot = (bool)args["extroot"];
1985  if (extroot) {
1986  m_BuildRoot = args["extroot"].AsString();
1987  }
1988  if ( const CArgValue& t = args["projtag"] ) {
1989  m_ProjTags = t.AsString();
1990  m_ProjTagCmnd = true;
1991  } else {
1994  m_ProjTagCmnd = false;
1995  }
1996 #if defined(NCBI_COMPILER_MSVC) || defined(NCBI_XCODE_BUILD) || defined(PSEUDO_XCODE)
1997  const CArgValue& ide = args["ide"];
1998  if ((bool)ide) {
1999  m_Ide = ide.AsInteger();
2000  }
2001  const CArgValue& arch = args["arch"];
2002  if ((bool)arch) {
2003  m_Arch = arch.AsString();
2004  }
2005 #endif
2006  }
2007 
2009 
2010  string entry[] = {"","",""};
2012  entry[0] = "ThirdPartyBasePath";
2013  entry[1] = "ThirdParty_C_ncbi";
2014  }
2016  entry[0] = "XCode_ThirdPartyBasePath";
2017  entry[1] = "XCode_ThirdParty_C_ncbi";
2018  }
2019  if (argfile) {
2020  // this replaces path separators in entry[j] with a native one
2021  string v;
2022  for (int j=0; !entry[j].empty(); ++j) {
2023  if (m_CustomConfiguration.GetPathValue(entry[j], v)) {
2024  m_CustomConfiguration.AddDefinition(entry[j], v);
2025  }
2026  }
2027  }
2028 
2029  m_ConfirmCfg = false;
2030 #if defined(NCBI_COMPILER_MSVC)
2031  m_ConfirmCfg = (bool)args["cfg"];
2032 #endif
2033  m_InteractiveCfg = (bool)args["i"];
2034  m_Dtdep = (bool)args["dtdep"];
2035  m_AddMissingDep = !((bool)args["noadddep"]);
2036  m_LibDep = args["libdep"].AsBoolean();
2037 
2038  // Solution
2039  PTB_INFO("Solution: " << m_Solution);
2040  m_StatusDir =
2042  CDirEntry(m_Solution).GetDir(),".."),"status"));
2043 // m_BuildPtb = m_BuildPtb &&
2044 // CMsvc7RegSettings::GetMsvcVersion() == CMsvc7RegSettings::eMsvc710;
2045 
2046  if ( extroot ) {
2047  if (CDirEntry(m_BuildRoot).Exists()) {
2048 // verify status dir
2049  if (!CDirEntry(m_StatusDir).Exists() && !m_BuildRoot.empty()) {
2052  m_BuildRoot,".."),"status"));
2053  }
2054 
2055  string t, try_dir;
2056  string src = GetConfig().Get("ProjectTree", "src");
2057  for ( t = try_dir = m_BuildRoot; ; try_dir = t) {
2058  if (CDirEntry(
2059  CDirEntry::ConcatPath(try_dir, src)).Exists()) {
2060  m_ExtSrcRoot = try_dir;
2061  break;
2062  }
2063  t = CDirEntry(try_dir).GetDir();
2064  if (t == try_dir) {
2065  break;
2066  }
2067  }
2068  }
2069  }
2070  if (m_ProjTags.empty() || m_ProjTags == "\"\"" || m_ProjTags == "#") {
2071  m_ProjTags = "*";
2072  }
2073 
2074  string tmp(GetConfig().Get("ProjectTree", "CustomConfiguration"));
2075  if (!tmp.empty()) {
2077  }
2078  CDir sln_dir(CDirEntry(m_Solution).GetDir());
2079  if ( !sln_dir.Exists() ) {
2080  sln_dir.CreatePath();
2081  }
2082  if (!argfile) {
2083  if (CFile(m_CustomConfFile).Exists()) {
2085 
2086  string subtree;
2087  m_CustomConfiguration.GetPathValue("__arg_subtree", subtree);
2088  if (m_Subtree.empty()) {
2089  m_Subtree = subtree;
2090  } else if (m_Subtree != subtree) {
2091  m_CustomConfiguration.RemoveDefinition("__AllowedProjects");
2092  }
2093  } else {
2095  for (int j=0; !entry[j].empty(); ++j) {
2096  m_CustomConfiguration.AddDefinition(entry[j], GetSite().GetConfigureEntry(entry[j]));
2097  }
2098  }
2100  string vt = GetSite().IsProvided("TweakVTune", false) ? "yes" : "no";
2101  m_CustomConfiguration.AddDefinition("__TweakVTuneR", vt);
2102  m_CustomConfiguration.AddDefinition("__TweakVTuneD", vt);
2103  }
2104  }
2105 
2106  string v;
2107  v = GetConfigPath();
2108  if (CDirEntry::IsAbsolutePath(v)) {
2109  try {
2111  } catch (CFileException&) {
2112  }
2113  }
2114  m_CustomConfiguration.AddDefinition("__arg_conffile", v);
2115 
2116  m_CustomConfiguration.AddDefinition("__arg_root", root);
2117  m_CustomConfiguration.AddDefinition("__arg_subtree", m_Subtree);
2118  v = m_Solution;
2119  if (CDirEntry::IsAbsolutePath(v)) {
2120  try {
2122  } catch (CFileException&) {
2123  }
2124  }
2125  m_CustomConfiguration.AddDefinition("__arg_solution", v);
2126 
2127  m_CustomConfiguration.AddDefinition("__arg_dll", m_Dll ? "yes" : "no");
2128  m_CustomConfiguration.AddDefinition("__arg_nobuildptb", m_BuildPtb ? "no" : "yes");
2129  m_CustomConfiguration.AddDefinition("__arg_ext", m_AddMissingLibs ? "yes" : "no");
2130  m_CustomConfiguration.AddDefinition("__arg_nws", m_ScanWholeTree ? "no" : "yes");
2133 
2134 #if defined(NCBI_COMPILER_MSVC) || defined(NCBI_XCODE_BUILD) || defined(PSEUDO_XCODE)
2137 #endif
2138 
2139  m_CustomConfiguration.AddDefinition("__arg_dtdep", m_Dtdep ? "yes" : "no");
2140  m_CustomConfiguration.AddDefinition("__arg_noadddep", m_AddMissingDep ? "no" : "yes");
2141  m_CustomConfiguration.AddDefinition("__arg_libdep", m_LibDep ? "yes" : "no");
2142 
2143  // this replaces path separators in entry[j] with a native one
2144  for (int j=0; !entry[j].empty(); ++j) {
2145  if (m_CustomConfiguration.GetPathValue(entry[j], v)) {
2146  m_CustomConfiguration.AddDefinition(entry[j], v);
2147  }
2148  }
2149  }
2151  string v;
2152  if (m_CustomConfiguration.GetValue("__TweakVTuneR", v)) {
2154  }
2155  if (m_CustomConfiguration.GetValue("__TweakVTuneD", v)) {
2157  }
2158  m_AddUnicode = GetSite().IsProvided("Ncbi_Unicode", false) ||
2159  GetSite().IsProvided("Ncbi-Unicode", false);
2160  if (m_AddUnicode && !(
2161  GetSite().IsProvided("Ncbi_Unicode", false) &&
2162  GetSite().IsProvided("Ncbi-Unicode", false))) {
2163  //workaround to handle both
2164  string add;
2165  if (GetSite().IsProvided("Ncbi_Unicode", false)) {
2166  add = "Ncbi-Unicode";
2167  } else {
2168  add = "Ncbi_Unicode";
2169  }
2170  string section("__EnabledUserRequests");
2171  string value;
2173  if (!value.empty()) {
2174  value += " ";
2175  }
2176  value += add;
2178  }
2179  }
2180  tmp = GetConfig().Get("Configure", "UserRequests");
2181  if (!tmp.empty()) {
2182  m_CustomConfiguration.AddDefinition("__UserRequests", tmp);
2183  } else {
2184  m_CustomConfiguration.RemoveDefinition("__UserRequests");
2185  }
2186  if ( m_MsvcRegSettings.get() ) {
2187  GetBuildConfigs(&m_MsvcRegSettings->m_ConfigInfo);
2188  }
2189  m_AbsDirs.clear();
2190  for (int j=0; !entry[j].empty(); ++j) {
2191  string v;
2192  if (m_CustomConfiguration.GetPathValue(entry[j], v)) {
2193  m_AbsDirs.push_back(v);
2194  }
2195  }
2196 }
2197 
2199 {
2203  }
2204 
2209  } else {
2210  m_IncDir = CDirEntry::ConcatPath(m_IncDir,GetRegSettings().m_CompilersSubdir);
2212  }
2215 }
2216 
2217 
2218 int CProjBulderApp::EnumOpt(const string& enum_name,
2219  const string& enum_val) const
2220 {
2221  int opt = GetConfig().GetInt(enum_name, enum_val, -1);
2222  if (opt == -1) {
2223  NCBI_THROW(CProjBulderAppException, eEnumValue,
2224  enum_name + "::" + enum_val);
2225  }
2226  return opt;
2227 }
2228 
2229 
2231  const string& filename) const
2232 {
2233  CNcbiOfstream ofs(filename.c_str(), IOS_BASE::out | IOS_BASE::trunc);
2234  if ( !ofs ) {
2235  NCBI_THROW(CProjBulderAppException, eFileCreation, filename);
2236  }
2237 
2238  ITERATE(TFiles, p, files) {
2239  ofs << "+++++++++++++++++++++++++\n";
2240  ofs << p->first << endl;
2241  p->second.Dump(ofs);
2242  ofs << "-------------------------\n";
2243  }
2244 }
2245 
2246 bool CProjBulderApp::UseAbsolutePath(const string& path) const
2247 {
2248  ITERATE(list<string>, p, m_AbsDirs) {
2249  if (NStr::strncasecmp(path.c_str(), p->c_str(), p->length()) == 0) {
2250  return true;
2251  }
2252  }
2253  return false;
2254 }
2255 
2257 {
2259  if ( find(m_CustomMetaData.begin(), m_CustomMetaData.end(), s) ==
2260  m_CustomMetaData.end()) {
2261  m_CustomMetaData.push_back( s );
2262  }
2263 }
2264 
2265 void CProjBulderApp::GetMetaDataFiles(list<string>* files) const
2266 {
2267  *files = m_CustomMetaData;
2269  NStr::Split(GetConfig().Get("ProjectTree", "MetaData"), LIST_SEPARATOR,
2271  } else {
2272  string name(GetApp().GetSite().GetConfigureEntry("MetaData"));
2273  if (!name.empty()) {
2274  files->push_back( name);
2275  }
2276  }
2277 }
2278 
2280 {
2281  m_CustomConfH.push_back(file);
2282 }
2283 
2284 void CProjBulderApp::GetCustomConfH(list<string>* files) const
2285 {
2286  *files = m_CustomConfH;
2287 }
2288 
2289 
2290 void CProjBulderApp::GetBuildConfigs(list<SConfigInfo>* configs)
2291 {
2292  configs->clear();
2293  string name = m_Dll ? "DllConfigurations" : "Configurations";
2294  const string& config_str
2296  list<string> configs_list;
2298  LoadConfigInfoByNames(GetConfig(), configs_list, configs);
2299 }
2300 
2301 
2303 {
2304  if ( !m_MsvcRegSettings.get() ) {
2305  m_MsvcRegSettings.reset(new CMsvc7RegSettings());
2306 
2307  string section(CMsvc7RegSettings::GetMsvcRegSection());
2308 
2309  m_MsvcRegSettings->m_MakefilesExt =
2310  GetConfig().GetString(section, "MakefilesExt", "msvc");
2311 
2312  m_MsvcRegSettings->m_ProjectsSubdir =
2313  GetConfig().GetString(section, "Projects", "build");
2314 
2316  GetConfig().Get(section, "MetaMakefile"));
2317 
2318  m_MsvcRegSettings->m_DllInfo =
2319  GetConfig().Get(section, "DllInfo");
2320 
2321  m_MsvcRegSettings->m_Version = NStr::Replace(
2323  "\\n", "\n");
2324 
2325  m_MsvcRegSettings->m_CompilersSubdir =
2327 
2328  GetBuildConfigs(&m_MsvcRegSettings->m_ConfigInfo);
2329  }
2330  return *m_MsvcRegSettings;
2331 }
2332 
2333 
2335 {
2336  if ( !m_MsvcSite.get() ) {
2337  m_MsvcSite.reset(new CMsvcSite(GetConfigPath()));
2338  }
2339 
2340  return *m_MsvcSite;
2341 }
2342 
2343 
2345 {
2346  if ( !m_MsvcMetaMakefile.get() ) {
2347  //Metamakefile must be in RootSrc directory
2350  GetRegSettings().m_MetaMakefile)));
2351 
2352  //Metamakefile must present and must not be empty
2353  if ( m_MsvcMetaMakefile->IsEmpty() )
2355  eMetaMakefile, GetRegSettings().m_MetaMakefile);
2356  }
2357 
2358  return *m_MsvcMetaMakefile;
2359 }
2360 
2361 
2363 {
2364  if ( m_ProjectTreeInfo.get() )
2365  return *m_ProjectTreeInfo;
2366 
2368 
2369  // Root, etc.
2370  m_ProjectTreeInfo->m_Root = m_Root;
2371  PTB_INFO("Project tree root: " << m_Root);
2372 
2373  // all possible project tags
2374  string tagsfile = CDirEntry::ConvertToOSPath(
2375  GetConfig().Get("ProjectTree", "ProjectTags"));
2376  if (!tagsfile.empty()) {
2377  string fileloc(CDirEntry::ConcatPath(m_ProjectTreeInfo->m_Root, tagsfile));
2378  if (!CDirEntry(fileloc).Exists() && !m_ExtSrcRoot.empty()) {
2379  fileloc = CDirEntry::ConcatPath(m_ExtSrcRoot,tagsfile);
2380  }
2381  LoadProjectTags(fileloc);
2382  }
2383 
2384  //dependencies
2385  list<string> depsfile;
2386  if (!FindDepGraph(m_ProjectTreeInfo->m_Root, depsfile) && !m_ExtSrcRoot.empty()) {
2387  FindDepGraph(m_ExtSrcRoot, depsfile);
2388  }
2389  if (!depsfile.empty()) {
2390  ITERATE(list<string>, d, depsfile) {
2391  PTB_INFO("Library dependencies graph: " << *d);
2392  LoadDepGraph(*d);
2393  }
2394  }
2395 
2396  /// <include> branch of tree
2397  string include = GetConfig().Get("ProjectTree", "include");
2398  m_ProjectTreeInfo->m_Include =
2400  include);
2401  m_ProjectTreeInfo->m_Include =
2403 
2404 
2405  /// <src> branch of tree
2406  string src = GetConfig().Get("ProjectTree", "src");
2407  m_ProjectTreeInfo->m_Src =
2409  src);
2410  m_ProjectTreeInfo->m_Src =
2412 
2413  // Subtree to build - projects filter
2414  string subtree = CDirEntry::ConcatPath(m_ProjectTreeInfo->m_Root, m_Subtree);
2415  PTB_INFO("Project list or subtree: " << subtree);
2416  if (!CDirEntry(subtree).Exists()) {
2417  PTB_WARNING_EX(kEmptyStr, ePTB_PathNotFound, "subtree does not exist: "<< subtree);
2418  }
2419  m_ProjectTreeInfo->m_IProjectFilter.reset(
2420  new CProjectsLstFileFilter(m_ProjectTreeInfo->m_Src, subtree));
2421 
2422  /// <compilers> branch of tree
2423  string compilers = GetConfig().Get("ProjectTree", "compilers");
2424  m_ProjectTreeInfo->m_Compilers =
2426  compilers);
2427  m_ProjectTreeInfo->m_Compilers =
2429  (m_ProjectTreeInfo->m_Compilers);
2430 
2431  /// ImplicitExcludedBranches - all subdirs will be excluded by default
2432  string implicit_exclude_str
2433  = GetConfig().Get("ProjectTree", "ImplicitExclude");
2434  list<string> implicit_exclude_list;
2435  NStr::Split(implicit_exclude_str,
2436  LIST_SEPARATOR,
2437  implicit_exclude_list, NStr::fSplit_MergeDelimiters | NStr::fSplit_Truncate);
2438  ITERATE(list<string>, p, implicit_exclude_list) {
2439  const string& subdir = *p;
2440  string dir = CDirEntry::ConcatPath(m_ProjectTreeInfo->m_Src,
2441  subdir);
2443  m_ProjectTreeInfo->m_ImplicitExcludedAbsDirs.push_back(dir);
2444  }
2445 
2446  /// <projects> branch of tree (scripts\projects)
2447  string projects = CDirEntry::ConvertToOSPath(
2448  GetConfig().Get("ProjectTree", "projects"));
2449  m_ProjectTreeInfo->m_Projects =
2451  projects);
2452  m_ProjectTreeInfo->m_Projects =
2454  (m_ProjectTreeInfo->m_Compilers);
2455 
2456  /// impl part if include project node
2457  m_ProjectTreeInfo->m_Impl =
2458  GetConfig().Get("ProjectTree", "impl");
2459 
2460  /// Makefile in tree node
2461  m_ProjectTreeInfo->m_TreeNode =
2462  GetConfig().Get("ProjectTree", "TreeNode");
2463 
2464  m_ProjectTreeInfo->m_CustomMetaData =
2465  GetConfig().Get("ProjectTree", "CustomMetaData");
2466  m_ProjectTreeInfo->m_CustomConfH =
2467  GetConfig().Get("ProjectTree", "CustomConfH");
2468 
2469  return *m_ProjectTreeInfo;
2470 }
2471 
2472 
2474 {
2475  if ( !m_BuildType.get() ) {
2476  m_BuildType.reset(new CBuildType(m_Dll));
2477  }
2478  return *m_BuildType;
2479 }
2480 
2482 {
2483  if ( !m_WholeTree.get() ) {
2484  m_WholeTree.reset(new CProjectItemsTree);
2485  if (m_ScanWholeTree) {
2486  m_ScanningWholeTree = true;
2487  CProjectsLstFileFilter pass_all_filter(m_ProjectTreeInfo->m_Src, m_ProjectTreeInfo->m_Src);
2488 // pass_all_filter.SetExcludePotential(false);
2489  CProjectTreeBuilder::BuildProjectTree(&pass_all_filter,
2490  GetProjectTreeInfo().m_Src,
2491  m_WholeTree.get());
2492  m_ScanningWholeTree = false;
2493  }
2494  }
2495  return *m_WholeTree;
2496 }
2497 
2498 
2500 {
2501  if (m_DllSrcFilesDistr.get())
2502  return *m_DllSrcFilesDistr;
2503 
2504  m_DllSrcFilesDistr.reset ( new CDllSrcFilesDistr() );
2505  return *m_DllSrcFilesDistr;
2506 }
2507 
2509 {
2510  return "_generate_all_objects";
2511 }
2512 
2514 {
2515  return GetConfig().GetString("Datatool", "datatool",
2517 }
2518 
2519 
2521 {
2523  return GetConfig().GetString("Datatool", "Location.xcode", "datatool");
2524  }
2525  return GetConfig().GetString("Datatool", "Location.App", "datatool.exe");
2526 }
2527 
2528 
2530 {
2532  return GetConfig().GetString("Datatool", "Location.xcode", "datatool");
2533  }
2534  return GetConfig().GetString("Datatool", "Location.Lib", "datatool.exe");
2535 }
2536 
2537 
2539 {
2541  return GetConfig().GetString("Datatool", "CommandLine.xcode", "");
2542  }
2543  return GetConfig().Get("Datatool", "CommandLine");
2544 }
2545 
2547 {
2548  string path = CDirEntry::ConcatPath(
2549  m_ProjectTreeInfo->m_Compilers,
2550  m_MsvcRegSettings->m_CompilersSubdir);
2552 }
2553 
2555  const CProjItem& project, const string* filter /*= NULL*/) const
2556 {
2557  // verify that all project tags are registered
2558  list<string>::const_iterator i;
2559  for (i = project.m_ProjTags.begin(); i != project.m_ProjTags.end(); ++i) {
2561  NCBI_THROW(CProjBulderAppException, eUnknownProjectTag,
2562  project.GetPath() + ": Unregistered project tag: " + *i);
2563  return false;
2564  }
2565  }
2566 
2567  if (filter == NULL) {
2568  filter = &m_ProjTags;
2569  }
2570  // no filter - everything is allowed
2571  if (filter->empty() || *filter == "*") {
2572  return true;
2573  }
2574 
2575  CExprParser parser;
2577  parser.AddSymbol(p->c_str(),
2578  find( project.m_ProjTags.begin(), project.m_ProjTags.end(), *p) != project.m_ProjTags.end());
2579  }
2580  parser.Parse(filter->c_str());
2581  return parser.GetResult().GetBool();
2582 }
2583 
2584 void CProjBulderApp::LoadProjectTags(const string& filename)
2585 {
2586  CNcbiIfstream ifs(filename.c_str(), IOS_BASE::in | IOS_BASE::binary);
2587  if ( ifs.is_open() ) {
2588  string line;
2589  while ( NcbiGetlineEOL(ifs, line) ) {
2590  if (line.empty() || line[0] == '#') {
2591  continue;
2592  }
2593  list<string> values;
2594  if (line.find('=') != string::npos) {
2596  if (values.size() > 1) {
2597  string first = NStr::TruncateSpaces(values.front());
2598  string second = NStr::TruncateSpaces(values.back());
2599  m_CompositeProjectTags[first] = second;
2600 
2601  }
2602  continue;
2603  }
2605  ITERATE(list<string>,v,values) {
2607  }
2608  }
2609  }
2613  m_RegisteredProjectTags.insert("public");
2614  m_RegisteredProjectTags.insert("internal");
2615 }
2616 
2617 bool CProjBulderApp::FindDepGraph(const string& root, list<string>& found) const
2618 {
2619  found.clear();
2620  list<string> locations;
2621  string locstr(GetConfig().Get("ProjectTree", "DepGraph"));
2623  for (list<string>::const_iterator l = locations.begin(); l != locations.end(); ++l) {
2625  if (fileloc.Exists() && fileloc.IsFile()) {
2626  found.push_back(fileloc.GetPath());
2627  }
2628  }
2629  return !found.empty();
2630 }
2631 
2632 void CProjBulderApp::LoadDepGraph(const string& filename)
2633 {
2634  const CMsvcSite& site = GetSite();
2635  CNcbiIfstream ifs(filename.c_str(), IOS_BASE::in);
2636  if ( ifs.is_open() ) {
2637  string line;
2638  while ( NcbiGetlineEOL(ifs, line) ) {
2639  if (line.empty() || line[0] == '#') {
2640  continue;
2641  }
2642  list<string> values;
2644  if (values.size() < 2) {
2645  continue;
2646  }
2647  list<string>::const_iterator l= values.begin();
2648  string first = *l++;
2649  string second = *l++;
2650  string third = values.size() > 2 ? (*l++) : string();
2651 
2652  list<string> first_list;
2654  string resolved;
2655  site.ResolveDefine(CSymResolver::StripDefine(first), resolved);
2656  first = resolved;
2657  }
2659 
2660  list<string> third_list;
2661 #if DO_PATCHTREEMAKEFILES
2662  if (!third.empty()) {
2663  third_list.push_back(third);
2664  }
2665 #else
2666  if (CSymResolver::IsDefine(third)) {
2667  string resolved;
2669  string stripped(CSymResolver::StripDefine(third));
2670  if (stripped != "NCBI_C_ncbi") {
2671  site.ResolveDefine(stripped, resolved);
2672  }
2673  if (resolved.empty()) {
2674  resolved = "@" + stripped + "@";
2675  }
2676  } else {
2677  site.ResolveDefine(CSymResolver::StripDefine(third), resolved);
2678  }
2679  third = resolved;
2680  }
2682 #endif
2683  ITERATE(list<string>, f, first_list) {
2684  string f_name(*f);
2685  if (NStr::StartsWith(*f, "-l")) {
2686  f_name = f->substr(2);
2687  } else if (NStr::FindCase(*f,"-framework") != NPOS) {
2688  list<string> f_list;
2690  f_name = f_list.back();
2691  } else if (f->at(0) == '-') {
2692  continue;
2693  }
2694  map<string, set<string> > lib3Precedes;
2695  CSymResolver::StripSuffix(f_name);
2696  if (third_list.empty() && m_GraphDepPrecedes.find(f_name) == m_GraphDepPrecedes.end()) {
2697  m_GraphDepPrecedes[f_name] = set<string>();
2698  }
2699  ITERATE(list<string>, t, third_list) {
2700  string t_name(*t);
2701  CSymResolver::StripSuffix(t_name);
2702  bool is_lib = false;
2703  bool is_framework = false;
2704  if (NStr::StartsWith(*t, "-l")) {
2705  is_lib = true;
2706  t_name = t_name.substr(2);
2707  } else if (NStr::CompareNocase(*t,"-framework") == 0) {
2708  if (t != third_list.end()) {
2709  is_framework = true;
2710  t_name = *(++t);
2711  } else {
2712  continue;
2713  }
2714  } else {
2715  is_lib = t->at(0) != '-';
2716  }
2717  if (*f == t_name) {
2718  continue;
2719  }
2720  if (!is_lib && !is_framework) {
2721  if (second == "needs3party") {
2722  m_GraphDepFlags[*f].insert(t_name);
2723  }
2724  continue;
2725  }
2726  if (second == "includes") {
2727  m_GraphDepIncludes[*f].insert(t_name);
2728  } else if (second == "includes3party") {
2729  m_GraphDepIncludes[*f].insert(t_name);
2730  m_3PartyLibs.insert(t_name);
2731  if (is_framework) {
2732  m_Frameworks.insert(t_name);
2733  }
2734  } else if (second == "needs") {
2735  m_GraphDepPrecedes[*f].insert(t_name);
2736  } else if (second == "needs3party") {
2737  m_GraphDepPrecedes[*f].insert(t_name);
2738  m_3PartyLibs.insert(t_name);
2739  if (is_framework) {
2740  m_Frameworks.insert(t_name);
2741  }
2742  }
2743  }
2744  }
2745  }
2746  }
2747  for ( map<string, set<string> >::const_iterator i = m_GraphDepIncludes.begin();
2748  i != m_GraphDepIncludes.end(); ++i) {
2749  const set<string>& inc = i->second;
2750  for (set<string>::const_iterator m = inc.begin(); m != inc.end(); ++m) {
2751  CollectDep(i->first, *m);
2752  }
2753  }
2754 // RankDepGraph();
2755 }
2756 
2757 void CProjBulderApp::CollectDep(const string& libname, const string& incname)
2758 {
2759  if (incname[0] == '@') {
2760  return;
2761  }
2762  const set<string>& deps = m_GraphDepPrecedes[incname];
2763  for (set<string>::const_iterator d = deps.begin(); d != deps.end(); ++d) {
2764  m_GraphDepPrecedes[libname].insert(*d);
2765  }
2766  if (m_GraphDepFlags.find(incname) != m_GraphDepFlags.end()) {
2767  const set<string>& flags = m_GraphDepFlags[incname];
2768  for (set<string>::const_iterator d = flags.begin(); d != flags.end(); ++d) {
2769  m_GraphDepFlags[libname].insert(*d);
2770  }
2771  }
2772  if (m_GraphDepIncludes.find(incname) != m_GraphDepIncludes.end()) {
2773  const set<string>& inc = m_GraphDepIncludes.find(incname)->second;
2774  for (set<string>::const_iterator m = inc.begin(); m != inc.end(); ++m) {
2775  CollectDep(libname, *m);
2776  }
2777  }
2778 }
2779 
2781 {
2782 #if DO_PATCHTREEMAKEFILES
2783  return;
2784 #endif
2785  if (!IsScanningWholeTree()) {
2786  return;
2787  }
2788  const CMsvcSite& site = GetSite();
2790  const CSimpleMakeFileContents& fc( f->second);
2791  string libname;
2792  fc.GetValue("LIB", libname);
2793  list<string> libdep;
2794  fc.GetValue("USES_LIBRARIES", libdep);
2795  if (!libdep.empty()) {
2796  if (m_GraphDepPrecedes.find(libname) == m_GraphDepPrecedes.end()) {
2797  set<string> t;
2798  m_GraphDepPrecedes[libname] = t;
2799  }
2800  ITERATE(list<string>, l, libdep) {
2801  list<string> dep_list;
2802  string dep(*l);
2803  if (dep.at(0) == '#') {
2804  break;
2805  }
2806  if (CSymResolver::IsDefine(dep)) {
2807  string resolved;
2809  string stripped(CSymResolver::StripDefine(dep));
2810  if (stripped != "NCBI_C_ncbi") {
2811  site.ResolveDefine(stripped, resolved);
2812  }
2813  if (resolved.empty()) {
2814  resolved = "@" + stripped + "@";
2815  }
2816  } else {
2817  site.ResolveDefine(CSymResolver::StripDefine(dep), resolved);
2818  }
2819  dep = resolved;
2820  }
2822  ITERATE(list<string>, d, dep_list) {
2823  string dep_name = NStr::StartsWith(*d, "-l") ? d->substr(2) : *d;
2824  CSymResolver::StripSuffix(dep_name);
2825  if (dep_name.at(0) == '-' || libname == dep_name) {
2826  continue;
2827  }
2828  m_GraphDepPrecedes[libname].insert(dep_name);
2829  }
2830  }
2831  }
2832  }
2833  RankDepGraph();
2834 }
2835 
2837 {
2838 #if DO_PATCHTREEMAKEFILES
2839  return;
2840 #endif
2842  return;
2843  }
2844  vector< set<string> > graph;
2845  for (map<string, set<string> >::const_iterator d= m_GraphDepPrecedes.begin();
2846  d!= m_GraphDepPrecedes.end(); ++d) {
2847  list<string> done;
2848  done.push_back(d->first);
2849  InsertDep(graph, d->first, done);
2850  }
2851  for (size_t s= 0; s<graph.size(); ++s) {
2852  for (set<string>::const_iterator l = graph[s].begin(); l != graph[s].end(); ++l) {
2853  m_GraphDepRank[*l] = s;
2854  }
2855  }
2856 }
2857 
2858 bool CProjBulderApp::InsertDep(vector< set<string> >& graph, const string& dep, list<string>& done)
2859 {
2860  const set<string>& dependents = m_GraphDepPrecedes[dep];
2861  size_t graphset=0;
2862  for (set<string>::const_iterator d = dependents.begin(); d != dependents.end(); ++d) {
2864  continue;
2865  }
2866  if (find(done.begin(), done.end(), *d) != done.end()) {
2867  done.push_back(*d);
2869  "Library dependency cycle found: " << NStr::Join(done, " - "));
2870  done.pop_back();
2871  //m_GraphDepPrecedes.erase(*d);
2872  return false;
2873  }
2874  done.push_back(*d);
2875  for (bool found=false; !found; ) {
2876  for (size_t s= 0; !found && s<graph.size(); ++s) {
2877  if (graph[s].find(*d) != graph[s].end()) {
2878  graphset = max(graphset,s);
2879  found = true;
2880  }
2881  }
2882  if (!found) {
2883  found = !InsertDep(graph, *d, done);
2884  }
2885  }
2886  done.pop_back();
2887  }
2888  if (!dependents.empty()) {
2889  ++graphset;
2890  }
2891  if (graphset < graph.size()) {
2892  graph[graphset].insert(dep);
2893  } else {
2894  set<string> t;
2895  t.insert(dep);
2896  graph.push_back(t);
2897  }
2898  return true;
2899 }
2900 
2902 {
2903  string data(raw_data), raw_macro, macro, definition;
2904  string::size_type start, end, done = 0;
2905  while ((start = data.find("$(", done)) != string::npos) {
2906  end = data.find(")", start);
2907  if (end == string::npos) {
2908  PTB_WARNING_EX(kEmptyStr, ePTB_MacroInvalid, "Possibly incorrect MACRO definition in: " + raw_data);
2909  return data;
2910  }
2911  raw_macro = data.substr(start,end-start+1);
2912  if (CSymResolver::IsDefine(raw_macro)) {
2913  macro = CSymResolver::StripDefine(raw_macro);
2914  definition.erase();
2915  definition = GetConfig().GetString(CMsvc7RegSettings::GetMsvcSection(), macro, "");
2916  if (!definition.empty()) {
2917  definition = CDirEntry::ConcatPath(
2918  m_ProjectTreeInfo->m_Compilers, definition);
2919  data = NStr::Replace(data, raw_macro, definition);
2920  } else {
2921  done = end;
2922  }
2923  }
2924  }
2925  return data;
2926 }
2927 
2929 {
2930  string definition = GetConfig().GetString(CMsvc7RegSettings::GetMsvcSection(), data, "");
2931  if (!definition.empty()) {
2932  definition = CDirEntry::ConcatPath( m_ProjectTreeInfo->m_Compilers, definition);
2933  }
2934  return definition;
2935 }
2936 
2938 {
2939  m_SuspiciousProj.insert(proj);
2940 }
2941 
2943 {
2944  m_GeneratedFiles.push_back(file);
2945 }
2946 
2948  const string& project, const string& dir, const string& watcher)
2949 {
2950  if (watcher.empty()) {
2951  return;
2952  }
2953  string sep;
2954  sep += CDirEntry::GetPathSeparator();
2955  string root(GetProjectTreeInfo().m_Src);
2956  if (!CDirEntry::IsAbsolutePath(root)) {
2957  root = CDirEntry::ConcatPath(CDir::GetCwd(), root);
2958  }
2959  string path(dir);
2960  if (!CDirEntry::IsAbsolutePath(path)) {
2961  path = CDirEntry::ConcatPath(CDir::GetCwd(), path);
2962  }
2964  CDirEntry::CreateRelativePath(root, path));
2965  NStr::ReplaceInPlace( path, sep, "/");
2966  m_ProjWatchers.push_back( project + ", " + path + ", " + watcher );
2967 }
2968 
2970 {
2971  EraseIf(tree.m_Projects, PIsExcludedByTag());
2972  if (!m_ProjTags.empty() && m_ProjTags != "*") {
2974  if (p->second.m_ProjType == CProjKey::eDll) {
2975  p->second.m_External = false;
2976  }
2977  }
2978  }
2979 }
2980 
2982 {
2983  EraseIf(tree.m_Projects, PIsExcludedByUser());
2984 }
2985 
2987 {
2988  string utility_projects_dir = CDirEntry(m_Solution).GetDir();
2989  utility_projects_dir =
2990  CDirEntry::ConcatPath(utility_projects_dir, "UtilityProjects");
2991  utility_projects_dir =
2992  CDirEntry::AddTrailingPathSeparator(utility_projects_dir);
2993  return utility_projects_dir;
2994 }
2995 
2997 {
2998  string prj = GetProjectTreeInfo().m_Compilers;
2999  prj = CDirEntry::ConcatPath(prj, GetRegSettings().m_CompilersSubdir);
3000  prj = CDirEntry::ConcatPath(prj, GetBuildType().GetTypeStr());
3001  prj = CDirEntry::ConcatPath(prj, GetRegSettings().m_ProjectsSubdir);
3002 
3003  string sln = CDirEntry(m_Solution).GetDir();
3004  prj = CDirEntry::CreateRelativePath( prj, sln);
3005  prj = CDirEntry::ConcatPath(GetProjectTreeInfo().m_Src, prj);
3006  prj = CDirEntry::ConcatPath(prj, "UtilityProjects");
3008  return prj;
3009 }
3010 
3011 void CProjBulderApp::SetConfFileData(const string& src, const string& dest)
3012 {
3013  m_ConfSrc = src;
3014  m_ConfDest= dest;
3015 }
3016 
3018 {
3021  GetProjectTreeInfo().m_Compilers, GetRegSettings().m_CompilersSubdir),
3022  GetBuildType().GetTypeStr()), GetRegSettings().m_ProjectsSubdir));
3023 }
3024 
3026 {
3027  static CProjBulderApp theApp;
3028  return theApp;
3029 }
3030 
3032 
3033 
3035 
3036 int NcbiSys_main(int argc, TXChar* argv[])
3037 {
3038  // Execute main application function
3041  return GetApp().AppMain(argc, argv);
3042 }
AutoPtr –.
Definition: ncbimisc.hpp:401
CArgDescriptions –.
Definition: ncbiargs.hpp:541
CArgValue –.
Definition: ncbiargs.hpp:184
CArgs –.
Definition: ncbiargs.hpp:379
Utility class for distinguish between static and dll builds.
EBuildType GetType(void) const
static void FindCyclesNew(const TProjects &tree, TDependsCycles *cycles)
Definition: proj_tree.cpp:350
list< CProjKey > TDependsChain
Definition: proj_tree.hpp:116
CDirEntry –.
Definition: ncbifile.hpp:262
CDir –.
Definition: ncbifile.hpp:1695
Distribution if source files by lib projects Uses in dll project to separate source files to groups b...
void Parse(const char *str)
Definition: expr.cpp:738
CExprSymbol * AddSymbol(const char *name, VT value)
Definition: expr.hpp:382
const CExprValue & GetResult(void) const
Definition: expr.hpp:289
bool GetBool(void) const
Definition: expr.hpp:135
CFileException –.
Definition: ncbifile.hpp:136
CFile –.
Definition: ncbifile.hpp:1604
static void PatchTreeMakefiles(const CProjectItemsTree &prj_tree)
Definition: proj_tree.cpp:976
CMsvc7RegSettings –.
static string GetVcprojExt(void)
static EMsvcPlatform GetMsvcPlatform(void)
list< SConfigInfo > m_ConfigInfo
static string GetMsvcSection(void)
static const string & GetMsvcPlatformName(void)
static void IdentifyPlatform(void)
static string GetConfigNameKeyword(void)
static EMsvcVersion GetMsvcVersion(void)
static string GetMsvcRegSection(void)
virtual bool IsExcludeProject(bool default_val) const
Configurator for msvc projects:
void Configure(CMsvcSite &site, const list< SConfigInfo > &configs, const string &root_dir)
void CreateConfH(CMsvcSite &site, const list< SConfigInfo > &configs, const string &root_dir)
CMsvcMetaMakefile –.
CMsvcPrjProjectContext –.
static const set< string > & GetEnabledPackages(const string &config_name)
static bool IsRequiresOk(const CProjItem &prj, string *unmet)
static const set< string > & GetDisabledPackages(const string &config_name)
const CMsvcCombinedProjectMakefile & GetMsvcProjectMakefile(void) const
CMsvcSite –.
Definition: msvc_site.hpp:131
void GetStandardFeatures(list< string > &features) const
Definition: msvc_site.cpp:727
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
void GetConfigurableRequests(list< string > &features) const
Definition: msvc_site.cpp:734
static CNcbiApplication * Instance(void)
Singleton method.
Definition: ncbiapp.cpp:264
CProjBulderAppException –.
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
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.
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
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 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)
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
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
list< CProjKey > m_Depends
What projects this project is depend upon (IDs).
Definition: proj_item.hpp:102
bool m_External
Definition: proj_item.hpp:148
TProjType m_ProjType
Type of the project.
Definition: proj_item.hpp:89
EMakeFileType m_MakeType
Type of the project.
Definition: proj_item.hpp:125
string m_ID
ID of atomic project.
Definition: proj_item.hpp:86
string GetPath(void) const
Definition: proj_item.cpp:237
string m_GUID
project GUID
Definition: proj_item.hpp:128
set< string > m_CheckConfigs
Definition: proj_item.hpp:138
list< string > m_ProjTags
Definition: proj_item.hpp:143
string m_Name
Name of atomic project.
Definition: proj_item.hpp:83
string m_SourcesBaseDir
Base directory of source files (....c++/src/a/ )
Definition: proj_item.hpp:92
list< string > m_CheckInfo
Definition: proj_item.hpp:137
CProjKey –.
const string & Id(void) const
Definition: proj_item.cpp:112
CProjectItemsTree –.
Definition: proj_tree.hpp:54
void VerifyDataspecProj(void)
Definition: proj_tree.cpp:310
TProjects m_Projects
Definition: proj_tree.hpp:70
void VerifyExternalDepends(void)
Definition: proj_tree.cpp:266
static bool VerifyBuildOrder(const CProjItem &item, list< string > dependencies, const CProjectItemsTree &tree)
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 string GetAllowedTagsInfo(const string &file_full_path)
CSimpleMakeFileContents –.
static void LoadFrom(const string &file_path, CSimpleMakeFileContents *fc)
void RemoveDefinition(const string &key)
bool GetPathValue(const string &key, string &value) const
void AddDefinition(const string &key, const string &value)
bool GetValue(const string &key, string &value) const
void Save(const string &filename) const
CStopWatch –.
Definition: ncbitime.hpp:1938
static string StripDefine(const string &define)
Definition: resolver.cpp:75
static bool StripSuffix(string &libname, string *suffix=nullptr)
Definition: resolver.cpp:243
static bool IsDefine(const string &param)
Definition: resolver.cpp:258
CTempString implements a light-weight string on top of a storage buffer whose lifetime management is ...
Definition: tempstr.hpp:65
CTime –.
Definition: ncbitime.hpp:296
CVersionInfo –.
CVisualStudioProject –.
Windows-specific command-line logger This is used to format error output in such a way that the Windo...
unique_ptr< CDiagHandler > m_OrigHandler
string m_AppName
the original diagnostics handler
void Post(const SDiagMessage &msg)
post a message
const_iterator begin() const
Definition: map.hpp:151
const_iterator end() const
Definition: map.hpp:152
iterator_bool insert(const value_type &val)
Definition: map.hpp:165
bool empty() const
Definition: map.hpp:149
const_iterator find(const key_type &key) const
Definition: map.hpp:153
Definition: map.hpp:338
Definition: set.hpp:45
iterator_bool insert(const value_type &val)
Definition: set.hpp:149
const_iterator begin() const
Definition: set.hpp:135
bool empty() const
Definition: set.hpp:133
const_iterator find(const key_type &key) const
Definition: set.hpp:137
const_iterator end() const
Definition: set.hpp:136
pre_order_iterator end() const
Definition: tree_msvc7.hpp:579
void Print(const CCompactSAMApplication::AlignInfo &ai)
bool CreateConfigurableFile(const string &src_path, const string &dst_path, const string &config_name)
string ConfigurableFileSuffix(const string &config_name)
static uch flags
std::ofstream out("events_result.xml")
main entry point for tests
@ eMakeType_Expendable
@ eMakeType_Excluded
@ eMakeType_ExcludedByReq
static CS_COMMAND * cmd
Definition: ct_dynamic.c:26
#define bool
Definition: bool.h:34
static DLIST_TYPE *DLIST_NAME() first(DLIST_LIST_TYPE *list)
Definition: dlist.tmpl.h:46
static DLIST_TYPE *DLIST_NAME() last(DLIST_LIST_TYPE *list)
Definition: dlist.tmpl.h:51
static DLIST_TYPE *DLIST_NAME() prev(DLIST_LIST_TYPE *list, DLIST_TYPE *item)
Definition: dlist.tmpl.h:61
static int trunc
Definition: array_out.c:8
static const char * str(char *buf, int n)
Definition: stats.c:84
static char tmp[3200]
Definition: utf8.c:42
char data[12]
Definition: iconv.c:80
const CNcbiEnvironment & GetEnvironment(void) const
Get the application's cached environment.
const CNcbiRegistry & GetConfig(void) const
Get the application's cached configuration parameters (read-only).
virtual const CArgs & GetArgs(void) const
Get parsed command line arguments.
Definition: ncbiapp.cpp:305
int AppMain(int argc, const char *const *argv, const char *const *envp=0, EAppDiagStream diag=eDS_Default, const char *conf=NcbiEmptyCStr, const string &name=NcbiEmptyString)
Main function (entry point) for the NCBI application.
Definition: ncbiapp.cpp:819
CVersionInfo GetVersion(void) const
Get the program version information.
Definition: ncbiapp.cpp:1184
virtual void SetupArgDescriptions(CArgDescriptions *arg_desc)
Setup the command line argument descriptions.
Definition: ncbiapp.cpp:1195
virtual bool LoadConfig(CNcbiRegistry &reg, const string *conf, CNcbiRegistry::TFlags reg_flags)
Load settings from the configuration file to the registry.
Definition: ncbiapp.cpp:1226
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
const string & GetConfigPath(void) const
Get the full path to the configuration file (if any) we ended up using.
const string & GetProgramDisplayName(void) const
Get the application's "display" name.
CNcbiRegistry & GetRWConfig(void)
Get the application's cached configuration parameters, accessible for read-write for an application's...
#define NON_CONST_ITERATE(Type, Var, Cont)
Non constant version of ITERATE macro.
Definition: ncbimisc.hpp:822
const CNcbiArguments & GetArguments(void) const
Get the application's cached unprocessed command-line arguments.
void SetVersion(const CVersionInfo &version)
Set the version number for the program.
Definition: ncbiapp.cpp:1155
virtual const string & AsString(void) const =0
Get the argument's string value.
virtual int AsInteger(void) const =0
Get the argument's integer value.
@ eBoolean
{'true', 't', 'false', 'f'}, case-insensitive
Definition: ncbiargs.hpp:590
@ eString
An arbitrary string.
Definition: ncbiargs.hpp:589
@ eInteger
Convertible into an integer number (int or Int8)
Definition: ncbiargs.hpp:592
#define NULL
Definition: ncbistd.hpp:225
#define _TRACE(message)
Definition: ncbidbg.hpp:122
int m_ErrCode
Error code.
Definition: ncbidiag.hpp:1659
const char * m_File
File name.
Definition: ncbidiag.hpp:1654
const char * m_Buffer
Not guaranteed to be '\0'-terminated!
Definition: ncbidiag.hpp:1652
CDiagContext & GetDiagContext(void)
Get diag context instance.
Definition: logging.cpp:818
void SetLogRate_Limit(ELogRate_Type type, unsigned int limit)
Definition: ncbidiag.cpp:1380
size_t m_Line
Line number in file.
Definition: ncbidiag.hpp:1658
EDiagSev m_Severity
Severity level.
Definition: ncbidiag.hpp:1651
CDiagHandler * GetDiagHandler(bool take_ownership=false, bool *current_ownership=0)
Get the currently set diagnostic handler class.
Definition: ncbidiag.cpp:6329
size_t m_BufferLen
Length of m_Buffer.
Definition: ncbidiag.hpp:1653
EDiagSev SetDiagPostLevel(EDiagSev post_sev=eDiag_Error)
Set the threshold severity for posting the messages.
Definition: ncbidiag.cpp:6129
void SetDiagHandler(CDiagHandler *handler, bool can_delete=true)
Set the diagnostic handler using the specified diagnostic handler class.
Definition: ncbidiag.cpp:6288
TDiagPostFlags SetDiagPostAllFlags(TDiagPostFlags flags)
Set global post flags to "flags".
Definition: ncbidiag.cpp:6065
static void SetLogTruncate(bool value)
Set log file truncation flag.
Definition: ncbidiag.cpp:3475
string GetLogFile(EDiagFileType file_type)
Get log file name for the given log type.
Definition: ncbidiag.cpp:7612
@ eDPF_DateTime
Include date and time.
Definition: ncbidiag.hpp:700
@ eDPF_Log
Print the posted message only; without severity, location, prefix, etc.
Definition: ncbidiag.hpp:747
@ eDPF_All
All flags (except for the "unusual" ones!)
Definition: ncbidiag.hpp:718
@ eLogRate_Err
Error log.
Definition: ncbidiag.hpp:2278
@ eDiag_Trace
Trace message.
Definition: ncbidiag.hpp:657
@ eDiag_Info
Informational message.
Definition: ncbidiag.hpp:651
@ eDiag_Error
Error message.
Definition: ncbidiag.hpp:653
@ eDiag_Warning
Warning message.
Definition: ncbidiag.hpp:652
@ eDiag_Fatal
Fatal error – guarantees exit(or abort)
Definition: ncbidiag.hpp:655
@ eDiag_Critical
Critical error message.
Definition: ncbidiag.hpp:654
const string & Get(const string &name, bool *found=NULL) const
Get environment value by name.
Definition: ncbienv.cpp:109
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
Definition: ncbiexpt.hpp:704
static string NormalizePath(const string &path, EFollowLinks follow_links=eIgnoreLinks)
Normalize a path.
Definition: ncbifile.cpp:820
string GetDir(EIfEmptyPath mode=eIfEmptyPath_Current) const
Get the directory component for this directory entry.
Definition: ncbifile.cpp:475
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 DeleteTrailingPathSeparator(const string &path)
Delete trailing path separator, if any.
Definition: ncbifile.cpp:465
bool CreatePath(TCreateFlags flags=fCreate_Default) const
Create the directory path recursively possibly more than one at a time.
Definition: ncbifile.cpp:4106
virtual bool Remove(TRemoveFlags flags=eRecursive) const
Remove a directory entry.
Definition: ncbifile.cpp:2595
static string AddTrailingPathSeparator(const string &path)
Add trailing path separator, if needed.
Definition: ncbifile.cpp:455
virtual bool Exists(void) const
Check if directory "dirname" exists.
Definition: ncbifile.hpp:4065
static string CreateRelativePath(const string &path_from, const string &path_to)
Create a relative path between two points in the file system specified by their absolute paths.
Definition: ncbifile.cpp:599
bool IsFile(EFollowLinks follow=eFollowLinks) const
Check whether a directory entry is a file.
Definition: ncbifile.hpp:3940
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
static string GetCwd(void)
Get the current working directory.
Definition: ncbifile.cpp:3708
string GetName(void) const
Get the base entry name with extension (if any).
Definition: ncbifile.hpp:3916
list< TEntry > TEntries
Definition: ncbifile.hpp:1750
const string & GetPath(void) const
Get entry path.
Definition: ncbifile.hpp:3910
string GetExt(void) const
Get extension name.
Definition: ncbifile.hpp:3932
virtual const string & Get(const string &section, const string &name, TFlags flags=0) const
Get the parameter value.
Definition: ncbireg.cpp:262
virtual int GetInt(const string &section, const string &name, int default_value, TFlags flags=0, EErrAction err_action=eThrow) const
Get integer value of specified parameter name.
Definition: ncbireg.cpp:362
virtual string GetString(const string &section, const string &name, const string &default_value, TFlags flags=0) const
Get the parameter string value.
Definition: ncbireg.cpp:321
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
CNcbiIstream & NcbiGetlineEOL(CNcbiIstream &is, string &str, string::size_type *count=NULL)
Read from "is" to "str" the next line (taking into account platform specifics of End-of-Line)
IO_PREFIX::ofstream CNcbiOfstream
Portable alias for ofstream.
Definition: ncbistre.hpp:500
IO_PREFIX::ifstream CNcbiIfstream
Portable alias for ifstream.
Definition: ncbistre.hpp:439
static bool StringToBool(const CTempString str)
Convert string to bool.
Definition: ncbistr.cpp:2821
#define kEmptyStr
Definition: ncbistr.hpp:123
static int CompareNocase(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2)
Case-insensitive compare of a substring with another string.
Definition: ncbistr.cpp:219
static int StringToInt(const CTempString str, TStringToNumFlags flags=0, int base=10)
Convert string to int.
Definition: ncbistr.cpp:630
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
char TXChar
Definition: ncbistr.hpp:172
#define NPOS
Definition: ncbistr.hpp:133
static int strncasecmp(const char *s1, const char *s2, size_t n)
Case-insensitive comparison of two zero-terminated strings, narrowed to the specified number of chara...
Definition: ncbistr.hpp:5247
static string IntToString(int value, TNumToStringFlags flags=0, int base=10)
Convert int to string.
Definition: ncbistr.hpp:5084
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 SIZE_TYPE FindCase(const CTempString str, const CTempString pattern, SIZE_TYPE start, SIZE_TYPE end, EOccurrence which=eFirst)
Find the pattern in the specified range of a string using a case sensitive search.
Definition: ncbistr.hpp:5490
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 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
static string TruncateSpaces(const string &str, ETrunc where=eTrunc_Both)
Truncate spaces in a string.
Definition: ncbistr.cpp:3186
static string & ToLower(string &str)
Convert string to lower case – string& version.
Definition: ncbistr.cpp:405
@ fSplit_Truncate
Definition: ncbistr.hpp:2501
@ fSplit_MergeDelimiters
Merge adjacent delimiters.
Definition: ncbistr.hpp:2498
double Elapsed(void) const
Return time elapsed since first Start() or last Restart() call (in seconds).
Definition: ncbitime.hpp:2776
string AsString(const CTimeFormat &format=kEmptyStr, TSeconds out_tz=eCurrentTimeZone) const
Transform time to string.
Definition: ncbitime.cpp:1511
void Start(void)
Start the timer.
Definition: ncbitime.hpp:2765
@ eCurrent
Use current time. See also CCurrentTime.
Definition: ncbitime.hpp:300
virtual string Print(void) const
Print version information.
Definition: version.cpp:120
const TProjectGUID & GetProjectGUID(void) const
Get the ProjectGUID member data.
const TAttlist & GetAttlist(void) const
Get the Attlist member data.
const TName & GetName(void) const
Get the Name member data.
static CStopWatch sw
FILE * file
int i
yy_size_t n
CBioseq_Base_Info & GetBase(CTSE_Info &tse, const CBioObjectId &id)
void CreateDllBuildTree(const CProjectItemsTree &tree_src, CProjectItemsTree *tree_dst)
string GetDllHost(const CProjectItemsTree &tree, const string &lib)
#define LIST_SEPARATOR_LIBS
#define LIST_SEPARATOR
Separator for list values in registry.
void LoadConfigInfoByNames(const CNcbiRegistry &registry, const list< string > &config_names, list< SConfigInfo > *configs)
CProjKey CreateProjKey(const string &project_name)
string CreateProjectName(const CProjKey &project_id)
Project naming schema.
bool IsSubdir(const string &abs_parent_dir, const string &abs_dir)
Is abs_dir a parent of abs_parent_dir.
void EraseIf(C &cont, const P &pred)
Erase if predicate is true.
const TYPE & Get(const CNamedParameterList *param)
constexpr bool empty(list< Ts... >) noexcept
const struct ncbi::grid::netcache::search::fields::KEY key
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
EIPRangeType t
Definition: ncbi_localip.c:101
ESERV_Site site
Defines: CTimeFormat - storage class for time format.
T max(T x_, T y_)
std::istream & in(std::istream &in_, double &x_)
double r(size_t dimension_, const Int4 *score_, const double *prob_, double theta_)
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
#define fc
CProjBulderApp & GetApp(void)
access to App singleton
int NcbiSys_main(int argc, TXChar *argv[])
const char * s_ptb_skipconfig
USING_NCBI_SCOPE
static void s_ReportDependenciesStatus(const CCyclicDepends::TDependsCycles &cycles, CProjectItemsTree::TProjects &tree)
CProjItem CreateUtilityProjectItem(const string &prj_dir, const string &name)
string ParentDir(const string &dir_abs)
Definition: proj_utils.cpp:36
#define PTB_ERROR_EX(file, err_code, msg)
#define PTB_INFO(msg)
@ ePTB_MacroInvalid
@ ePTB_FileModified
@ ePTB_ProjectExcluded
@ ePTB_ProjectNotFound
@ ePTB_NoError
@ ePTB_ConfigurationError
@ ePTB_PathNotFound
#define PTB_WARNING_EX(file, err_code, msg)
#define PTB_ERROR(file, msg)
CProjectItemsTree::TProjects::value_type TValueType
bool operator()(const TValueType &item) const
CProjectItemsTree::TProjects::value_type TValueType
bool operator()(const TValueType &item) const
bool operator()(const TValueType &item) const
CProjectItemsTree::TProjects::value_type TValueType
bool operator()(const TValueType &item) const
CProjectItemsTree::TProjects::value_type TValueType
bool operator()(const TValueType &item) const
CProjectItemsTree::TProjects::value_type TValueType
SConfigInfo –.
string GetConfigFullName(void) const
SDiagMessage –.
Definition: ncbidiag.hpp:1599
static bool IsConfigurableDefine(const string &define)
Abstraction of project tree general information.
Definition: proj_utils.hpp:56
string m_Compilers
<compilers> branch of tree
Definition: proj_utils.hpp:74
list< string > m_ImplicitExcludedAbsDirs
Branch of tree to be implicit exclude from build.
Definition: proj_utils.hpp:65
done
Definition: token1.c:1
static const char *const features[]
static CS_CONTEXT * context
Definition: will_convert.c:21
Modified on Tue Apr 23 07:38:48 2024 by modify_doxy.py rev. 669887