- Timestamp:
- Aug 23, 2010, 11:31:26 AM (14 years ago)
- Location:
- CMT/HEAD
- Files:
-
- 1 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
CMT/HEAD/ChangeLog
r549 r550 1 2010-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 1 28 2010-08-12 <rybkin@lal.in2p3.fr> 434 2 29 -
CMT/HEAD/source/cmt.h
r547 r550 261 261 static void print_symbol_names (PrintMode mode, const cmt_string& pattern = ""); 262 262 static void print_tabs (int tabs); 263 static void print_xml_prolog (const cmt_string& root = "cmt", ostream& out = cout); 263 264 static int reach_current_package (); 264 265 static void restore_all_tags (Use* use); -
CMT/HEAD/source/cmt_commands.cxx
r549 r550 382 382 pv.push_back (&ArgParser::option_without_version_directory); i++; 383 383 384 parsers.add ("-xml", i); 385 pv.push_back (&ArgParser::option_xml); i++; 384 386 } 385 387 … … 1773 1775 { 1774 1776 mode = Requirements; 1777 } 1778 1779 void ArgParser::option_xml () 1780 { 1781 mode = Xml; 1775 1782 } 1776 1783 … … 2222 2229 cerr << "# -cleanup : activate install area cleanup" << endl; 2223 2230 cerr << "# -no_cleanup : inhibit install area cleanup" << endl; 2231 cerr << "# -xml : output in XML format (cmt setup, cmt show projects, cmt show uses)" << endl; 2224 2232 } 2225 2233 -
CMT/HEAD/source/cmt_commands.h
r549 r550 69 69 void option_bat (); 70 70 void option_requirements (); 71 void option_xml (); 71 72 void option_use (); 72 73 void option_pack (); -
CMT/HEAD/source/cmt_parser.cxx
r549 r550 4042 4042 do_check_configuration (ap); 4043 4043 4044 switch (ap.mode) 4045 { 4046 case Xml : 4047 Cmt::print_xml_prolog ("setup"); 4048 cout << "<setup>"; 4049 break; 4050 } 4044 4051 print (ap.mode); 4052 switch (ap.mode) 4053 { 4054 case Xml : 4055 cout << "</setup>" << endl; 4056 break; 4057 } 4045 4058 4046 4059 // … … 4568 4581 4569 4582 //---------------------------------------------------------- 4570 void Cmt::do_show_projects (const ArgParser& /*ap*/) 4571 { 4572 Project::show_all (); 4583 void Cmt::do_show_projects (const ArgParser& ap) 4584 //void Cmt::do_show_projects (const ArgParser& /*ap*/) 4585 { 4586 Project::show_all (ap.mode); 4573 4587 } 4574 4588 … … 4774 4788 4775 4789 //---------------------------------------------------------- 4776 void Cmt::do_show_uses (const ArgParser& /*ap*/, ostream& out) 4777 { 4778 Use::show_all (false, out); 4790 void 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); 4779 4795 } 4780 4796 … … 7123 7139 } 7124 7140 7141 switch (mode) 7142 { 7143 case Xml : 7144 break; 7145 default : 7125 7146 cout << endl; 7147 break; 7148 } 7126 7149 } 7127 7150 … … 7294 7317 7295 7318 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; 7296 7341 case Requirements : 7297 7342 if (do_root && … … 7451 7496 tabs--; 7452 7497 } 7498 } 7499 7500 //---------------------------------------------------------- 7501 void 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; 7453 7510 } 7454 7511 -
CMT/HEAD/source/cmt_parser.h
r549 r550 19 19 Bat, 20 20 Make, 21 Requirements 21 Requirements, 22 Xml 22 23 } PrintMode; 23 24 -
CMT/HEAD/source/cmt_project.cxx
r547 r550 1250 1250 1251 1251 /*----------------------------------------------------------*/ 1252 void Project::show_all () 1252 void Project::show_all (PrintMode mode) 1253 //void Project::show_all () 1253 1254 { 1254 1255 static const Project::ProjectPtrVector& Ordered = Project::ordered_projects (); … … 1261 1262 } 1262 1263 1264 switch (mode) 1265 { 1266 case Xml : 1267 Cmt::print_xml_prolog ("projects"); 1268 cout << "<projects>"; 1269 break; 1270 } 1271 1263 1272 for (int i = 0; i < Ordered.size (); i++) 1264 Ordered[i]->show (); 1273 Ordered[i]->show (mode); 1274 // Ordered[i]->show (); 1265 1275 1266 1276 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 } 1269 1286 /* 1270 1287 Project* p = get_current (); … … 2583 2600 2584 2601 //---------------------------------------------------------- 2585 void Project::show () 2602 void Project::show (PrintMode mode) 2603 //void Project::show () 2586 2604 { 2587 2605 if (m_visited) return; … … 2607 2625 } 2608 2626 */ 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 : 2609 2636 for (int tab = 0; tab < level; tab++) cout << " "; 2610 2637 cout << m_name << " " << (m_name != "CMTUSERCONTEXT" && m_name != "CMTHOME" ? m_release : "v0") << " (in " << m_cmtpath << ")"; … … 2613 2640 if (m_is_current) cout << " (current)"; 2614 2641 // if (is_current) cout << " (current)"; 2642 break; 2643 } 2615 2644 2616 2645 int i; 2617 2646 2647 switch (mode) 2648 { 2649 case Xml : 2650 cout << "<clients>"; 2651 break; 2652 } 2618 2653 for (i = 0; i < m_parents.size (); i++) 2619 2654 { 2620 2655 Project* p = m_parents[i]; 2621 2656 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 : 2622 2668 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 } 2625 2685 for (i = 0; i < m_children.size (); i++) 2626 2686 { 2627 2687 Project* p = m_children[i]; 2628 2688 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 : 2629 2700 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 : 2632 2711 cout << endl; 2712 break; 2713 } 2714 2633 2715 2634 2716 /* … … 2643 2725 if (p == 0) continue; 2644 2726 level++; 2645 p->show (); 2727 p->show (mode); 2728 // p->show (); 2646 2729 level--; 2647 2730 } -
CMT/HEAD/source/cmt_project.h
r547 r550 112 112 static void order_all (); 113 113 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 (); 115 116 static void show_container (const cmt_string& path = ""); 116 117 static void show_specified_strategies_for_all (); … … 183 184 bool operator != (const cmt_string& name) const; 184 185 185 void show (); 186 void show (PrintMode mode = Csh); // Csh is default for ArgParser::mode 187 // void show (); 186 188 void show_specified_strategies () const; 187 189 -
CMT/HEAD/source/cmt_symbol.cxx
r549 r550 1527 1527 cout << endl; 1528 1528 } 1529 else if (mode == Xml) 1530 { 1531 // cout << endl; 1532 } 1529 1533 else 1530 1534 { … … 1738 1742 result = 1; 1739 1743 break; 1744 case Xml : 1745 cout << "<variable><name>" << name << "</name>" 1746 << "<value>" << temp << "</value></variable>"; 1747 result = 1; 1748 break; 1740 1749 } 1741 1750 break; … … 1756 1765 cout << "set " << name << 1757 1766 "=" << temp; 1767 result = 1; 1768 break; 1769 case Xml : 1770 cout << "<alias><name>" << name << "</name>" 1771 << "<value>" << temp << "</value></alias>"; 1758 1772 result = 1; 1759 1773 break; … … 1793 1807 case Bat : 1794 1808 cout << "call " << name; 1809 result = 1; 1810 break; 1811 case Xml : 1812 cout << "<script>" << name << "</script>"; 1795 1813 result = 1; 1796 1814 break; -
CMT/HEAD/source/cmt_use.cxx
r547 r550 364 364 365 365 //---------------------------------------------------------- 366 void Use::show_all (bool skip_discarded, ostream& out) 366 void Use::show_all (bool skip_discarded, ostream& out, PrintMode mode) 367 //void Use::show_all (bool skip_discarded, ostream& out) 367 368 //void Use::show_all (bool skip_discarded) 368 369 { 369 show_all ("use ", skip_discarded, out); 370 show_all ("use ", skip_discarded, out, mode); 371 // show_all ("use ", skip_discarded, out); 370 372 } 371 373 … … 471 473 472 474 //---------------------------------------------------------- 473 void Use::show_all (const cmt_string& prefix, bool skip_discarded, ostream& out) 475 void 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) 474 477 //void Use::show_all (const cmt_string& prefix, bool skip_discarded) 475 478 { … … 498 501 use = &(current ()); 499 502 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); 501 504 502 505 if (uses.size () > 0) 503 506 { 504 if (!Cmt::get_quiet () )507 if (!Cmt::get_quiet () && mode != Xml) 505 508 { 506 509 out << "#\n"; … … 515 518 Use::move (use); 516 519 520 switch (mode) 521 { 522 case Xml : 523 Cmt::print_xml_prolog ("uses", out); 524 out << "<uses>"; 525 break; 526 } 527 517 528 for (number = uses.size () - 1; number >= 0; number--) 518 529 { … … 540 551 else 541 552 { 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 : 542 587 static const cmt_string empty; 543 588 cmt_string p = use->real_path; … … 547 592 if (pos != cmt_string::npos) 548 593 { 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); 550 602 } 551 552 603 } 604 553 605 out << prefix << use->get_package_name () 554 606 << " " << use->version; … … 573 625 574 626 out << endl; 627 break; 628 } 575 629 } 576 630 } … … 579 633 if (suse != 0 && !suse->discarded && !suse->m_hidden && suse->located ()) 580 634 { 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 : 581 647 out << prefix << suse->get_package_name () 582 648 << " " << suse->version; … … 586 652 } 587 653 out << endl; 654 break; 655 } 588 656 } 589 657 suse = Use::find (CmtSystem::get_user_context_package ()); 590 658 if (suse != 0 && !suse->discarded && !suse->m_hidden && suse->located ()) 591 659 { 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 : 592 672 out << prefix << suse->get_package_name () 593 673 << " " << suse->version; … … 597 677 } 598 678 out << endl; 679 break; 680 } 681 } 682 683 switch (mode) 684 { 685 case Xml : 686 out << "</uses>" << endl; 687 break; 599 688 } 600 689 /* … … 3059 3148 } 3060 3149 } 3150 else 3151 { 3152 offset = real_path; 3153 } 3061 3154 } 3062 3155 -
CMT/HEAD/source/cmt_use.h
r547 r550 46 46 static void select_clients (const cmt_string& package, 47 47 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 ); 49 50 // static void show_all (bool skip_discarded = false); 50 51 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 52 53 // static void show_all (const cmt_string& prefix, bool skip_discarded = false); 53 54 -
CMT/HEAD/src/setup.sh
r11 r550 19 19 newpath="" 20 20 for p in `echo ${PATH} | sed 's/:/ /g'`; do 21 if test ! "`echo ${p} | egrep CMT`"; then21 if ! echo ${p} | egrep /CMT/ >/dev/null ; then 22 22 if test "${newpath}" = "" ; then 23 23 newpath=${p} … … 33 33 newpath="" 34 34 for p in `echo ${CLASSPATH} | sed 's/:/ /g'`; do 35 if test ! "`echo ${p} | egrep CMT`"; then35 if ! echo ${p} | egrep /CMT/ >/dev/null ; then 36 36 if test "${newpath}" = "" ; then 37 37 newpath=${p}
Note: See TracChangeset
for help on using the changeset viewer.