Changeset 550 for CMT/HEAD


Ignore:
Timestamp:
Aug 23, 2010, 11:31:26 AM (14 years ago)
Author:
rybkin
Message:

See C.L. 435

Location:
CMT/HEAD
Files:
1 added
12 edited

Legend:

Unmodified
Added
Removed
  • CMT/HEAD/ChangeLog

    r549 r550  
     12010-08-23    <rybkin@lal.in2p3.fr> 435
     2
     3        * source/cmt_commands.h: Introduce option -xml to produce output in XML
     4        format, currently for commands "cmt setup", "cmt show projects",
     5        "cmt show uses"
     6        * source/cmt_commands.cxx: Implement function option_xml
     7        * source/cmt.h: In class Cmt, introduce function print_xml_prolog
     8        * source/cmt_parser.h: Introduce PrintMode Xml
     9        * source/cmt_parser.cxx: In class Cmt, in functions do_setup, print,
     10        print_context, implement case for mode Xml, in functions do_show_projects,
     11        do_show_uses, pass mode to Project::show_all, Use::show_all, implement
     12        function print_xml_prolog
     13        * source/cmt_symbol.cxx: In class Symbol, in functions all_print, print,
     14        implement case for mode Xml
     15        * source/cmt_project.h: In class Project, in functions show_all, show, add
     16        optional argument of type PrintMode
     17        * source/cmt_project.cxx: Implement added optional argument for mode Xml,
     18        in particular
     19        * source/cmt_use.h: In class Use, in functions show_all, add optional
     20        argument of type PrintMode
     21        * source/cmt_use.cxx: Implement added optional argument for mode Xml,
     22        in particular, in function get_cmtpath_and_offset, set offset to real_path
     23        for packages not belonging to any project
     24        * mgr/CMT.dtd: Introduce document type definition for XML format output
     25        * src/setup.sh: In PATH, CLASSPATH, only strip entries matching /CMT/,
     26        rather than CMT (similar to src/setup.csh)
     27       
    1282010-08-12    <rybkin@lal.in2p3.fr> 434
    229
  • CMT/HEAD/source/cmt.h

    r547 r550  
    261261  static void print_symbol_names (PrintMode mode, const cmt_string& pattern = "");
    262262  static void print_tabs (int tabs);
     263  static void print_xml_prolog (const cmt_string& root = "cmt", ostream& out = cout);
    263264  static int reach_current_package ();
    264265  static void restore_all_tags (Use* use);
  • CMT/HEAD/source/cmt_commands.cxx

    r549 r550  
    382382  pv.push_back (&ArgParser::option_without_version_directory); i++;
    383383
     384  parsers.add ("-xml", i);
     385  pv.push_back (&ArgParser::option_xml); i++;
    384386}
    385387
     
    17731775{
    17741776  mode = Requirements;
     1777}
     1778
     1779void ArgParser::option_xml ()
     1780{
     1781  mode = Xml;
    17751782}
    17761783
     
    22222229  cerr << "#   -cleanup                : activate install area cleanup" << endl;
    22232230  cerr << "#   -no_cleanup             : inhibit install area cleanup" << endl;
     2231  cerr << "#   -xml                    : output in XML format (cmt setup, cmt show projects, cmt show uses)" << endl;
    22242232}
    22252233
  • CMT/HEAD/source/cmt_commands.h

    r549 r550  
    6969  void option_bat ();
    7070  void option_requirements ();
     71  void option_xml ();
    7172  void option_use ();
    7273  void option_pack ();
  • CMT/HEAD/source/cmt_parser.cxx

    r549 r550  
    40424042  do_check_configuration (ap);
    40434043
     4044  switch (ap.mode)
     4045    {
     4046    case Xml :
     4047      Cmt::print_xml_prolog ("setup");
     4048      cout << "<setup>";
     4049      break;
     4050    }
    40444051  print (ap.mode);
     4052  switch (ap.mode)
     4053    {
     4054    case Xml :
     4055      cout << "</setup>" << endl;
     4056      break;
     4057    }
    40454058
    40464059  //
     
    45684581
    45694582//----------------------------------------------------------
    4570 void Cmt::do_show_projects (const ArgParser& /*ap*/)
    4571 {
    4572   Project::show_all ();
     4583void Cmt::do_show_projects (const ArgParser& ap)
     4584//void Cmt::do_show_projects (const ArgParser& /*ap*/)
     4585{
     4586  Project::show_all (ap.mode);
    45734587}
    45744588
     
    47744788
    47754789//----------------------------------------------------------
    4776 void Cmt::do_show_uses (const ArgParser& /*ap*/, ostream& out)
    4777 {
    4778   Use::show_all (false, out);
     4790void Cmt::do_show_uses (const ArgParser& ap, ostream& out)
     4791//void Cmt::do_show_uses (const ArgParser& /*ap*/, ostream& out)
     4792{
     4793  Use::show_all (false, out, ap.mode);
     4794  //  Use::show_all (false, out);
    47794795}
    47804796
     
    71237139    }
    71247140
     7141  switch (mode)
     7142    {
     7143    case Xml :
     7144      break;
     7145    default :
    71257146  cout << endl;
     7147      break;
     7148    }
    71267149}
    71277150
     
    72947317       
    72957318      break;
     7319    case Xml :
     7320      if (do_root)
     7321        {
     7322          cout << "<variable><name>" << use.prefix << "ROOT</name>"
     7323               << "<value>" << use.get_full_path () << "</value></variable>";
     7324        }
     7325
     7326      if (use.get_package_name () == "CMT")
     7327        {
     7328          cout << "<variable><name>CMTCONFIG</name>"
     7329               << "<value>" << system << "</value></variable>";
     7330        }
     7331      else
     7332        {
     7333          if (do_config)
     7334            {
     7335              cout << "<variable><name>" << use.prefix << "CONFIG</name>"
     7336                   << "<value>" << tag << "</value></variable>";
     7337            }
     7338        }
     7339       
     7340      break;
    72967341    case Requirements :
    72977342      if (do_root &&
     
    74517496      tabs--;
    74527497    }
     7498}
     7499
     7500//----------------------------------------------------------
     7501void Cmt::print_xml_prolog (const cmt_string& root, ostream& out)
     7502{
     7503  out << "<?xml version=\"1.0\" standalone=\"no\"?>" << endl;
     7504  cmt_string dtd_file (Me.m_cmt_root);
     7505  dtd_file += CmtSystem::file_separator ();
     7506  dtd_file += "mgr";
     7507  dtd_file += CmtSystem::file_separator ();
     7508  dtd_file += "CMT.dtd";
     7509  out << "<!DOCTYPE " + root + " SYSTEM \"" + dtd_file + "\">" << endl;
    74537510}
    74547511
  • CMT/HEAD/source/cmt_parser.h

    r549 r550  
    1919  Bat,
    2020  Make,
    21   Requirements
     21  Requirements,
     22  Xml
    2223} PrintMode;
    2324
  • CMT/HEAD/source/cmt_project.cxx

    r547 r550  
    12501250
    12511251/*----------------------------------------------------------*/
    1252 void Project::show_all ()
     1252void Project::show_all (PrintMode mode)
     1253//void Project::show_all ()
    12531254{
    12541255  static const Project::ProjectPtrVector& Ordered = Project::ordered_projects ();
     
    12611262    }
    12621263
     1264  switch (mode)
     1265    {
     1266    case Xml :
     1267      Cmt::print_xml_prolog ("projects");
     1268      cout << "<projects>";
     1269      break;
     1270    }
     1271
    12631272  for (int i = 0; i < Ordered.size (); i++)
    1264     Ordered[i]->show ();
     1273    Ordered[i]->show (mode);
     1274  //    Ordered[i]->show ();
    12651275
    12661276  for (int i = 0; i < Projects.size (); i++)
    1267     Projects[i].show ();
    1268 
     1277    Projects[i].show (mode);
     1278  //    Projects[i].show ();
     1279
     1280  switch (mode)
     1281    {
     1282    case Xml :
     1283      cout << "</projects>" << endl;
     1284      break;
     1285    }
    12691286  /*
    12701287  Project* p = get_current ();
     
    25832600
    25842601//----------------------------------------------------------
    2585 void Project::show ()
     2602void Project::show (PrintMode mode)
     2603//void Project::show ()
    25862604{
    25872605  if (m_visited) return;
     
    26072625    }
    26082626  */
     2627  switch (mode)
     2628    {
     2629    case Xml :
     2630      cout << "<project" << (m_is_current ? " current=\"yes\"" : "") << ">";
     2631      //      if (m_order >= 0)
     2632      cout << "<order>" << m_order << "</order>";
     2633      cout << "<name>" << m_name << "</name><version>" << (m_name != "CMTUSERCONTEXT" && m_name != "CMTHOME" ? m_release : "v0") << "</version><cmtpath>" << m_cmtpath << "</cmtpath>";
     2634      break;
     2635    default :
    26092636  for (int tab = 0; tab < level; tab++) cout << "  ";
    26102637  cout << m_name << " " << (m_name != "CMTUSERCONTEXT" && m_name != "CMTHOME" ? m_release : "v0") << " (in " << m_cmtpath << ")";
     
    26132640  if (m_is_current) cout << " (current)";
    26142641  //  if (is_current) cout << " (current)";
     2642      break;
     2643    }
    26152644
    26162645  int i;
    26172646
     2647  switch (mode)
     2648    {
     2649    case Xml :
     2650      cout << "<clients>";
     2651      break;
     2652    }
    26182653  for (i = 0; i < m_parents.size (); i++)
    26192654    {
    26202655      Project* p = m_parents[i];
    26212656      if (p == 0) continue;
     2657      switch (mode)
     2658        {
     2659        case Xml :
     2660          //      cout << "<name>" << p->get_name () << "</name>";
     2661          cout << "<project" << (p->is_current () ? " current=\"yes\"" : "") << ">";
     2662          //  if (p->m_order >= 0)
     2663          cout << "<order>" << p->m_order << "</order>";
     2664          cout << "<name>" << p->get_name () << "</name><version>" << (p->get_name () != "CMTUSERCONTEXT" && p->get_name () != "CMTHOME" ? p->get_release () : "v0") << "</version><cmtpath>" << p->get_cmtpath () << "</cmtpath>";
     2665          cout << "</project>";
     2666          break;
     2667        default :
    26222668      cout << " P=" << p->get_name ();
    2623     }
    2624 
     2669          break;
     2670        }
     2671    }
     2672  switch (mode)
     2673    {
     2674    case Xml :
     2675      cout << "</clients>";
     2676      break;
     2677    }
     2678
     2679  switch (mode)
     2680    {
     2681    case Xml :
     2682      cout << "<uses>";
     2683      break;
     2684    }
    26252685  for (i = 0; i < m_children.size (); i++)
    26262686    {
    26272687      Project* p = m_children[i];
    26282688      if (p == 0) continue;
     2689      switch (mode)
     2690        {
     2691        case Xml :
     2692          //      cout << "<name>" << p->get_name () << "</name>";
     2693          cout << "<project" << (p->is_current () ? " current=\"yes\"" : "") << ">";
     2694          //      if (p->m_order >= 0)
     2695          cout << "<order>" << p->m_order << "</order>";
     2696          cout << "<name>" << p->get_name () << "</name><version>" << (p->get_name () != "CMTUSERCONTEXT" && p->get_name () != "CMTHOME" ? p->get_release () : "v0") << "</version><cmtpath>" << p->get_cmtpath () << "</cmtpath>";
     2697          cout << "</project>";
     2698          break;
     2699        default :
    26292700      cout << " C=" << p->get_name ();
    2630     }
    2631 
     2701          break;
     2702        }
     2703    }
     2704  switch (mode)
     2705    {
     2706    case Xml :
     2707      cout << "</uses>";
     2708      cout << "</project>";
     2709      break;
     2710    default :
    26322711  cout << endl;
     2712      break;
     2713    }
     2714
    26332715
    26342716/*
     
    26432725      if (p == 0) continue;
    26442726      level++;
    2645       p->show ();
     2727      p->show (mode);
     2728      //      p->show ();
    26462729      level--;
    26472730    }
  • CMT/HEAD/source/cmt_project.h

    r547 r550  
    112112  static void order_all ();
    113113  static void clear_all ();
    114   static void show_all ();
     114  static void show_all (PrintMode mode = Csh); // Csh is default for ArgParser::mode
     115  //  static void show_all ();
    115116  static void show_container (const cmt_string& path = "");
    116117  static void show_specified_strategies_for_all ();
     
    183184  bool operator != (const cmt_string& name) const;
    184185
    185   void show ();
     186  void show (PrintMode mode = Csh); // Csh is default for ArgParser::mode
     187  //  void show ();
    186188  void show_specified_strategies () const;
    187189
  • CMT/HEAD/source/cmt_symbol.cxx

    r549 r550  
    15271527                      cout << endl;
    15281528                    }
     1529                  else if (mode == Xml)
     1530                    {
     1531                      //                      cout << endl;
     1532                    }
    15291533                  else
    15301534                    {
     
    17381742              result = 1;
    17391743              break;
     1744            case Xml :
     1745              cout << "<variable><name>" << name << "</name>"
     1746                   << "<value>" << temp << "</value></variable>";
     1747              result = 1;
     1748              break;
    17401749          }
    17411750        break;
     
    17561765              cout << "set " << name <<
    17571766                  "=" << temp;
     1767              result = 1;
     1768              break;
     1769            case Xml :
     1770              cout << "<alias><name>" << name << "</name>"
     1771                   << "<value>" << temp << "</value></alias>";
    17581772              result = 1;
    17591773              break;
     
    17931807                case Bat :
    17941808                  cout << "call " << name;
     1809                  result = 1;
     1810                  break;
     1811                case Xml :
     1812                  cout << "<script>" << name << "</script>";
    17951813                  result = 1;
    17961814                  break;
  • CMT/HEAD/source/cmt_use.cxx

    r547 r550  
    364364
    365365//----------------------------------------------------------
    366 void Use::show_all (bool skip_discarded, ostream& out)
     366void Use::show_all (bool skip_discarded, ostream& out, PrintMode mode)
     367//void Use::show_all (bool skip_discarded, ostream& out)
    367368//void Use::show_all (bool skip_discarded)
    368369{
    369   show_all ("use ", skip_discarded, out);
     370  show_all ("use ", skip_discarded, out, mode);
     371  //  show_all ("use ", skip_discarded, out);
    370372}
    371373
     
    471473
    472474//----------------------------------------------------------
    473 void Use::show_all (const cmt_string& prefix, bool skip_discarded, ostream& out)
     475void Use::show_all (const cmt_string& prefix, bool skip_discarded, ostream& out, PrintMode mode)
     476//void Use::show_all (const cmt_string& prefix, bool skip_discarded, ostream& out)
    474477//void Use::show_all (const cmt_string& prefix, bool skip_discarded)
    475478{
     
    498501  use = &(current ());
    499502  use->unselect ();
    500   if (!Cmt::get_quiet ()) use->show_sub_uses ("", skip_discarded, out);
     503  if (!Cmt::get_quiet () && mode != Xml) use->show_sub_uses ("", skip_discarded, out);
    501504
    502505  if (uses.size () > 0)
    503506    {
    504       if (!Cmt::get_quiet ())
     507      if (!Cmt::get_quiet () && mode != Xml)
    505508        {
    506509          out << "#\n";
     
    515518      Use::move (use);
    516519
     520      switch (mode)
     521        {
     522        case Xml :
     523          Cmt::print_xml_prolog ("uses", out);
     524          out << "<uses>";
     525          break;
     526        }
     527     
    517528      for (number = uses.size () - 1; number >= 0; number--)
    518529        {
     
    540551          else
    541552            {
     553              switch (mode)
     554                {
     555                case Xml :
     556                  Symbol* s;
     557                  out << "<package"
     558                      << (use->auto_imports == Off ? " auto_imports=\"no\"" : "")
     559                      << ">";
     560                  // out << "<order>" << use->get_index () << "</order>";
     561                  out << "<name>" << use->get_package_name ()
     562                      << "</name><version>" << use->version << "</version>";
     563                  out << "<offset>" <<
     564                    ( (s = Symbol::find (use->get_package_name () + "_offset"))
     565                      ? s->build_macro_value ()
     566                      : (CmtMessage::warning
     567                         (CmtError::get_error_name (CmtError::symbol_not_found)
     568                          + ": macro " + use->get_package_name () + "_offset")
     569                         , "") )
     570                      << "</offset>";
     571                  out << "<cmtpath>" <<
     572                    ( (s = Symbol::find (use->get_package_name () + "_cmtpath"))
     573                      ? s->build_macro_value ()
     574                      : (CmtMessage::warning
     575                         (CmtError::get_error_name (CmtError::symbol_not_found)
     576                          + ": macro " + use->get_package_name () + "_cmtpath")
     577                         , "") )
     578                      << "</cmtpath>";
     579                  //out << "<offset>" << use->path << "</offset>";
     580                  //out << "<cmtpath>" << p << "</cmtpath>";
     581                  out << "<root>" << use->get_full_path () << "</root>";
     582                  //if (use->auto_imports == Off)
     583                  //out << "<no_auto_imports/>";
     584                  out << "</package>";
     585                  break;
     586                default :
    542587              static const cmt_string empty;
    543588              cmt_string p = use->real_path;
     
    547592                  if (pos != cmt_string::npos)
    548593                    {
    549                       p.erase (pos);
     594                      if (pos > 0 &&
     595                          p[pos - 1] == CmtSystem::file_separator ())
     596                        {
     597                          // strip trailing file separator
     598                          p.erase (pos - 1);
     599                        }
     600                      else
     601                        p.erase (pos);
    550602                    }
    551                 }
    552              
     603                }
     604
    553605              out << prefix << use->get_package_name ()
    554606                   << " " << use->version;
     
    573625
    574626              out << endl;
     627                  break;
     628                }
    575629            }
    576630        }
     
    579633      if (suse != 0 && !suse->discarded && !suse->m_hidden && suse->located ())
    580634        {
     635          switch (mode)
     636            {
     637            case Xml :
     638              out << "<package>";
     639              out << "<name>" << suse->get_package_name ()
     640                  << "</name><version>" << suse->version << "</version>";
     641              out << "<offset></offset>";
     642              out << "<cmtpath>" << suse->path << "</cmtpath>";
     643              out << "<root>" << suse->path << "</root>";
     644              out << "</package>";
     645              break;
     646            default :
    581647          out << prefix << suse->get_package_name ()
    582648               << " " << suse->version;
     
    586652            }
    587653          out << endl;
     654              break;
     655            }
    588656        }
    589657      suse = Use::find (CmtSystem::get_user_context_package ());
    590658      if (suse != 0 && !suse->discarded && !suse->m_hidden && suse->located ())
    591659        {
     660          switch (mode)
     661            {
     662            case Xml :
     663              out << "<package>";
     664              out << "<name>" << suse->get_package_name ()
     665                  << "</name><version>" << suse->version << "</version>";
     666              out << "<offset></offset>";
     667              out << "<cmtpath>" << suse->path << "</cmtpath>";
     668              out << "<root>" << suse->path << "</root>";
     669              out << "</package>";
     670              break;
     671            default :
    592672          out << prefix << suse->get_package_name ()
    593673               << " " << suse->version;
     
    597677            }
    598678          out << endl;
     679              break;
     680            }
     681        }
     682
     683      switch (mode)
     684        {
     685        case Xml :
     686          out << "</uses>" << endl;
     687          break;
    599688        }
    600689      /*
     
    30593148        }
    30603149    }
     3150  else
     3151    {
     3152      offset = real_path;
     3153    }
    30613154}
    30623155
  • CMT/HEAD/source/cmt_use.h

    r547 r550  
    4646  static void select_clients (const cmt_string& package,
    4747                              const cmt_string& version);
    48   static void show_all (bool skip_discarded = false, ostream& out = cout );
     48  static void show_all (bool skip_discarded = false, ostream& out = cout, PrintMode mode = Csh); // Csh is default for ArgParser::mode
     49  //  static void show_all (bool skip_discarded = false, ostream& out = cout );
    4950  //  static void show_all (bool skip_discarded = false);
    5051  static void show_all (const cmt_string& prefix, bool skip_discarded = false,
    51                         ostream& out = cout);
     52                        ostream& out = cout, PrintMode mode = Csh); // Csh is default for ArgParser::mode
    5253  //  static void show_all (const cmt_string& prefix, bool skip_discarded = false);
    5354
  • CMT/HEAD/src/setup.sh

    r11 r550  
    1919newpath=""
    2020for p in `echo ${PATH} | sed 's/:/ /g'`; do
    21   if test ! "`echo ${p} | egrep CMT`" ; then
     21  if ! echo ${p} | egrep /CMT/ >/dev/null ; then
    2222    if test "${newpath}" = "" ; then
    2323      newpath=${p}
     
    3333newpath=""
    3434for p in `echo ${CLASSPATH} | sed 's/:/ /g'`; do
    35   if test ! "`echo ${p} | egrep CMT`" ; then
     35  if ! echo ${p} | egrep /CMT/ >/dev/null ; then
    3636    if test "${newpath}" = "" ; then
    3737      newpath=${p}
Note: See TracChangeset for help on using the changeset viewer.