Changeset 9


Ignore:
Timestamp:
Mar 4, 2005, 6:20:46 PM (19 years ago)
Author:
arnault
Message:

Temporary step for project management

Location:
CMT/v1r19
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • CMT/v1r19/ChangeLog

    r8 r9  
     12005-03-04  Christian Arnault  <arnault@lal.in2p3.fr> 256
     2
     3        * source/cmt_project.cxx: Ongoing work for redefining Project graphs.
     4
    152005-03-03  Christian Arnault  <arnault@lal.in2p3.fr> 255
    26
  • CMT/v1r19/source/cmt.h

    r2 r9  
    6464  bool m_standard_macros_done;
    6565  bool m_all_sets_done;
     66
     67  bool m_autoconfigure_cmtpath;
    6668};
    6769
  • CMT/v1r19/source/cmt_commands.cxx

    r3 r9  
    178178  parsers.add ("--version", i);
    179179  pv.push_back (&ArgParser::do_version); i++;
    180 
    181   parsers.add ("+p", i);
    182   parsers.add ("+pa", i);
    183   parsers.add ("+pat", i);
    184   parsers.add ("+path", i);
    185   pv.push_back (&ArgParser::do_add_path); i++;
    186180
    187181  parsers.add ("-b", i);
     
    15501544{
    15511545  cmt.m_action = action_version;
    1552 }
    1553 
    1554 void ArgParser::do_add_path ()
    1555 {
    1556   cmt_string here = CmtSystem::pwd ();
    1557 
    1558   if (CmtSystem::cd (arg))
    1559     {
    1560       arg = CmtSystem::pwd ();
    1561 
    1562       //cerr << "Adding path " << arg << endl;
    1563 
    1564       IProjectFactory& factory = ProjectFactory::instance ();
    1565       CmtSystem::add_cmt_path (arg, "argument", factory);
    1566       CmtSystem::cd (here);
    1567     }
    15681546}
    15691547
  • CMT/v1r19/source/cmt_commands.h

    r2 r9  
    5757  void do_unlock ();
    5858  void do_version ();
    59   void do_add_path ();
    6059  void option_help ();
    6160  void option_n ();
  • CMT/v1r19/source/cmt_parser.cxx

    r8 r9  
    8989  m_current_structuring_style = with_version_directory;
    9090  m_all_sets_done = false;
     91  m_autoconfigure_cmtpath = false;
    9192  m_debug = false;
    9293  if (getenv ("CMTDEBUG") != 0) m_debug = true;
     
    585586void Cmt::configure_cmt_path (Use* use)
    586587{
     588  if (!Me.m_autoconfigure_cmtpath) return;
     589
    587590  cmt_string s;
    588591
     
    611614  factory.reset ();
    612615
    613   CmtSystem::get_cmt_paths (factory, s);
    614 
    615   if (Me.m_cmt_user_context != "") factory.create_project (Me.m_cmt_user_context, "CMTUSERCONTEXT");
    616   if (Me.m_cmt_home != "") factory.create_project (Me.m_cmt_home, "CMTHOME");
     616  CmtSystem::get_cmt_paths (factory, s, Me.m_cmt_user_context, Me.m_cmt_home);
    617617}
    618618
     
    39093909
    39103910              IProjectFactory& factory = ProjectFactory::instance ();
    3911               factory.create_project (pwd, "CurrentProject");
     3911              factory.create_project (pwd, "CurrentProject", 0);
    39123912
    39133913              /*
     
    39393939
    39403940  cmt_string buffer = "path CMTPATH \n";
    3941   Project::set_cmtpaths (buffer);
     3941  Project::fill_cmtpaths (buffer);
    39423942  //cerr << "buffer = " << buffer << endl;
    39433943  Use& use = Use::current();
     
    39463946  SyntaxParser::parse_requirements_text (buffer, "", &use);
    39473947  Me.m_quiet = save_quiet;
     3948
     3949  Me.m_autoconfigure_cmtpath = true;
    39483950}
    39493951
  • CMT/v1r19/source/cmt_project.cxx

    r8 r9  
    105105     - then it tries to read and parse its project file
    106106 */
    107 void ProjectFactory::create_project (const cmt_string& path,
    108                                      const cmt_string& source)
     107Project* ProjectFactory::create_project (const cmt_string& path,
     108                                         const cmt_string& source,
     109                                         Project* parent)
    109110{
    110111  cmt_string compressed_path = path;
     
    117118      Project& p = Projects[i];
    118119     
    119       if (p.get_cmtpath () == compressed_path) return;
    120       if (p.get_cmtpath_pwd () == compressed_path) return;
     120      if ((p.get_cmtpath () == compressed_path) ||
     121          (p.get_cmtpath_pwd () == compressed_path))
     122        {
     123          if (parent != 0)
     124            {
     125              p.add_parent (parent);
     126              parent->add_child (&p);
     127            }
     128          return (&p);
     129        }
    121130    }
    122131 
     
    127136 
    128137  cmt_string here = CmtSystem::pwd ();
    129   if (!CmtSystem::cd (compressed_path)) return;
     138  if (!CmtSystem::cd (compressed_path)) return (0);
    130139
    131140  cmt_string name;
     
    187196  project = Project::add (name, release);
    188197
     198  if (parent != 0)
     199    {
     200      project->add_parent (parent);
     201      parent->add_child (project);
     202    }
     203
    189204  if (source == "default path")
    190205    {
     
    216231    }
    217232
    218   if (m_previous != 0) m_previous->set_predecessor (project);
    219   m_previous = project;
    220 
    221233  if (text != "")
    222234    {
     
    229241
    230242  CmtSystem::cd (here);
     243
     244  return (project);
    231245}
    232246
     
    374388        Project& p = Projects.add ();
    375389
    376         project->set_reference (&p);
    377390        p.set_name (name);
    378391        p.set_release (release);
     
    417430void Project::show_all ()
    418431{
     432  /*
    419433  static ProjectVector& Projects = projects ();
    420434
     
    424438      project.show ();
    425439    }
    426 }
     440  */
     441
     442  static Project::ProjectVector& Projects = Project::projects ();
     443 
     444  for (int i = 0; i < Projects.size (); i++)
     445    {
     446      Project& p = Projects[i];
     447      p.m_visited = false;
     448    }
     449
     450  Project* current = get_current ();
     451
     452  current->show ();
     453 
     454
     455}
     456
     457class VisitorForShowPaths : public IProjectVisitor
     458{
     459public:
     460  VisitorForShowPaths ()
     461  {
     462  }
     463
     464  void pre (Project* p)
     465  {
     466    const cmt_string& w = p->get_cmtpath_pwd ();
     467    const cmt_string& s = p->get_cmtpath_source ();
     468
     469    if (s == "default path") return;
     470
     471    if (CmtSystem::test_directory (w))
     472      {
     473        cout << "# Add path " << w << " from " << s << endl;
     474      }
     475  }
     476
     477  void in (Project* p)
     478  {
     479    const cmt_string& w = p->get_cmtpath_pwd ();
     480    const cmt_string& s = p->get_cmtpath_source ();
     481
     482    if (s == "default path") return;
     483
     484    if (CmtSystem::test_directory (w))
     485      {
     486        cout << "# Add path " << w << " from " << s << endl;
     487      }
     488  }
     489
     490  void post (Project* p)
     491  {
     492  }
     493};
    427494
    428495/*----------------------------------------------------------*/
    429496void Project::show_paths ()
    430497{
    431   static ProjectVector& Projects = projects ();
    432 
    433   if (!Cmt::get_quiet ())
    434     {
    435       for (int i = 0; i < Projects.size (); i++)
    436         {
    437           const Project& project = Projects[i];
    438 
    439           const cmt_string& path   = project.get_cmtpath ();
    440           const cmt_string& source = project.get_cmtpath_source ();
    441          
    442           cout << "# Add path " << path << " from " << source << endl;
    443         }
    444      
    445       cout << "#" << endl;
    446     }
    447 
    448   for (int i = 0; i < Projects.size (); i++)
    449     {
    450       const Project& project = Projects[i];
    451      
    452       const cmt_string& path   = project.get_cmtpath ();
    453       const cmt_string& source = project.get_cmtpath_source ();
    454 
    455       if (i > 0) cout << CmtSystem::path_separator ();
    456 
    457       cout << path;
    458     }
    459 
    460   cout << endl;
     498  VisitorForShowPaths visitor;
     499
     500  start_visit (visitor);
    461501}
    462502
     
    598638
    599639//----------------------------------------------------------
    600 void Project::set_cmtpaths (cmt_string& buffer)
     640void Project::visit (IProjectVisitor& visitor)
     641{
     642  if (m_visited) return;
     643  m_visited = true;
     644
     645  int i;
     646
     647  for (i = 0; i < get_children_size (); i++)
     648    {
     649      Project* child = get_child (i);
     650
     651      if (child->visited ()) continue;
     652
     653      visitor.in (child);
     654    }
     655
     656  for (i = 0; i < m_children.size (); i++)
     657    {
     658      Project* child = m_children[i];
     659      child->visit (visitor);
     660    }
     661}
     662
     663//----------------------------------------------------------
     664void Project::start_visit (IProjectVisitor& visitor)
     665{
     666  static Project::ProjectVector& Projects = Project::projects ();
     667 
     668  for (int i = 0; i < Projects.size (); i++)
     669    {
     670      Project& p = Projects[i];
     671      p.m_visited = false;
     672    }
     673
     674  Project* p = get_current ();
     675
     676  if (p == 0) return;
     677
     678  visitor.pre (p);
     679  p->visit (visitor);
     680  visitor.post (p);
     681}
     682
     683//----------------------------------------------------------
     684class VisitorForFillCMTPATH : public IProjectVisitor
     685{
     686public:
     687  VisitorForFillCMTPATH (cmt_string& buffer) : m_buffer (buffer)
     688  {
     689  }
     690
     691  void pre (Project* p)
     692  {
     693    const cmt_string& w = p->get_cmtpath_pwd ();
     694    const cmt_string& s = p->get_cmtpath_source ();
     695
     696    if (s == "default path") return;
     697
     698    if (CmtSystem::test_directory (w))
     699      {
     700        m_buffer += "path_append CMTPATH \"";
     701        m_buffer += w;
     702        m_buffer += "\" \n";
     703      }
     704  }
     705
     706  void in (Project* p)
     707  {
     708    const cmt_string& w = p->get_cmtpath_pwd ();
     709    const cmt_string& s = p->get_cmtpath_source ();
     710
     711    if (s == "default path") return;
     712
     713    if (CmtSystem::test_directory (w))
     714      {
     715        m_buffer += "path_append CMTPATH \"";
     716        m_buffer += w;
     717        m_buffer += "\" \n";
     718      }
     719  }
     720
     721  void post (Project* p)
     722  {
     723    //cerr << "Buffer = " << m_buffer << endl;
     724  }
     725
     726private:
     727  cmt_string& m_buffer;
     728
     729};
     730
     731//----------------------------------------------------------
     732void Project::fill_cmtpaths (cmt_string& buffer)
    601733{
    602734  /*
     
    606738   */
    607739
    608   static ProjectVector& Projects = projects ();
    609 
    610   for (int i = 0; i < Projects.size (); i++)
    611     {
    612       const Project& project = Projects[i];
    613 
    614       const cmt_string& p = project.m_cmtpath;
    615       const cmt_string& w = project.m_cmtpath_pwd;
    616       const cmt_string& s = project.m_cmtpath_source;
    617 
    618       if (s == "default path") continue;
    619 
    620       if (CmtSystem::test_directory (w))
    621         {
    622           buffer += "path_append CMTPATH \"";
    623           buffer += w;
    624           buffer += "\" \n";
    625         }
    626     }
    627 }
    628 
    629 //----------------------------------------------------------
    630 Project::Project () : m_name (""), m_reference (0), m_predecessor (0)
     740  VisitorForFillCMTPATH visitor (buffer);
     741
     742  start_visit (visitor);
     743}
     744
     745//----------------------------------------------------------
     746Project::Project () : m_name ("")
    631747{
    632748  clear ();
     
    664780
    665781//----------------------------------------------------------
     782int Project::get_children_size () const
     783{
     784  return (m_children.size ());
     785}
     786
     787//----------------------------------------------------------
     788Project* Project::get_child (int index) const
     789{
     790  if (index < 0) return (0);
     791  if (index >= m_children.size ()) return (0);
     792  return (m_children[index]);
     793}
     794
     795//----------------------------------------------------------
     796bool Project::visited () const
     797{
     798  return (m_visited);
     799}
     800
     801//----------------------------------------------------------
    666802void Project::set_name (const cmt_string& name)
    667803{
    668804  m_name = name;
    669   configure ();
     805  //configure ();
    670806}
    671807
     
    692828{
    693829  m_cmtpath_source = source;
    694 }
    695 
    696 //----------------------------------------------------------
    697 void Project::set_predecessor (Project* predecessor)
    698 {
    699   m_predecessor = predecessor;
    700 }
    701 
    702 //----------------------------------------------------------
    703 void Project::set_reference (Project* reference)
    704 {
    705   m_reference = reference;
    706830}
    707831
     
    714838  m_cmtpath_pwd = "";
    715839  m_cmtpath_source = "";
     840
     841  m_parents.clear ();
     842  m_children.clear ();
    716843
    717844  m_build_strategy_mask = 0;
     
    733860  m_setup_cleanup_tag = 0;
    734861  m_setup_no_cleanup_tag = 0;
     862}
     863
     864//----------------------------------------------------------
     865void Project::add_parent (Project* p)
     866{
     867  if (p == 0) return;
     868
     869  int i;
     870
     871  for (i = 0; i < m_children.size (); i++)
     872    {
     873      Project* child = m_children[i];
     874      if (child == 0) continue;
     875
     876      if (child->get_name () == p->get_name ())
     877        {
     878          // Already registered as a child (no cycle permitted!!)
     879          return;
     880        }
     881    }
     882
     883  for (i = 0; i < m_parents.size (); i++)
     884    {
     885      Project* parent = m_parents[i];
     886      if (parent == 0) continue;
     887
     888      if (parent->get_name () == p->get_name ())
     889        {
     890          // Already registered
     891          return;
     892        }
     893    }
     894
     895  m_parents.push_back (p);
     896}
     897
     898//----------------------------------------------------------
     899void Project::add_child (Project* p)
     900{
     901  if (p == 0) return;
     902
     903  int i;
     904
     905  for (i = 0; i < m_parents.size (); i++)
     906    {
     907      Project* parent = m_parents[i];
     908      if (parent == 0) continue;
     909
     910      if (parent->get_name () == p->get_name ())
     911        {
     912          // Already registered as a parent (no cycle permitted!!)
     913          return;
     914        }
     915    }
     916
     917  for (i = 0; i < m_children.size (); i++)
     918    {
     919      Project* child = m_children[i];
     920      if (child == 0) continue;
     921
     922      if (child->get_name () == p->get_name ())
     923        {
     924          // Already registered
     925          return;
     926        }
     927    }
     928
     929  m_children.push_back (p);
    735930}
    736931
     
    8761071          IProjectFactory& factory = ProjectFactory::instance ();
    8771072
    878           factory.create_project (p, "ProjectPath");
     1073          factory.create_project (p, "ProjectPath", this);
    8791074
    8801075          break;
     
    9081103
    9091104//----------------------------------------------------------
    910 void Project::show () const
    911 {
     1105void Project::show ()
     1106{
     1107  static int level = 0;
     1108
    9121109  bool is_current = false;
    9131110
     
    9221119    }
    9231120
     1121  for (int tab = 0; tab < level; tab++) cout << "  ";
    9241122  cout << m_name << " " << m_release << " (in " << m_cmtpath << ")";
    9251123
    9261124  if (is_current) cout << " (current)";
    9271125
     1126  int i;
     1127
     1128  for (i = 0; i < m_parents.size (); i++)
     1129    {
     1130      Project* p = m_parents[i];
     1131      if (p == 0) continue;
     1132      cout << " P=" << p->get_name ();
     1133    }
     1134
     1135  for (i = 0; i < m_children.size (); i++)
     1136    {
     1137      Project* p = m_children[i];
     1138      if (p == 0) continue;
     1139      cout << " C=" << p->get_name ();
     1140    }
     1141
    9281142  cout << endl;
     1143
     1144  if (m_visited) return;
     1145
     1146  m_visited = true;
     1147
     1148  for (i = 0; i < m_children.size (); i++)
     1149    {
     1150      Project* p = m_children[i];
     1151      if (p == 0) continue;
     1152      level++;
     1153      p->show ();
     1154      level--;
     1155    }
    9291156}
    9301157
     
    9401167  int result = 0;
    9411168
     1169  /*
    9421170  if (m_reference != 0) result = m_reference->get_build_strategy ();
    9431171  else if (m_predecessor != 0) result = m_predecessor->get_build_strategy ();
    9441172  else result = Cmt::get_current_build_strategy ();
     1173  */
     1174
     1175  result = Cmt::get_current_build_strategy ();
    9451176
    9461177  if (m_build_strategy_mask != 0)
     
    9581189  int result = 0;
    9591190
     1191  /*
    9601192  if (m_reference != 0) result = m_reference->get_setup_strategy ();
    9611193  else if (m_predecessor != 0) result = m_predecessor->get_setup_strategy ();
    9621194  else result = Cmt::get_current_setup_strategy ();
     1195  */
     1196
     1197  result = Cmt::get_current_setup_strategy ();
    9631198
    9641199  if (m_setup_strategy_mask != 0)
     
    10171252    }
    10181253
     1254 
     1255  /*
    10191256  static ProjectVector& Projects = projects ();
    10201257
     
    10321269        }
    10331270    }
     1271      */
    10341272
    10351273}
     
    10891327    }
    10901328
     1329  /*
    10911330  static ProjectVector& Projects = projects ();
    10921331
     
    11041343        }
    11051344    }
    1106 }
    1107 
     1345  */
     1346}
     1347
  • CMT/v1r19/source/cmt_project.h

    r8 r9  
    2121public:
    2222  void reset ();
    23   void create_project (const cmt_string& path,
    24                        const cmt_string& path_source);
     23  Project* create_project (const cmt_string& path,
     24                           const cmt_string& path_source,
     25                           Project* parent);
    2526
    2627private:
     
    3637};
    3738
     39class IProjectVisitor
     40{
     41public:
     42  virtual void pre (Project* p) = 0;
     43  virtual void in (Project* p) = 0;
     44  virtual void post (Project* p) = 0;
     45};
     46
    3847class Project
    3948{
     
    4150
    4251  typedef cmt_vector<Project> ProjectVector;
     52  typedef cmt_vector<Project*> ProjectPtrVector;
    4353
    4454  static void create (const cmt_string& name);
     
    6575  static cmt_string find_in_cmt_paths (const cmt_string& path);
    6676
    67   static void set_cmtpaths (cmt_string& buffer);
     77  static void fill_cmtpaths (cmt_string& buffer);
     78
     79  static void start_visit (IProjectVisitor& visitor);
    6880
    6981public:
     
    7688  const cmt_string& get_cmtpath_pwd () const;
    7789  const cmt_string& get_cmtpath_source () const;
     90  int get_children_size () const;
     91  Project* get_child (int index) const;
     92  bool visited () const;
     93
    7894  void set_name (const cmt_string& name);
    7995  void set_release (const cmt_string& release);
     
    8197  void set_cmtpath_pwd (const cmt_string& path);
    8298  void set_cmtpath_source (const cmt_string& source);
    83   void set_predecessor (Project* predecessor);
    84   void set_reference (Project* reference);
    8599  void clear ();
    86100  void configure ();
     101  void add_parent (Project* p);
     102  void add_child (Project* p);
    87103
    88104  void use_action (const cmt_string& name, const cmt_string& release);
     
    92108  bool operator != (const cmt_string& name) const;
    93109
    94   void show () const;
     110  void show ();
    95111  void show_strategies () const;
    96112  int get_build_strategy () const;
     
    99115  void set_setup_strategy (int mask, int strategy);
    100116
     117  void visit (IProjectVisitor& visitor);
     118
    101119private:
     120
     121  void fill_cmtpath (cmt_string& buffer);
     122
    102123  cmt_string m_name;
    103124  cmt_string m_release;
    104125
    105   Project* m_reference;
    106   Project* m_predecessor;
     126  ProjectPtrVector m_parents;
     127  ProjectPtrVector m_children;
     128
     129  bool m_visited;
    107130
    108131  cmt_string m_cmtpath;
  • CMT/v1r19/source/cmt_system.cxx

    r2 r9  
    12291229
    12301230//----------------------------------------------------------
    1231 void CmtSystem::add_cmt_path (const cmt_string& path,
    1232                               const cmt_string& path_source,
    1233                               IProjectFactory& factory)
    1234 {
    1235   cmt_string npath = path;
    1236 
    1237   if (npath == "") return;
     1231//
     1232// This singleton interacts with the ProjectFactory to consistently create
     1233// the project graph.
     1234//
     1235// In particular a single-depth stack of the top project is maintained.
     1236//
     1237//----------------------------------------------------------
     1238class CMTPathManager
     1239{
     1240public:
     1241  static CMTPathManager& instance ();
     1242  static void reset ();
     1243  static void add_cmt_path (const cmt_string& path,
     1244                            const cmt_string& path_source,
     1245                            IProjectFactory& factory);
     1246
     1247private:
     1248  CMTPathManager () : m_project (0)
     1249  {
     1250  }
     1251
     1252  void do_reset ()
     1253  {
     1254    m_project = 0;
     1255  }
     1256
     1257  void do_add_cmt_path (const cmt_string& path,
     1258                        const cmt_string& path_source,
     1259                        IProjectFactory& factory)
     1260  {
     1261    cmt_string npath = path;
     1262
     1263    if (npath == "") return;
    12381264
    12391265#ifdef WIN32
    1240   if (npath.size () == 2)
    1241     {
    1242       if (npath[1] == ':')
    1243         {
    1244           npath += file_separator ();
    1245         }
    1246     }
    1247 #endif
    1248 
    1249   npath.replace_all ("\\", file_separator ());
    1250   npath.replace_all ("/", file_separator ());
    1251 
    1252   if (!absolute_path (npath))
    1253     {
    1254       cmt_string h = pwd ();
    1255       h += file_separator ();
    1256       h += npath;
    1257       npath = h;
    1258     }
    1259 
    1260   compress_path (npath);
    1261 
    1262   //cerr << "adding npath=" << npath << endl;
    1263 
    1264   while (npath[npath.size ()-1] == file_separator ())
    1265     {
    1266       npath.erase (npath.size ()-1);
    1267     }
    1268 
    1269   //cerr << "adding npath=[" << npath << "]" << endl;
    1270 
    1271   if (npath != "")
    1272     {
    1273       if (!test_directory (npath))
    1274         {
    1275           CmtError::set (CmtError::path_not_found, npath);
    1276           return;
    1277         }
    1278 
    1279       factory.create_project (npath, path_source);
    1280     }
    1281 }
     1266    if (npath.size () == 2)
     1267      {
     1268        if (npath[1] == ':')
     1269          {
     1270            npath += CmtSystem::file_separator ();
     1271          }
     1272      }
     1273#endif
     1274
     1275    npath.replace_all ("\\", CmtSystem::file_separator ());
     1276    npath.replace_all ("/", CmtSystem::file_separator ());
     1277
     1278    if (!CmtSystem::absolute_path (npath))
     1279      {
     1280        cmt_string h = CmtSystem::pwd ();
     1281        h += CmtSystem::file_separator ();
     1282        h += npath;
     1283        npath = h;
     1284      }
     1285   
     1286    CmtSystem::compress_path (npath);
     1287
     1288    //cerr << "adding npath=" << npath << endl;
     1289
     1290    while (npath[npath.size ()-1] == CmtSystem::file_separator ())
     1291      {
     1292        npath.erase (npath.size ()-1);
     1293      }
     1294   
     1295    //cerr << "adding npath=[" << npath << "]" << endl;
     1296   
     1297    if (npath != "")
     1298      {
     1299        if (!CmtSystem::test_directory (npath))
     1300          {
     1301            CmtError::set (CmtError::path_not_found, npath);
     1302            return;
     1303          }
     1304       
     1305        m_project = factory.create_project (npath, path_source, m_project);
     1306      }
     1307  }
     1308
     1309  Project* m_project;
     1310};
     1311
     1312CMTPathManager& CMTPathManager::instance ()
     1313{
     1314  static CMTPathManager me;
     1315 
     1316  return (me);
     1317}
     1318
     1319void CMTPathManager::reset ()
     1320{
     1321  static CMTPathManager& me = instance ();
     1322  me.do_reset ();
     1323}
     1324
     1325void CMTPathManager::add_cmt_path (const cmt_string& path,
     1326                                   const cmt_string& path_source,
     1327                                   IProjectFactory& factory)
     1328{
     1329  static CMTPathManager& me = instance ();
     1330  me.do_add_cmt_path (path, path_source, factory);
     1331}
     1332
     1333
    12821334
    12831335//----------------------------------------------------------
     
    12951347      const cmt_string& path = path_vector[i];
    12961348
    1297       CmtSystem::add_cmt_path (path, context, factory);
    1298     }
    1299 }
    1300 
    1301 //----------------------------------------------------------
    1302 static void add_cmt_paths (const cmt_string& file_name, IProjectFactory& factory)
     1349      CMTPathManager::add_cmt_path (path, context, factory);
     1350    }
     1351}
     1352
     1353//----------------------------------------------------------
     1354static void add_cmt_paths_from_file (const cmt_string& file_name, IProjectFactory& factory)
    13031355{
    13041356  if (!CmtSystem::test_file (file_name)) return;
     
    13241376
    13251377//----------------------------------------------------------
    1326 void CmtSystem::get_cmt_paths (IProjectFactory& factory, const cmt_string& init_text)
    1327 {
     1378//
     1379// With this function we analyse all possible ways of
     1380// externally entering CMTPATH items
     1381//  + from the environment variable
     1382//  + from .cmtrc files
     1383//  + from registry on Windows
     1384//  + from EV settings for CMTUSERCONTEXT and CMTHOME
     1385//
     1386// Then projects are created from these settings.
     1387//
     1388// (The other way to enter project graph is through project files)
     1389//----------------------------------------------------------
     1390void CmtSystem::get_cmt_paths (IProjectFactory& factory,
     1391                               const cmt_string& init_text,
     1392                               const cmt_string& cmt_user_context,
     1393                               const cmt_string& cmt_home)
     1394{
     1395  CMTPathManager::reset ();
     1396
    13281397  if (init_text != "")
    13291398    {
     
    13551424            {
    13561425              const cmt_string path = temp;
    1357               add_cmt_path (path, "HKEY_CURRENT_USER", factory);
     1426              CMTPathManager::add_cmt_path (path, "HKEY_CURRENT_USER", factory);
    13581427            }
    13591428
     
    13881457            {
    13891458              const cmt_string path = temp;
    1390               add_cmt_path (path, "HKEY_LOCAL_MACHINE", factory);
     1459              CMTPathManager::add_cmt_path (path, "HKEY_LOCAL_MACHINE", factory);
    13911460            }
    13921461          else
     
    14211490          const cmt_string& path = path_vector[i];
    14221491
    1423           add_cmt_path (path, "${CMTPATH}", factory);
    1424         }
    1425     }
    1426 
    1427   add_cmt_paths (".cmtrc", factory);
     1492          CMTPathManager::add_cmt_path (path, "${CMTPATH}", factory);
     1493        }
     1494    }
     1495
     1496  add_cmt_paths_from_file (".cmtrc", factory);
    14281497
    14291498  if (get_home_directory (rc_name))
     
    14311500      rc_name += file_separator ();
    14321501      rc_name += ".cmtrc";
    1433       add_cmt_paths (rc_name, factory);
     1502      add_cmt_paths_from_file (rc_name, factory);
    14341503    }
    14351504
     
    14461515  rc_name += ".cmtrc";
    14471516
    1448   add_cmt_paths (rc_name, factory);
    1449 
    1450   //add_cmt_path (get_cmt_root (), "default path", factory);
     1517  add_cmt_paths_from_file (rc_name, factory);
     1518
     1519  // Suppress the definition of a CMTPATH entry for CMT itself
     1520  //CMTPathManager::add_cmt_path (get_cmt_root (), "default path", factory);
     1521
     1522  CMTPathManager::add_cmt_path (cmt_user_context, "CMTUSERCONTEXT", factory);
     1523  CMTPathManager::add_cmt_path (cmt_home, "CMTHOME", factory);
    14511524}
    14521525
  • CMT/v1r19/source/cmt_system.h

    r2 r9  
    1313#include "cmt_regexp.h"
    1414
     15class Project;
     16
    1517class IProjectFactory
    1618{
    1719public:
    1820  virtual void reset () = 0;
    19   virtual void create_project (const cmt_string& path,
    20                                const cmt_string& path_source) = 0;
     21  virtual Project* create_project (const cmt_string& path,
     22                                   const cmt_string& path_source,
     23                                   Project* parent) = 0;
    2124};
    2225
     
    107110  static cmt_string getenv (const cmt_string& name);
    108111  static bool putenv (const cmt_string& name_value);
    109   static void add_cmt_path (const cmt_string& path,
    110                             const cmt_string& path_source,
    111                             IProjectFactory& factory);
    112112  static void get_cmt_paths (IProjectFactory& factory,
    113                              const cmt_string& init_text = "");
     113                             const cmt_string& init_text,
     114                             const cmt_string& cmt_user_context,
     115                             const cmt_string& cmt_home);
    114116  static int execute (const cmt_string& command);
    115117  static int execute (const cmt_string& command, cmt_string& output);
Note: See TracChangeset for help on using the changeset viewer.