Changeset 16


Ignore:
Timestamp:
Mar 15, 2005, 5:20:10 PM (19 years ago)
Author:
arnault
Message:

Finalizing R&D on project and strategy management - see CL258

Location:
CMT/v1r19
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • CMT/v1r19/ChangeLog

    r15 r16  
     12005-03-15  Christian Arnault  <arnault@lal.in2p3.fr> 258
     2
     3        * source/cmt_parser.cxx (clear): Add m_autoconfigure_cmtpath
     4        variable to discard autoconfiguration of CMTPATH during initial
     5        phases of the configuration.
     6       
     7        (guess_current_project): Once the current project is known, the
     8        CMTPATH is re-generated from the effective knowledge of the
     9        project graph.
     10
     11        (do_setup): Add a check of the configuration when doing cmt setup
     12
     13        (do_check_configuration): analyze the tags coming from arguments
     14        or from CMTSITE to detect mistypings. This is done by checking the
     15        effective usage of those tags.
     16
     17        (configure_cmt_path): Analyze CMTPATH from either the symbol value
     18        or from the EV, before asking the project factory to create the
     19        projects from it.
     20
     21        (get_strategy): Add a generic local function to query the strategy elements.
     22
     23        * source/cmt_project.cxx (add): Manage conflicts between project
     24        release requests on a strict basis (no wild card - exact match
     25        only)
     26
     27        * source/cmt_project.h (class ProjectFactory): No longer need m_first and m_previous
     28
     29        * source/cmt_project.cxx (create_project): Implement a graph of projects.
     30        (create_project): Interpret the first top level directory as the project release
     31       
     32        (create_project): Interpret the second top level directory as the
     33        project name when it's not defined in the project file. So we
     34        don't create a dummy project name anymore Project<n>.
     35
     36        * source/cmt_commands.cxx (ArgParser): Suppress obsolete +path option
     37        (parse): Initialize the m_action value to none to fix a bad management of unknown commands
     38        (do_filter): Implement the cmt filter command
     39
     40        * source/cmt_error.cxx (class Error): Add unknown_command and project_release_conflict errors
     41
     42        * source/cmt_syntax.cxx (class KwdBuildStrategy): Apply the restructuration of strategy management to strategy decoding
     43        (class KwdSetupStrategy): idem
     44        (class KwdUse): Support the use statement for project files
     45        (SyntaxParser): Support the use statement for project files
     46
     47        * source/cmt_project.h (class StrategyDef): Create a class to hold the definition of all strategy elements
     48        (class Strategy): Create a class to hold the application of a strategy into a project
     49        (class StrategyMgr): Create a singleton to manage the strategy definitions
     50        (class ProjectFactory): Add parent argument to create_project to handle the project graph
     51        (class IProjectVisitor): Create a class to visit the project graph
     52        (class Project): Transport all definitions releated with strategies into Strategy objects
     53
     54        * source/cmt_system.cxx (class CMTPathManager): Add a class to
     55        interact with the ProjectFactory to convert CMTPATH specifications
     56        into projects
     57
     58        (get_cmt_paths): Suppress the setting from $CMTPATH. This is
     59        replaced by a selective understanding of the source of CMTPATH
     60        either from the symbol (when defined in a requirements file) or
     61        from the EV. This selection is performed in
     62        Cmt::configure_cmt_path.
     63
     64        (get_cmt_paths): Suppress the definition of a CMTPATH entry for CMT itself
     65
    1662005-03-10    <arnault@lal.in2p3.fr> 257
    267
     
    38103        * source/cmt_tag.cxx (use_operand): Add way of checking internal structure of a tag
    39104        * source/cmt_tag.cxx (use_ref): Add way of checking internal structure of a tag
    40 
    41105        * source/cmt_tag.h (class Tag): Add way of checking internal structure of a tag
    42 
    43106        * source/cmt_symbol.h (class Symbol): Add way of checking if a tag is used by symbols.
    44 
    45107        * source/cmt_symbol.cxx (print): Suppress the "export" action after defining an alias in Sh mode
    46 
    47108        * source/cmt_project.cxx: Introduce use_action
    48 
    49109        * source/cmt_syntax.cxx (SyntaxParser): Add support to use statements in project files
    50 
    51110        * source/cmt_project.cxx (create_project): Add comments
    52111
     
    831422004-12-01    <arnault@lal.in2p3.fr> 247
    84143
    85         * source/cmt_version.h (CMTVERSION): Prepare for tagging 20041201
     144        * source/cmt_version.h (CMTVERSION): Prepare for tagging v1r18p20041201
    86145
    87146        * source/cmt.h (class Cmt): Fix typo
  • CMT/v1r19/mgr/cmt

    • Property svn:executable set to *
  • CMT/v1r19/source/cmt_parser.cxx

    r15 r16  
    536536  configure_home (0);
    537537  log << "configure_current_dir" << log_endl;
     538
     539
     540  Me.m_autoconfigure_cmtpath = true;
     541  configure_cmt_path (0);
     542  Me.m_autoconfigure_cmtpath = false;
     543
     544
    538545  configure_current_dir ();
    539546
     
    589596          Me.m_action = action_show_set;
    590597        }
     598    }
     599  else
     600    {
     601      s = CmtSystem::getenv ("CMTPATH");
    591602    }
    592603
     
    35593570void Cmt::do_show_strategies (const ArgParser& /*ap*/)
    35603571{
     3572  Project::show_specified_strategies_for_all ();
     3573
    35613574  Project* p = Project::get_current ();
    35623575
     
    38323845}
    38333846
    3834 /**
    3835     if current directory is in one of the CMTPATHs, do nothing.
    3836 
    3837   Otherwise, we want to guess the current project => perhaps prepend an item to the CMTPATH??
     3847/**---------------------------------------------------------
     3848  guess_current_project
     3849
     3850   if current directory is in one of the CMTPATHs, do nothing.
     3851
     3852  Otherwise, we want to guess the current project
    38383853
    38393854  move up in directories until cmt/project.cmt is found
     
    38503865    move up
    38513866  }
    3852 
    38533867  */
    38543868void Cmt::guess_current_project ()
     
    39033917    }
    39043918
    3905   cmt_string buffer = "path CMTPATH \n";
     3919  //cmt_string buffer = "path CMTPATH \n";
     3920  cmt_string buffer;
    39063921  Project::fill_cmtpaths (buffer);
    39073922  //cerr << "buffer = " << buffer << endl;
  • CMT/v1r19/source/cmt_project.cxx

    r15 r16  
    9393{
    9494  Project::clear_all ();
    95   m_first = 0;
    96   m_previous = 0;
    97   m_id = 0;
    9895}
    9996
     
    112109  CmtSystem::compress_path (compressed_path);
    113110
     111  //cerr << "Creating project " << path << " with parent " << ((parent==0)? "0" : parent->get_name ()) << endl;
     112
    114113  static Project::ProjectVector& Projects = Project::projects ();
    115114 
     
    125124              p.add_parent (parent);
    126125              parent->add_child (&p);
     126
     127              // Since p is a new parent, we should propagate the settings UP.
     128
     129              parent->update_strategies_from_children ();
    127130            }
     131
    128132          return (&p);
    129133        }
     
    168172          CmtSystem::dirname (compressed_path, name);
    169173          CmtSystem::basename (name, name);
    170 
    171           /*
    172           char buffer[20];
    173           m_id++;
    174           sprintf (buffer, "Project%d", m_id);
    175           name = buffer;
    176           */
    177174        }
    178175    }
     
    189186          CmtSystem::dirname (compressed_path, name);
    190187          CmtSystem::basename (name, name);
    191           //m_id++;
    192           //sprintf (buffer, "Project%d", m_id);
    193188        }
    194189    }
     
    200195      project->add_parent (parent);
    201196      parent->add_child (project);
     197
     198      // Since p is a new parent, we should propagate the settings UP.
     199
     200      parent->update_strategies_from_children ();
    202201    }
    203202
     
    206205      cmt = project;
    207206      is_current = false;
    208     }
    209   else
    210     {
    211       if (m_first == 0)
    212         {
    213           m_first = project;
    214         }
    215207    }
    216208
     
    399391
    400392  Project& project = Projects.add ();
     393  project.clear ();
    401394  project.set_name (name);
    402395  project.set_release (release);
     
    455448}
    456449
     450/*----------------------------------------------------------*/
     451void Project::show_specified_strategies_for_all ()
     452{
     453  static ProjectVector& Projects = projects ();
     454
     455  for (int i = 0; i < Projects.size (); i++)
     456    {
     457      const Project& project = Projects[i];
     458      project.show_specified_strategies ();
     459    }
     460}
     461
     462/*----------------------------------------------------------*/
    457463class VisitorForShowPaths : public IProjectVisitor
    458464{
     
    850856{
    851857  if (p == 0) return;
     858  if (p == this) return;
     859
     860  //cerr << "Adding parent " << p->get_name () << " to " << m_name << endl;
    852861
    853862  int i;
     
    878887
    879888  m_parents.push_back (p);
    880 
    881   // Since p is a new parent, we should propagate the settings UP.
    882 
    883   p->update_strategies_from_children ();
    884889}
    885890
     
    888893{
    889894  if (p == 0) return;
     895  if (p == this) return;
    890896
    891897  int i;
     
    954960  CmtSystem::cmt_string_vector items;
    955961  CmtSystem::split (cmtprojectpath, sep, items);
     962
     963  bool found = false;
     964
    956965  for (int i = 0; i < items.size (); i++)
    957966    {
     
    967976          //cerr << "Project directory " << p << " exists " << endl;
    968977
     978          found = true;
     979
    969980          IProjectFactory& factory = ProjectFactory::instance ();
    970981
     
    973984          break;
    974985        }
     986    }
     987
     988  if (!found)
     989    {
     990      Project* p = Project::find_by_name (name);
     991
     992      if (p != 0)
     993        {
     994          found = true;
     995
     996          p->add_parent (this);
     997          add_child (p);
     998
     999          update_strategies_from_children ();
     1000        }
     1001    }
     1002
     1003  if (!found && (cmtprojectpath != ""))
     1004    {
     1005      cerr << "#CMT> Project " << name << " " << release << " requested by " << m_name << " not found in CMTPROJECTPATH" << endl;
    9751006    }
    9761007}
     
    10561087
    10571088//----------------------------------------------------------
    1058 void Project::show_strategies () const
    1059 {
     1089void Project::show_specified_strategies () const
     1090{
     1091  int i;
     1092
     1093  for (i = 0; i < m_strategies.size (); i++)
     1094    {
     1095      const Strategy& s = m_strategies[i];
     1096      if (s.m_specified)
     1097        {
     1098          const StrategyDef* def = s.m_definition;
     1099 
     1100          cout << "# Project " << m_name
     1101               << " sets " << def->m_keyword
     1102               << " strategy to " << ((s.m_value) ? def->m_on_value : def->m_off_value);
     1103
     1104          if (s.m_context != "")
     1105            {
     1106              cout << " (from package " << s.m_context << ")";
     1107            }
     1108
     1109          cout << endl;
     1110        }
     1111    }
    10601112}
    10611113
     
    11511203
    11521204//----------------------------------------------------------
    1153 void Project::set_strategy (const cmt_string& name, const cmt_string& value)
     1205void Project::set_strategy (const cmt_string& name, const cmt_string& value, const cmt_string& context)
    11541206{
    11551207  static StrategyMgr& mgr = StrategyMgr::instance ();
     
    11781230    }
    11791231
    1180   set_strategy (def, b_value);
    1181 }
    1182 
    1183 //----------------------------------------------------------
    1184 void Project::set_strategy (StrategyDef* definition, bool b_value)
     1232  set_strategy (def, b_value, context);
     1233}
     1234
     1235//----------------------------------------------------------
     1236void Project::set_strategy (StrategyDef* definition, bool b_value, const cmt_string& context)
    11851237{
    11861238  bool need_strategy = true;
     
    11951247          // This strategy is already applied in this project. Let's change it's value
    11961248          s.set (definition, b_value, get_name ());
     1249          if (context != "")
     1250            {
     1251              if (s.m_context != "") s.m_context += " ";
     1252              s.m_context += context;
     1253            }
    11971254          need_strategy = false;
    11981255          break;
     
    12051262
    12061263      Strategy& s = m_strategies.add ();
     1264      s.clear ();
    12071265      s.set (definition, b_value, get_name ());
     1266      s.m_context = context;
    12081267    }
    12091268 
     
    12271286{
    12281287  bool need_strategy = true;
     1288  bool specified = false;
    12291289
    12301290  int i;
     
    12351295      if (s.m_definition == definition)
    12361296        {
    1237           // This strategy is already applied in this project. Let's change it's value
    1238           s.update (definition, b_value, get_name ());
    12391297          need_strategy = false;
     1298
     1299          if (!s.m_specified)
     1300            {
     1301              // This strategy is already applied in this project. Let's change it's value
     1302              s.update (definition, b_value, get_name ());
     1303            }
     1304          else
     1305            {
     1306              specified = true;
     1307            }
    12401308          break;
    12411309        }
     
    12471315
    12481316      Strategy& s = m_strategies.add ();
     1317      s.clear ();
    12491318      s.update (definition, b_value, get_name ());
    12501319    }
    1251  
    1252   for (i = 0; i < m_parents.size (); i++)
    1253     {
    1254       Project* project = m_parents[i];
    1255 
    1256       if (project->has_strategy (definition))
    1257         {
     1320
     1321  if (!specified)
     1322    {
     1323      for (i = 0; i < m_parents.size (); i++)
     1324        {
     1325          Project* project = m_parents[i];
     1326
    12581327          project->update_strategy (definition, b_value);
    12591328        }
     
    12711340  // If this strategy is specified we don't care what happens from the children
    12721341
    1273   cerr << "Updating strategy " << definition->m_name << " from children for project " << m_name << endl;
     1342  //cerr << "Updating strategy " << definition->m_name << " from children for project " << m_name << endl;
    12741343
    12751344  int i;
     
    12861355              // There will be no impact since the strategy is specified
    12871356
    1288               cerr << "This strategy is specified in this project" << endl;
     1357              //cerr << "This strategy is specified in this project" << endl;
    12891358              return;
    12901359            }
     
    13051374  Project* selected = 0;
    13061375  bool selected_is_specified = false;
    1307   bool selected_value = false;
     1376  bool selected_value = definition->m_default_value;
    13081377
    13091378  for (i = 0; i < m_children.size (); i++)
     
    13111380      Project* p = m_children[i];
    13121381
    1313       cerr << "Checking strategy for child " << p->get_name () << endl;
     1382      //cerr << "Checking strategy for child " << p->get_name () << endl;
    13141383
    13151384      bool is_specified = p->is_specified (definition);
     
    13621431  StrategyDef::StrategyDefs& defs = StrategyMgr::get_definitions ();
    13631432
    1364   cerr << "Updating strategies from children for project " << m_name << endl;
     1433  //cerr << "Updating strategies from children for project " << m_name << endl;
    13651434
    13661435  int i;
     
    13691438    {
    13701439      StrategyDef* def = defs[i];
    1371 
     1440     
    13721441      update_strategy_from_children (def);
     1442    }
     1443
     1444  for (i = 0; i < m_parents.size (); i++)
     1445    {
     1446      Project* p = m_parents[i];
     1447      p->update_strategies_from_children ();
    13731448    }
    13741449}
     
    13941469
    13951470  s = new StrategyDef;
     1471  s->m_keyword = "build";
    13961472  s->m_name = "BuildPrototypes";
    13971473  s->m_on_value = "prototypes";
     
    14031479
    14041480  s = new StrategyDef;
     1481  s->m_keyword = "build";
    14051482  s->m_name = "InstallArea";
    14061483  s->m_on_value = "with_installarea";
     
    14121489
    14131490  s = new StrategyDef;
     1491  s->m_keyword = "setup";
    14141492  s->m_name = "SetupConfig";
    14151493  s->m_on_value = "config";
     
    14211499
    14221500  s = new StrategyDef;
     1501  s->m_keyword = "setup";
    14231502  s->m_name = "SetupRoot";
    14241503  s->m_on_value = "root";
     
    14301509
    14311510  s = new StrategyDef;
     1511  s->m_keyword = "setup";
    14321512  s->m_name = "SetupCleanup";
    14331513  s->m_on_value = "cleanup";
     
    14911571}
    14921572
     1573//-----------------------------------------------------------
     1574Strategy::Strategy ()
     1575{
     1576  clear ();
     1577}
     1578
     1579//-----------------------------------------------------------
     1580void Strategy::clear ()
     1581{
     1582  m_definition = 0;
     1583  m_specified = false;
     1584  m_specified_value = false;
     1585  m_value = false;
     1586  m_on_tag = 0;
     1587  m_off_tag = 0;
     1588}
     1589
    14931590/**----------------------------------------------------------
    14941591   Specify a new value for this strategy.
     
    14971594void Strategy::set (StrategyDef* definition, bool value, const cmt_string& project_name)
    14981595{
     1596  //cerr << "Setting strategy " << definition->m_name << " for project " << project_name << " to " << value << endl;
     1597
    14991598  m_definition = definition;
    15001599  m_specified = true;
     
    15111610void Strategy::update (StrategyDef* definition, bool value, const cmt_string& project_name)
    15121611{
     1612  //cerr << "Updating strategy " << definition->m_name << " for project " << project_name << " to " << value << endl;
     1613
    15131614  m_value = value;
     1615  m_definition = definition;
    15141616
    15151617  cmt_string to_tag_name = project_name;
  • CMT/v1r19/source/cmt_project.h

    r15 r16  
    1919  typedef cmt_vector <StrategyDef*> StrategyDefs;
    2020
     21  cmt_string m_keyword;
    2122  cmt_string m_name;
    2223  cmt_string m_on_value;
     
    3738  Tag* m_on_tag;
    3839  Tag* m_off_tag;
     40  cmt_string m_context;
    3941
     42  Strategy ();
     43  void clear ();
    4044  void set (StrategyDef* definition, bool value, const cmt_string& project_name);
    4145  void update (StrategyDef* definition, bool value, const cmt_string& project_name);
     
    6771                           Project* parent);
    6872
    69 private:
    70   Project* m_first;
    71   Project* m_previous;
    72   int m_id;
    7373};
    7474
     
    105105  static void clear_all ();
    106106  static void show_all ();
     107  static void show_specified_strategies_for_all ();
    107108  static void show_paths ();
    108109  static const cmt_string& get_project_file_name ();
     
    151152
    152153  void show ();
    153   void show_strategies () const;
     154  void show_specified_strategies () const;
    154155
    155156  bool has_strategy (const StrategyDef* definition) const;
     
    158159  bool get_strategy (const cmt_string& name) const;
    159160  void set_default_strategy (const cmt_string& name);
    160   void set_strategy (const cmt_string& name, const cmt_string& value);
    161   void set_strategy (StrategyDef* definition, bool b_value);
     161  void set_strategy (const cmt_string& name, const cmt_string& value, const cmt_string& context);
     162  void set_strategy (StrategyDef* definition, bool b_value, const cmt_string& context);
    162163  void update_strategy (StrategyDef* definition, bool b_value);
    163164  void update_strategy_from_children (StrategyDef* definition);
  • CMT/v1r19/source/cmt_syntax.cxx

    r15 r16  
    173173        if (decode (w, strategy, value))
    174174          {
    175             if (p != 0) p->set_strategy (strategy, value);
     175            if (p != 0) p->set_strategy (strategy, value, use->get_package_name ());
    176176          }
    177177        else
     
    181181            CmtError::set (CmtError::syntax_error, "ParseRequirements> bad strategy keyword");
    182182          }
    183 
    184         if ((Cmt::get_action () == action_show_strategies) && !Cmt::get_quiet ())
    185           {
    186             if (!in_error)
    187               {
    188                 cerr << "# Package " << use->get_package_name ()
    189                      << " adds " << w << " to build strategy" << endl;
    190               }
    191             else
    192               {
    193                 cerr << "# Error: Package " << use->get_package_name ()
    194                      << " uses unknown " << w << " keyword to build strategy" << endl;
    195               }
    196           }
    197183      }
    198184  }
     
    214200        if (decode (w, strategy, value))
    215201          {
    216             if (project != 0) project->set_strategy (strategy, value);
     202            if (project != 0) project->set_strategy (strategy, value, "");
    217203          }
    218204        else
     
    221207
    222208            CmtError::set (CmtError::syntax_error, "ParseRequirements> bad strategy keyword");
    223           }
    224 
    225         if ((Cmt::get_action () == action_show_strategies) && !Cmt::get_quiet ())
    226           {
    227             if (!in_error)
    228               {
    229                 cerr << "# Project " << project->get_name ()
    230                      << " adds " << w << " to build strategy" << endl;
    231               }
    232             else
    233               {
    234                 cerr << "# Error: Project " << project->get_name ()
    235                      << " uses unknown " << w << " keyword to build strategy" << endl;
    236               }
    237209          }
    238210      }
     
    784756        if (decode (w, strategy, value))
    785757          {
    786             if (p != 0) p->set_strategy (strategy, value);
     758            if (p != 0) p->set_strategy (strategy, value, use->get_package_name ());
    787759          }
    788760        else
     
    792764            CmtError::set (CmtError::syntax_error, "ParseRequirements> bad strategy keyword");
    793765          }
    794 
    795         if ((Cmt::get_action () == action_show_strategies) && !Cmt::get_quiet ())
    796           {
    797             if (!in_error)
    798               {
    799                 cerr << "# Package " << use->get_package_name ()
    800                      << " adds " << w << " to setup strategy" << endl;
    801               }
    802             else
    803               {
    804                 cerr << "# Error: Package " << use->get_package_name ()
    805                      << " uses unknown " << w << " keyword to setup strategy" << endl;
    806               }
    807           }
    808766      }
    809767  }
     
    825783        if (decode (w, strategy, value))
    826784          {
    827             if (project != 0) project->set_strategy (strategy, value);
     785            if (project != 0) project->set_strategy (strategy, value, "");
    828786          }
    829787        else
     
    832790
    833791            CmtError::set (CmtError::syntax_error, "ParseRequirements> bad strategy keyword");
    834           }
    835 
    836         if ((Cmt::get_action () == action_show_strategies) && !Cmt::get_quiet ())
    837           {
    838             if (!in_error)
    839               {
    840                 cerr << "# Project " << project->get_name ()
    841                      << " adds " << w << " to setup strategy" << endl;
    842               }
    843             else
    844               {
    845                 cerr << "# Error: Project " << project->get_name ()
    846                      << " uses unknown " << w << " keyword to setup strategy" << endl;
    847               }
    848792          }
    849793      }
  • CMT/v1r19/source/cmt_system.cxx

    r11 r16  
    14771477  cmt_string rc_name;
    14781478
    1479   const cmt_string env = CmtSystem::getenv ("CMTPATH");
    1480 
    1481   if (env != "")
    1482     {
    1483       static cmt_string_vector path_vector;
    1484       int i;
    1485 
    1486       split (env, path_separator (), path_vector);
    1487 
    1488       for (i = 0; i < path_vector.size (); i++)
    1489         {
    1490           const cmt_string& path = path_vector[i];
    1491 
    1492           CMTPathManager::add_cmt_path (path, "${CMTPATH}", factory);
    1493         }
    1494     }
    1495 
    14961479  add_cmt_paths_from_file (".cmtrc", factory);
    14971480
     
    15161499
    15171500  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);
    15211501
    15221502  CMTPathManager::add_cmt_path (cmt_user_context, "CMTUSERCONTEXT", factory);
Note: See TracChangeset for help on using the changeset viewer.