Changeset 664 for CMT/v1r25-branch/source/cmt_parser.cxx
- Timestamp:
- Jan 13, 2014, 4:09:37 PM (10 years ago)
- Location:
- CMT/v1r25-branch
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
CMT/v1r25-branch
-
CMT/v1r25-branch/source/cmt_parser.cxx
r642 r664 3 3 // arnault@lal.in2p3.fr 4 4 // Modified by garonne@lal.in2p3.fr 5 // Modified by Grigory Rybkin 5 6 // See the complete license in cmt_license.txt "http://www.cecill.info". 6 7 //----------------------------------------------------------- … … 10 11 #include <string.h> 11 12 #include <ctype.h> 13 #include <errno.h> 12 14 13 15 //---------------------------------------------------------- … … 50 52 } 51 53 54 //---------------------------------------------------------- 52 55 CmtContext::~CmtContext () 53 56 { 54 57 } 55 58 59 //---------------------------------------------------------- 56 60 void CmtContext::clear () 57 61 { … … 59 63 m_build_nmake = false; 60 64 m_cmt_config = ""; 61 //m_cmt_path.clear ();62 //m_cmt_path_pwds.clear ();63 //m_cmt_path_sources.clear ();64 65 m_cmt_root = ""; 66 m_cmt_home = ""; 67 m_cmt_user_context = ""; 68 m_cmt_site = ""; 65 69 m_cmt_version = ""; 66 70 m_use_cmt = true; 71 m_use_projects = true; 72 67 73 m_current_dir = ""; 68 74 m_current_file_path = ""; … … 74 80 m_current_offset = ""; 75 81 76 m_current_access = DeveloperMode; 82 m_current_access = UserMode; 83 m_current_style = cmt_style; 84 m_current_structuring_style = default_structuring_style; 77 85 78 86 m_current_tag = ""; 79 87 m_current_target = ""; 80 88 m_current_version = ""; 89 90 // m_extra_tags = ""; 91 m_extra_tags.clear (); 92 m_tags.clear (); 93 m_tags_add.clear (); 94 m_tags_remove.clear (); 95 96 m_configure_error = ""; 97 98 m_debug = (::getenv ("CMTDEBUG") != 0) ? true : false; 99 81 100 m_default_path = ""; 82 83 //m_quiet = false; 84 101 m_quiet = false; 85 102 m_disable_warnings = false; 86 103 m_warnings = false; … … 91 108 92 109 m_standard_macros_done = false; 93 m_current_access = UserMode;94 m_current_style = cmt_style;95 m_current_structuring_style = default_structuring_style;96 110 m_all_sets_done = false; 111 97 112 m_autoconfigure_cmtpath = false; 98 m_debug = false; 99 if (getenv ("CMTDEBUG") != 0) m_debug = true; 100 } 101 113 114 m_env_access = true; 115 m_print_mode = Csh; 116 m_strip_path = false; 117 } 118 //---------------------------------------------------------- 119 120 int CmtContext::initialize () 121 { 122 int errors (0); 123 124 cmt_string tags = CmtSystem::getenv ("CMTEXTRATAGS"); 125 CmtSystem::cmt_string_vector words; 126 CmtSystem::split (tags, " \t,", words); 127 for (int i = 0; i < words.size (); i++) 128 { 129 bool has (false); 130 for (int j = 0; j < m_extra_tags.size (); j++) 131 { 132 if (m_extra_tags[j] == words[i]) 133 { 134 has = true; 135 break; 136 } 137 } 138 if (!has) 139 m_extra_tags.push_back (words[i]); 140 } 141 142 return - errors; 143 } 102 144 //---------------------------------------------------------- 103 145 … … 357 399 358 400 401 //---------------------------------------------------------- 402 // 403 // The static Cmt member 404 // 405 //---------------------------------------------------------- 406 407 CmtContext& Cmt::m_cmt_context = Me; 408 //CmtContext * Cmt::m_cmt_context = &Me; 359 409 360 410 //---------------------------------------------------------- … … 462 512 463 513 //---------------------------------------------------------- 514 /* 464 515 bool Cmt::build_nmake () 465 516 { 466 517 return (Me.m_build_nmake); 467 518 } 468 519 */ 469 520 //---------------------------------------------------------- 470 521 void Cmt::build_OS9_makefile (const cmt_string& target) … … 497 548 void Cmt::clear () 498 549 { 499 Me.m_quiet = false;500 550 Me.clear (); 551 //Me.m_quiet = false; 501 552 502 553 Database::clear (); … … 507 558 508 559 //---------------------------------------------------------- 560 namespace { 561 562 bool parse_cmt_flags (const cmt_string& file_name, CmtContext& cmt) 563 { 564 cmt_string Flags (Cmt::get_cmt_flags (file_name)); 565 if (CmtError::get_last_error_code () == CmtError::file_access_error) 566 return false; 567 if (Flags.size () == 0) 568 return true; 569 570 cmt_string CmtFlags (Cmt::get_cmt_flags ()); 571 if (CmtFlags.size () != 0) 572 Flags += " " + CmtFlags; 573 574 CmtSystem::cmt_string_vector flags; 575 CmtSystem::split (Flags, " \t", flags); 576 for (int i = 0; i < flags.size (); i++) 577 { 578 if (flags[i] == "-without_cmt" && 579 cmt.m_use_cmt) 580 cmt.m_use_cmt = false; 581 else if (flags[i] == "-with_cmt" && 582 !cmt.m_use_cmt) 583 cmt.m_use_cmt = true; 584 else if (flags[i] == "-without_projects" && 585 cmt.m_use_projects) 586 cmt.m_use_projects = false; 587 else if (flags[i] == "-with_projects" && 588 !cmt.m_use_projects) 589 cmt.m_use_projects = true; 590 else if (flags[i] == "-no_strip_path" && 591 cmt.m_strip_path) 592 { 593 cmt.m_strip_path = false; 594 Symbol::set_strip_path (false); 595 } 596 else if (flags[i] == "-strip_path" && 597 !cmt.m_strip_path) 598 { 599 cmt.m_strip_path = true; 600 Symbol::set_strip_path (true); 601 } 602 } 603 604 return true; 605 } 606 607 } 608 609 //---------------------------------------------------------- 509 610 //void Cmt::configure () 510 611 void Cmt::configure (const ArgParser& ap) … … 515 616 if (configured) return; 516 617 517 Me.clear ();618 // Me.clear (); 518 619 519 620 log << "configure_cmt_message" << log_endl; … … 523 624 log << "configure_default_path" << log_endl; 524 625 configure_default_path (); 626 627 log << "restore_all_tags" << log_endl; 628 restore_all_tags (0); 525 629 log << "configure_version_tag" << log_endl; 526 630 configure_version_tag (); … … 533 637 log << "configure_site_tag" << log_endl; 534 638 configure_site_tag (0); 639 640 cmt_string requirements; 641 642 if (Me.m_current_package.size () != 0 && 643 Me.m_current_package != "cmt_standalone") 644 { 645 // we have a package name (not "cmt_standalone") 646 Use& use = Use::current(); 647 use.set (Me.m_current_package, 648 Me.m_current_version, 649 Me.m_current_path); 650 if (CmtSystem::absolute_path (Me.m_current_path)) 651 { 652 if (!use.move_to ()) 653 { 654 CmtError::set (CmtError::package_not_found, use.get_info ()); 655 return; 656 } 657 } 658 else 659 { 660 if (!use.move_to ("", true)) 661 { 662 // will try again later from CMTPATH entries 663 } 664 } 665 666 if (use.located ()) 667 { 668 // parse additional options 669 parse_cmt_flags ("requirements", m_cmt_context); 670 } 671 } 672 else 673 { 674 if (Me.m_current_path.size () != 0 && 675 !CmtSystem::cd (Me.m_current_path)) 676 { 677 CmtError::set (CmtError::path_not_found, Me.m_current_path); 678 return; 679 } 680 681 configure_current_dir (); 682 configure_current_structuring_style (ap); 683 cmt_string current_package_saved (Me.m_current_package); 684 requirements = configure_current_package (); 685 Me.m_current_package = current_package_saved; 686 if (requirements.size () != 0) 687 { 688 // parse additional options 689 parse_cmt_flags (requirements, m_cmt_context); 690 } 691 } 692 535 693 log << "configure_current_dir" << log_endl; 536 694 configure_current_dir (); … … 540 698 // log << "configure_current_dir" << log_endl; 541 699 542 543 700 bool save_quiet = Me.m_quiet; 544 701 Me.m_quiet = true; … … 546 703 Me.m_autoconfigure_cmtpath = true; 547 704 configure_cmt_path (0); 548 Me.m_autoconfigure_cmtpath = false;705 // Me.m_autoconfigure_cmtpath = false; 549 706 550 707 Me.m_quiet = save_quiet; … … 553 710 554 711 guess_current_project (); 712 713 if (Me.m_current_package.size () != 0 && 714 Me.m_current_package != "cmt_standalone") 715 { 716 Use& use = Use::current(); 717 if (!use.located ()) 718 { 719 if (!use.move_to ()) 720 { 721 CmtError::set (CmtError::package_not_found, use.get_info ()); 722 return; 723 } 724 else 725 { 726 use.get_full_path (Me.m_current_dir); 727 switch (use.style) 728 { 729 case cmt_style: 730 Me.m_current_dir += CmtSystem::file_separator (); 731 Me.m_current_dir += "cmt"; 732 break; 733 case mgr_style: 734 Me.m_current_dir += CmtSystem::file_separator (); 735 Me.m_current_dir += "mgr"; 736 break; 737 default: 738 break; 739 } 740 Me.m_current_file_path = Me.m_current_dir; 741 742 Project::order_all (); 743 Cmt::guess_current_project (); 744 } 745 } 746 } 555 747 556 748 log << "configure_current_structuring_style" << log_endl; … … 558 750 configure_current_structuring_style (ap); 559 751 752 // if (requirements.size () == 0) 753 // { 560 754 log << "configure_current_package" << log_endl; 561 755 configure_current_package (); 756 // } 562 757 563 758 Use& use = Use::current(); 564 565 use.set (Me.m_current_package, 566 Me.m_current_version, 567 Me.m_current_path, 568 "", 569 ""); 570 571 use.style = Me.m_current_style; 572 use.structuring_style = Me.m_current_structuring_style; 573 574 use.change_path (Me.m_current_path); 759 if (!use.located ()) 760 { 761 use.set (Me.m_current_package, 762 Me.m_current_version, 763 Me.m_current_path); 764 use.style = Me.m_current_style; 765 766 if (use.style != none_style) 767 { 768 use.structuring_style = Me.m_current_structuring_style; 769 use.change_path (Me.m_current_path, Project::get_current ()); 770 } 771 else 772 { 773 use.real_path = Me.m_current_path; 774 } 775 } 776 else if (const Project * p = Project::get_current ()) 777 { 778 use.set_project (p); 779 } 575 780 576 781 if (CmtError::has_pending_error ()) … … 584 789 { 585 790 if (!Me.m_autoconfigure_cmtpath) return; 791 792 if (!m_cmt_context.m_use_projects) return; 586 793 587 794 cmt_string s; … … 621 828 { 622 829 Use& current_use = Use::current (); 623 830 current_use.get_cmtpath_and_offset (Me.m_current_cmtpath, Me.m_current_offset); 831 /* 624 832 Me.m_current_cmtpath = ""; 625 833 Me.m_current_offset = ""; … … 633 841 634 842 Me.m_current_offset = current_use.path; 635 843 */ 636 844 /** 637 845 try to remove this current CMTPATH entry from path. This … … 639 847 absolute path. 640 848 */ 641 849 /* 642 850 Me.m_current_offset.replace (Me.m_current_cmtpath, empty_string); 643 851 if (Me.m_current_offset[0] == CmtSystem::file_separator ()) … … 648 856 } 649 857 } 858 */ 650 859 } 651 860 … … 731 940 void Cmt::configure_current_dir () 732 941 { 942 if (Me.m_current_dir.size () != 0) return; 943 733 944 cmt_string file_name; 734 945 … … 788 999 Me.m_current_file_path = mount_filter.get_current_dir (); 789 1000 790 cmt_string t = Me.m_current_file_path; 791 } 792 793 //---------------------------------------------------------- 794 void Cmt::configure_current_package () 1001 // cmt_string t = Me.m_current_file_path; 1002 } 1003 1004 //---------------------------------------------------------- 1005 cmt_string Cmt::configure_current_package () 1006 //void Cmt::configure_current_package () 795 1007 { 796 1008 /* … … 800 1012 standard directory tree (i.e. <package>/<version>/cmt or mgr) 801 1013 */ 1014 Use& use = Use::current(); 1015 if (use.located ()) 1016 { 1017 Me.m_current_style = use.style; 1018 build_prefix (Me.m_current_package, Me.m_current_prefix); 1019 build_config (Me.m_current_prefix, Me.m_current_config); 1020 1021 cmt_string req; 1022 use.get_full_path (req); 1023 switch (use.style) 1024 { 1025 case cmt_style: 1026 req += CmtSystem::file_separator (); 1027 req += "cmt"; 1028 break; 1029 case mgr_style: 1030 req += CmtSystem::file_separator (); 1031 req += "mgr"; 1032 break; 1033 default: 1034 break; 1035 } 1036 req += CmtSystem::file_separator (); 1037 req += "requirements"; 1038 return req; 1039 } 802 1040 803 1041 cmt_string req = ".."; … … 813 1051 else 814 1052 { 815 cmt_string req = ".."; 1053 req = ".."; 1054 // cmt_string req = ".."; 816 1055 req += CmtSystem::file_separator (); 817 1056 req += "mgr"; … … 827 1066 // This package is probably a standalone one 828 1067 Me.m_current_style = none_style; 1068 req = "requirements"; 1069 if (!CmtSystem::test_file (req)) 1070 { 1071 req = ""; 1072 } 829 1073 } 830 1074 } … … 1062 1306 // Do NOT (re)set m_current_structuring_style yet 1063 1307 // (as requirements may NOT exist, so this is not a package) 1064 // rather do it in reach_current_package (if/when requirements is read)1308 // rather do it in use_current_package (if/when requirements is read) 1065 1309 //Me.m_current_structuring_style = without_version_directory; 1066 1310 build_prefix (Me.m_current_package, Me.m_current_prefix); 1067 1311 build_config (Me.m_current_prefix, Me.m_current_config); 1068 1312 } 1313 1314 return req; 1069 1315 } 1070 1316 … … 1074 1320 { 1075 1321 cmt_string s; 1076 s = CmtSystem::getenv ("CMTSTRUCTURINGSTYLE"); 1077 if (s == "without_version_directory") 1078 { 1079 Me.m_current_structuring_style = without_version_directory; 1080 } 1081 else if (s == "with_version_directory") 1082 { 1083 Me.m_current_structuring_style = with_version_directory; 1084 } 1085 1086 CmtSystem::cmt_string_vector flags; 1087 Cmt::get_cmt_flags (flags); 1088 for (int i = 0; i < flags.size (); i++) 1089 { 1090 const cmt_string& flag = flags[i]; 1091 if (flag == "-without_version_directory") 1322 if (Me.m_current_structuring_style == default_structuring_style) 1323 { 1324 s = CmtSystem::getenv ("CMTSTRUCTURINGSTYLE"); 1325 if (s == "without_version_directory") 1092 1326 { 1093 1327 Me.m_current_structuring_style = without_version_directory; 1094 1328 } 1095 else if ( flag == "-with_version_directory")1329 else if (s == "with_version_directory") 1096 1330 { 1097 1331 Me.m_current_structuring_style = with_version_directory; 1098 } 1099 } 1100 1101 for (int i = 1; i < ap.argc; i++) 1102 { 1103 const cmt_string& arg = ap.argv[i]; 1104 if (arg[0] != '-') break; 1105 if (arg == "-without_v" || 1106 arg == "-without_ve" || 1107 arg == "-without_ver" || 1108 arg == "-without_vers" || 1109 arg == "-without_versi" || 1110 arg == "-without_versio" || 1111 arg == "-without_version" || 1112 arg == "-without_version_" || 1113 arg == "-without_version_d" || 1114 arg == "-without_version_di" || 1115 arg == "-without_version_dir" || 1116 arg == "-without_version_dire" || 1117 arg == "-without_version_direc" || 1118 arg == "-without_version_direct" || 1119 arg == "-without_version_directo" || 1120 arg == "-without_version_director" || 1121 arg == "-without_version_directory") 1122 { 1123 Me.m_current_structuring_style = without_version_directory; 1124 // if (!CmtSystem::putenv ("CMTSTRUCTURINGSTYLE", "without_version_directory")) 1125 // CmtMessage::error ("Cannot set `CMTSTRUCTURINGSTYLE' to" 1126 // " `without_version_directory' in the environment"); 1127 if (!Cmt::add_cmt_flag ("-without_version_directory")) 1128 CmtMessage::error ("Cannot add flag `-without_version_directory'"); 1129 } 1130 else if (arg == "-with_v" || 1131 arg == "-with_ve" || 1132 arg == "-with_ver" || 1133 arg == "-with_vers" || 1134 arg == "-with_versi" || 1135 arg == "-with_versio" || 1136 arg == "-with_version" || 1137 arg == "-with_version_" || 1138 arg == "-with_version_d" || 1139 arg == "-with_version_di" || 1140 arg == "-with_version_dir" || 1141 arg == "-with_version_dire" || 1142 arg == "-with_version_direc" || 1143 arg == "-with_version_direct" || 1144 arg == "-with_version_directo" || 1145 arg == "-with_version_director" || 1146 arg == "-with_version_directory") 1147 { 1148 Me.m_current_structuring_style = with_version_directory; 1149 // if (!CmtSystem::putenv ("CMTSTRUCTURINGSTYLE", "with_version_directory")) 1150 // CmtMessage::error ("Cannot set `CMTSTRUCTURINGSTYLE' to" 1151 // " `with_version_directory' in the environment"); 1152 if (!Cmt::add_cmt_flag ("-with_version_directory")) 1153 CmtMessage::error ("Cannot add flag `-with_version_directory'"); 1332 } 1333 1334 CmtSystem::cmt_string_vector flags; 1335 Cmt::get_cmt_flags (flags); 1336 for (int i = 0; i < flags.size (); i++) 1337 { 1338 const cmt_string& flag = flags[i]; 1339 if (flag == "-without_version_directory") 1340 { 1341 Me.m_current_structuring_style = without_version_directory; 1342 } 1343 else if (flag == "-with_version_directory") 1344 { 1345 Me.m_current_structuring_style = with_version_directory; 1346 } 1347 } 1348 } 1349 1350 if (Me.m_current_structuring_style != default_structuring_style) 1351 { 1352 StrategyDef* def = StrategyMgr::find_strategy ("VersionDirectory"); 1353 if (def != 0) 1354 { 1355 def->m_default_value = 1356 Me.m_current_structuring_style == with_version_directory; 1357 def->m_priority_value = 1358 Me.m_current_structuring_style == without_version_directory; 1154 1359 } 1155 1360 } … … 1171 1376 void Cmt::configure_home (Use* use) 1172 1377 { 1173 Me.m_cmt_home = ""; 1174 1175 Symbol* symbol = Symbol::find ("CMTHOME"); 1176 if (symbol != 0) 1177 { 1178 Me.m_cmt_home = symbol->build_macro_value (); 1179 Symbol::expand (Me.m_cmt_home); 1180 } 1181 else if (CmtSystem::testenv ("CMTHOME")) 1182 { 1183 Me.m_cmt_home = CmtSystem::getenv ("CMTHOME"); 1378 if (Me.m_cmt_home.size () == 0) 1379 { 1380 // if not passed on the command line 1381 if (const Symbol* symbol = Symbol::find ("CMTHOME")) 1382 { 1383 Me.m_cmt_home = symbol->build_macro_value (); 1384 Symbol::expand (Me.m_cmt_home); 1385 } 1386 else if (CmtSystem::testenv ("CMTHOME")) 1387 { 1388 Me.m_cmt_home = CmtSystem::getenv ("CMTHOME"); 1389 } 1184 1390 } 1185 1391 … … 1195 1401 void Cmt::configure_user_context (Use* use) 1196 1402 { 1197 Me.m_cmt_user_context = ""; 1198 1199 Symbol* symbol = Symbol::find ("CMTUSERCONTEXT"); 1200 if (symbol != 0) 1201 { 1202 Me.m_cmt_user_context = symbol->build_macro_value (); 1203 Symbol::expand (Me.m_cmt_user_context); 1204 } 1205 else if (CmtSystem::testenv ("CMTUSERCONTEXT")) 1206 { 1207 Me.m_cmt_user_context = CmtSystem::getenv ("CMTUSERCONTEXT"); 1403 if (Me.m_cmt_user_context.size () == 0) 1404 { 1405 // if not passed on the command line 1406 if (const Symbol* symbol = Symbol::find ("CMTUSERCONTEXT")) 1407 { 1408 Me.m_cmt_user_context = symbol->build_macro_value (); 1409 Symbol::expand (Me.m_cmt_user_context); 1410 } 1411 else if (CmtSystem::testenv ("CMTUSERCONTEXT")) 1412 { 1413 Me.m_cmt_user_context = CmtSystem::getenv ("CMTUSERCONTEXT"); 1414 } 1208 1415 } 1209 1416 … … 1272 1479 1273 1480 Cmt::configure_tags (use); 1481 1482 cmt_string s, t; 1483 if (0 < Me.m_extra_tags.size ()) 1484 { 1485 s = "CMTEXTRATAGS"; 1486 t = use != 0 ? use->get_package_name () : s; 1487 } 1488 for (int i = 0; i < Me.m_extra_tags.size (); i++) 1489 { 1490 Tag* tag = Tag::add (Me.m_extra_tags[i], PriorityUserTag, s, use); 1491 tag->mark (t); 1492 } 1493 1494 for (int i = 0; i < Me.m_tags.size (); i++) 1495 { 1496 const cmt_string& a = Me.m_tags[i]; 1497 if (i == 0) 1498 { 1499 Me.m_current_tag = a; 1500 } 1501 // // Then restore uname if the specified tag is CMTCONFIG 1502 // if (a == CmtSystem::get_cmt_config ()) 1503 // { 1504 // Cmt::configure_uname_tag (); 1505 // } 1506 Tag* tag = Tag::add (a, PriorityArgument, "arguments", 0); 1507 tag->mark ("arguments"); 1508 } 1509 1510 for (int i = 0; i < Me.m_tags_add.size (); i++) 1511 { 1512 const cmt_string& a = Me.m_tags_add[i]; 1513 // // Then restore uname if the specified tag is CMTCONFIG 1514 // if (a == CmtSystem::get_cmt_config ()) 1515 // { 1516 // Cmt::configure_uname_tag (); 1517 // } 1518 Tag* tag = Tag::add (a, PriorityUserTag, "arguments", 0); 1519 tag->mark ("arguments"); 1520 } 1274 1521 1275 1522 /* … … 1277 1524 */ 1278 1525 1526 /* 1279 1527 if (CmtSystem::testenv ("CMTEXTRATAGS")) 1280 1528 { … … 1309 1557 } 1310 1558 } 1559 */ 1311 1560 } 1312 1561 … … 1319 1568 1320 1569 log << "current_tag=" << Me.m_current_tag << log_endl; 1570 1571 cmt_string s = "CMTCONFIG"; 1321 1572 1322 1573 Symbol* symbol = Symbol::find ("CMTCONFIG"); … … 1347 1598 { 1348 1599 config_tag = CmtSystem::getenv ("CMTBIN"); 1600 s = "CMTBIN"; 1349 1601 } 1350 1602 … … 1352 1604 { 1353 1605 CmtSystem::get_uname (config_tag); 1606 s = "uname"; 1354 1607 } 1355 1608 1356 1609 log << "current_tag=" << Me.m_current_tag << log_endl; 1357 1610 1358 cmt_string s = "CMTCONFIG";1611 // cmt_string s = "CMTCONFIG"; 1359 1612 cmt_string t = s; 1360 1613 … … 1552 1805 if (CmtMessage::level () != Warning) 1553 1806 CmtMessage::set_level (Warning); 1554 // if (CmtMessage::level () > Warning)1555 }1556 }1557 1558 for (int i = 1; i < ap.argc; i++)1559 {1560 const cmt_string& arg = ap.argv[i];1561 if (arg[0] != '-') break;1562 if (arg == "-d" ||1563 arg == "-di" ||1564 arg == "-dis" ||1565 arg == "-disa" ||1566 arg == "-disab" ||1567 arg == "-disabl" ||1568 arg == "-disable" ||1569 arg == "-disable_" ||1570 arg == "-disable_w" ||1571 arg == "-disable_wa" ||1572 arg == "-disable_war" ||1573 arg == "-disable_warn" ||1574 arg == "-disable_warni" ||1575 arg == "-disable_warnin" ||1576 arg == "-disable_warning" ||1577 arg == "-disable_warnings")1578 {1579 Me.m_disable_warnings = true;1580 if (CmtMessage::level () <= Warning)1581 {1582 CmtMessage::set_level (Error);1583 // if (!CmtSystem::putenv ("CMTERROR", "1"))1584 // CmtMessage::error ("Cannot set `CMTERROR' in the environment");1585 }1586 if (!Cmt::add_cmt_flag ("-disable_warnings"))1587 CmtMessage::error ("Cannot add flag `-disable_warnings'");1588 }1589 else if (arg == "-q" ||1590 arg == "-qu" ||1591 arg == "-qui" ||1592 arg == "-quie" ||1593 arg == "-quiet")1594 {1595 Me.m_quiet = true;1596 if (CmtMessage::level () <= Error)1597 {1598 CmtMessage::set_level (Fatal);1599 // if (!CmtSystem::putenv ("CMTFATAL", "1"))1600 // CmtMessage::error ("Cannot set `CMTFATAL' in the environment");1601 }1602 if (!Cmt::add_cmt_flag ("-quiet"))1603 CmtMessage::error ("Cannot add flag `-quiet'");1604 }1605 else if (arg == "-warn" ||1606 arg == "-warni" ||1607 arg == "-warnin" ||1608 arg == "-warning" ||1609 arg == "-warnings")1610 {1611 Me.m_warnings = true;1612 // if (CmtMessage::level () > Warning)1613 if (CmtMessage::level () != Warning)1614 {1615 CmtMessage::set_level (Warning);1616 // if (!CmtSystem::putenv ("CMTWARNING", "1"))1617 // CmtMessage::error ("Cannot set `CMTWARNING' in the environment");1618 }1619 if (!Cmt::add_cmt_flag ("-warnings"))1620 CmtMessage::error ("Cannot add flag `-warnings'");1621 1807 } 1622 1808 } … … 1668 1854 1669 1855 CmtSystem::cmt_string_vector uses; 1856 cmt_vector<int> use_indexes; 1670 1857 CmtSystem::cmt_string_vector packages; 1671 1858 CmtSystem::cmt_string_vector versions; 1672 CmtSystem::cmt_string_vector path_selections; 1859 Project::ConstProjectPtrVector path_selections; 1860 // CmtSystem::cmt_string_vector path_selections; 1861 Project::ConstProjectPtrVector path_exclusions; 1673 1862 CmtSystem::cmt_string_vector selections; 1674 1863 CmtSystem::cmt_string_vector exclusions; … … 1677 1866 bool is_cmt = false; 1678 1867 int first = 0; 1679 int i;1680 1868 bool ignore_errors = false; 1681 1869 bool all_packages = false; 1682 1870 int depth (1); 1683 1871 bool local = true; 1684 1685 for (i = 0; i < ap.arguments.size (); i++) 1872 bool global (false); 1873 1874 for (int i = 0; i < ap.arguments.size (); i++) 1686 1875 { 1687 1876 const cmt_string& w = ap.arguments[i]; … … 1699 1888 { 1700 1889 local = false; 1890 global = false; 1701 1891 1702 1892 cmt_string depth_str; 1703 int depth_value = 0;1893 int depth_value; 1704 1894 1705 1895 w.substr (7, depth_str); 1706 if ((sscanf (depth_str.c_str (), "%d", &depth_value) < 1) || 1707 (depth_value < 1)) 1708 { 1896 int n = sscanf (depth_str.c_str (), "%d", &depth_value); 1897 cmt_string msg; 1898 switch (n) 1899 { 1900 case EOF: 1901 msg = "Cannot read `depth' value `"; 1902 msg += depth_str; 1903 msg += cmt_string ("'"); 1904 if (errno) 1905 msg += cmt_string (strerror (errno)); 1906 CmtError::set (CmtError::system_error, msg); 1907 return; 1908 break; 1909 case 0: 1910 msg = "Invalid `depth' value `"; 1911 msg += depth_str; 1912 msg += cmt_string ("'"); 1913 CmtError::set (CmtError::syntax_error, msg); 1914 return; 1915 break; 1916 case 1: 1917 if (depth_value < -1) 1918 { 1919 char num[32]; sprintf (num, "%lu", -depth_value); 1920 msg = "Invalid `depth' value `-"; 1921 msg += num; 1922 msg += cmt_string ("'"); 1923 CmtError::set (CmtError::syntax_error, msg); 1924 return; 1925 } 1926 depth = depth_value; 1927 //cerr << "depth: " << depth << endl; 1928 break; 1929 default: 1930 break; 1931 } 1932 // if ((sscanf (depth_str.c_str (), "%d", &depth_value) < 1) || 1933 // (depth_value < 1)) 1934 // { 1709 1935 // Syntax error 1710 1936 // We shall restrict to packages found within … … 1712 1938 // If CMTPATH is empty, nothing is selected. 1713 1939 // depth=1 is equivalent to local 1714 }1715 1716 Project::fill_selection (depth_value, path_selections);1940 // } 1941 1942 // Project::fill_selection (depth_value, path_selections); 1717 1943 } 1718 1944 else if (w.substr (0, 9) == "-exclude=") … … 1738 1964 else if (w.substr (0, 7) == "-global") 1739 1965 { 1740 path_selections.clear ();1741 1966 //path_selections.clear (); 1967 global = true; 1742 1968 local = false; 1743 1969 } … … 1745 1971 { 1746 1972 local = true; 1973 global = false; 1747 1974 } 1748 1975 else if (w.substr (0, 8) == "-select=") … … 1787 2014 } 1788 2015 1789 if (local) 1790 { 1791 Project::fill_selection (1, path_selections); 2016 const Project* p_cur (Project::get_current ()); 2017 if (global) 2018 { 2019 Project::fill_exclusion (path_exclusions); 2020 } 2021 else if (local) 2022 { 2023 if (p_cur) 2024 Project::fill_selection (1, path_selections); 2025 else 2026 path_selections.push_back (0); // means that we want Use::current () 2027 // path_selections.push_back ((Use::current ()).get_realpath ()); 2028 } 2029 else 2030 { 2031 if (!p_cur 2032 && depth != 0 2033 && depth != -1) 2034 path_selections.push_back (0); // means that we want Use::current () 2035 // path_selections.push_back ((Use::current ()).get_realpath ()); 2036 Project::fill_selection (depth, path_selections); 2037 /* 2038 cerr << "depth: " << depth << endl; 2039 for (int j = 0; j < path_selections.size (); j++) 2040 { 2041 const Project* sp = path_selections[j]; 2042 cerr << "path_selections: " << (sp ? sp->get_cmtpath () : "current use") << endl; 2043 } 2044 */ 1792 2045 } 1793 2046 … … 1800 2053 //if (command.substr (0, 3) == "cmt") is_cmt = true; 1801 2054 1802 cmt_string curuse = CmtSystem::pwd ();2055 //cmt_string curuse = CmtSystem::pwd (); 1803 2056 if (all_packages) 1804 2057 { … … 1806 2059 PathScanner scanner; 1807 2060 Project::scan_paths (scanner, selector); 2061 return; 1808 2062 } 1809 2063 else 1810 2064 { 1811 for (i = Uses.size () - 1; i >= 0; i--)2065 for (int i = Uses.size () - 1; i >= 0; i--) 1812 2066 { 1813 2067 Use* use = Uses[i]; … … 1815 2069 if (use->discarded) continue; 1816 2070 if (use->m_hidden) continue; 1817 1818 2071 if (!use->located ()) 1819 2072 { 1820 CmtMessage::warning ("package " + use->get_package_name () 1821 + " " + use->version + " " + use->path 1822 + " not found"); 1823 /* 1824 if (!Me.m_quiet) 1825 { 1826 cerr << "#CMT> package " << use->get_package_name () << 1827 " " << use->version << " " << use->path << 1828 " not found" << 1829 endl; 1830 } 1831 */ 2073 CmtMessage::warning 2074 (CmtError::get_error_name (CmtError::package_not_found) 2075 + ": " + use->get_info ()); 2076 continue; 1832 2077 } 1833 else 1834 { 1835 if (use->get_package_name () != "CMT") 1836 { 1837 cmt_string& s = uses.add (); 1838 1839 use->get_full_path (s); 1840 1841 s += CmtSystem::file_separator (); 1842 if (use->style == mgr_style) s += "mgr"; 1843 else s += "cmt"; 1844 1845 cmt_string& v = versions.add (); 1846 v = use->version; 1847 1848 cmt_string& p = packages.add (); 1849 p = use->get_package_name (); 1850 } 1851 } 1852 } 2078 if (use->get_package_name () == "CMT") continue; 2079 2080 cmt_string& s = uses.add (); 2081 use->get_full_path (s); 2082 switch (use->style) 2083 { 2084 case cmt_style: 2085 s += CmtSystem::file_separator (); 2086 s += "cmt"; 2087 break; 2088 case mgr_style: 2089 s += CmtSystem::file_separator (); 2090 s += "mgr"; 2091 break; 2092 default: 2093 break; 2094 } 2095 // if (use->style == mgr_style) s += "mgr"; 2096 // else s += "cmt"; 2097 2098 cmt_string& v = versions.add (); 2099 v = use->version; 2100 2101 cmt_string& p = packages.add (); 2102 p = use->get_package_name (); 2103 2104 int& use_index = use_indexes.add (); 2105 use_index = i; 2106 } 1853 2107 1854 2108 { 2109 Use* use = &(Use::current ()); 2110 1855 2111 cmt_string& s = uses.add (); 2112 use->get_full_path (s); 2113 switch (use->style) 2114 { 2115 case cmt_style: 2116 s += CmtSystem::file_separator (); 2117 s += "cmt"; 2118 break; 2119 case mgr_style: 2120 s += CmtSystem::file_separator (); 2121 s += "mgr"; 2122 break; 2123 default: 2124 break; 2125 } 2126 // if (use->get_package_name ().find ("cmt_standalone") != cmt_string::npos) 2127 // { 2128 // s = CmtSystem::pwd (); 2129 // } 2130 // else 2131 // { 2132 // use->get_full_path (s); 2133 2134 // s += CmtSystem::file_separator (); 1856 2135 1857 Use* use = &(Use::current ()); 1858 1859 if (use->get_package_name ().find ("cmt_standalone") != cmt_string::npos) 1860 { 1861 s = CmtSystem::pwd (); 1862 } 1863 else 1864 { 1865 use->get_full_path (s); 1866 1867 s += CmtSystem::file_separator (); 1868 1869 if (use->style == mgr_style) s += "mgr"; 1870 else s += "cmt"; 1871 } 1872 1873 curuse = s; 2136 // if (use->style == mgr_style) s += "mgr"; 2137 // else s += "cmt"; 2138 // } 2139 //curuse = s; 1874 2140 1875 2141 cmt_string& v = versions.add (); … … 1878 2144 cmt_string& p = packages.add (); 1879 2145 p = use->get_package_name (); 2146 2147 int& use_index = use_indexes.add (); 2148 use_index = -1; 1880 2149 } 1881 2150 } … … 1891 2160 CmtSystem::putenv ("CMTBCAST", ""); 1892 2161 1893 for (i = 0; i < uses.size (); i++)2162 for (int i = 0; i < uses.size (); i++) 1894 2163 { 1895 2164 const cmt_string& s = uses[i]; 1896 2165 const cmt_string& v = versions[i]; 1897 2166 const cmt_string& p = packages[i]; 2167 const int use_index = use_indexes[i]; 2168 2169 const Use* use = use_index >= 0 ? Uses[use_index] : &(Use::current ()); 2170 const Project* up = use->get_project (); 2171 1898 2172 cmt_string cmtpath; 1899 2173 1900 2174 bool ok = true; 1901 bool selected = true;2175 bool selected = global ? true : false; 1902 2176 bool excluded = false; 1903 2177 1904 /** 1905 Ensure that the current package is not skipped 1906 due to symlinks in the paths 1907 */ 1908 // if (path_selections.size () > 0) 1909 if (path_selections.size () > 0 && s != curuse) 2178 ok = selected; 2179 if (path_selections.size () > 0) 1910 2180 { 1911 2181 selected = false; 1912 1913 2182 for (int j = 0; j < path_selections.size (); j++) 1914 2183 { 1915 const cmt_string& sel = path_selections[j]; 1916 1917 if (s.find (sel) != cmt_string::npos) 1918 { 1919 cmtpath = sel; 1920 selected = true; 1921 break; 1922 } 1923 } 1924 2184 const Project* sp = path_selections[j]; 2185 if (sp) 2186 { 2187 if (up) 2188 { 2189 if (up == sp) 2190 { 2191 cmtpath = sp->get_cmtpath (); 2192 selected = true; 2193 break; 2194 } 2195 } 2196 else 2197 { 2198 if (use->get_realpath ().find (sp->get_cmtpath_real ()) == 0) 2199 { 2200 cmtpath = sp->get_cmtpath (); 2201 selected = true; 2202 break; 2203 } 2204 } 2205 } 2206 else if (use == &(Use::current ())) 2207 { 2208 // means that we want Use::current () 2209 // cmtpath = sp->get_cmtpath (); 2210 if (up) 2211 cmtpath = up->get_cmtpath (); 2212 else 2213 cmtpath = ""; 2214 selected = true; 2215 break; 2216 } 2217 // const cmt_string& sel = path_selections[j]; 2218 // if (s.find (sel) != cmt_string::npos) 2219 // { 2220 // cmtpath = sel; 2221 // selected = true; 2222 // break; 2223 // } 2224 } 1925 2225 ok = selected; 1926 2226 } 2227 else if (up) 2228 cmtpath = up->get_cmtpath (); 1927 2229 1928 2230 if (ok) … … 1960 2262 } 1961 2263 1962 1963 2264 if (ok) 1964 2265 { … … 1974 2275 break; 1975 2276 } 2277 } 2278 2279 if (excluded) ok = false; 2280 } 2281 2282 if (ok) 2283 { 2284 excluded = false; 2285 for (int j = 0; j < path_exclusions.size (); j++) 2286 { 2287 const Project* sp = path_exclusions[j]; 2288 if (up) 2289 { 2290 if (up == sp) 2291 { 2292 excluded = true; 2293 break; 2294 } 2295 } 2296 else 2297 { 2298 if (use->get_realpath ().find (sp->get_cmtpath_real ()) == 0) 2299 { 2300 excluded = true; 2301 break; 2302 } 2303 } 1976 2304 } 1977 2305 … … 2021 2349 } 2022 2350 2351 /* 2023 2352 if (cmtpath == "") 2024 2353 { … … 2026 2355 cmtpath = Project::find_in_cmt_paths (sel); 2027 2356 } 2357 */ 2028 2358 2029 2359 cmt_string cmd = command; … … 2041 2371 static const cmt_string empty_string; 2042 2372 static const cmt_string fs = CmtSystem::file_separator (); 2043 cmt_string offset = s; 2044 offset.replace (cmtpath, empty_string); 2045 if (offset[0] == CmtSystem::file_separator ()) 2046 { 2047 offset.replace (fs, empty_string); 2048 } 2049 CmtSystem::dirname (offset, offset); 2050 2051 cmt_string n; 2052 CmtSystem::basename (offset, n); 2053 if (n == p) 2054 { 2373 cmt_string offset; 2374 if (cmtpath.size ()) 2375 { 2376 offset = s; 2377 offset.replace (cmtpath, empty_string); 2378 if (offset[0] == CmtSystem::file_separator ()) 2379 { 2380 offset.replace (fs, empty_string); 2381 } 2055 2382 CmtSystem::dirname (offset, offset); 2383 2384 cmt_string n; 2385 CmtSystem::basename (offset, n); 2386 if (n == p) 2387 { 2388 CmtSystem::dirname (offset, offset); 2389 } 2390 else 2391 { 2392 CmtSystem::dirname (offset, offset); 2393 CmtSystem::dirname (offset, offset); 2394 } 2056 2395 } 2057 2396 else 2058 2397 { 2059 CmtSystem::dirname (offset, offset); 2060 CmtSystem::dirname (offset, offset); 2061 } 2062 2398 offset = use->real_path; 2399 } 2063 2400 cmd.replace_all (offset_template, offset); 2064 2401 … … 2067 2404 { 2068 2405 cout << "#--------------------------------------------------------------" << endl; 2069 cout << "# Now trying [" << cmd << "] in " << s << " (" << i+1 << "/" << uses.size ()2406 cout << "# " << p << " " << v << " " << offset << ": Now trying [" << cmd << "] in " << s << " (" << i+1 << "/" << uses.size () 2070 2407 << ")" << endl; 2071 2408 cout << "#--------------------------------------------------------------" << endl; … … 2904 3241 } 2905 3242 2906 static CmtSystem::cmt_string_vector tags;3243 // static CmtSystem::cmt_string_vector tags; 2907 3244 2908 3245 if (action_build_constituents_config != get_action ()) 2909 CmtSystem::split (Me.m_extra_tags, " \t,", tags); 2910 2911 for (int i = 0; i < tags.size (); i++) 2912 { 2913 const cmt_string& t = tags[i]; 2914 2915 tag = Tag::find (t); 2916 if (tag == 0) continue; 2917 2918 if (!Tag::check_tag_used (tag) && !Symbol::check_tag_used (tag)) 2919 { 2920 CmtMessage::warning ("The tag " + t + " is not used in any tag expression. Please check spelling"); 2921 // cerr << "#CMT> The tag " << t << " is not used in any tag expression. Please check spelling" << endl; 2922 } 2923 } 2924 2925 Symbol::check_all_paths (); 3246 { 3247 // CmtSystem::split (Me.m_extra_tags, " \t,", tags); 3248 3249 // for (int i = 0; i < tags.size (); i++) 3250 // { 3251 // const cmt_string& t = tags[i]; 3252 for (int i = 0; i < Me.m_extra_tags.size (); i++) 3253 { 3254 const cmt_string& t = Me.m_extra_tags[i]; 3255 tag = Tag::find (t); 3256 if (tag == 0) continue; 3257 if (!Tag::check_tag_used (tag) && !Symbol::check_tag_used (tag)) 3258 { 3259 CmtMessage::warning ("The tag " + t + " is not used in any tag expression. Please check spelling"); 3260 } 3261 } 3262 for (int i = 0; i < Me.m_tags.size (); i++) 3263 { 3264 const cmt_string& t = Me.m_tags[i]; 3265 tag = Tag::find (t); 3266 if (tag == 0) continue; 3267 if (!Tag::check_tag_used (tag) && !Symbol::check_tag_used (tag)) 3268 { 3269 CmtMessage::warning ("The tag " + t + " is not used in any tag expression. Please check spelling"); 3270 } 3271 } 3272 for (int i = 0; i < Me.m_tags_add.size (); i++) 3273 { 3274 const cmt_string& t = Me.m_tags_add[i]; 3275 tag = Tag::find (t); 3276 if (tag == 0) continue; 3277 if (!Tag::check_tag_used (tag) && !Symbol::check_tag_used (tag)) 3278 { 3279 CmtMessage::warning ("The tag " + t + " is not used in any tag expression. Please check spelling"); 3280 } 3281 } 3282 } 3283 3284 if (action_setup != get_action () || 3285 Requirements == ap.mode) 3286 // PathBuilder::filter_path_value is called 3287 // for each path in Symbol::print 3288 Symbol::check_all_paths (); 2926 3289 2927 3290 env = CmtSystem::getenv ("CMTSITE"); … … 2940 3303 { 2941 3304 CmtMessage::warning ("The CMTSITE value " + env + " is not used in any tag expression. Please check spelling"); 2942 // cerr << "#CMT> The CMTSITE value " << env << " is not used in any tag expression. Please check spelling" << endl;2943 3305 } 2944 3306 … … 4323 4685 break; 4324 4686 case Requirements : 4687 /* 4325 4688 CmtSystem::cmt_string_vector flags; 4326 4689 get_cmt_flags (flags); 4327 4690 cout << "\n# CMTFLAGS: -without_cmt"; 4691 cout << " -without_projects" ; 4328 4692 for (int i = 0; i < flags.size (); i++) 4329 4693 { … … 4332 4696 else if (flags[i] == "-with_cmt") 4333 4697 cout << " -without_cmt"; 4698 else if (flags[i] == "-without_projects") 4699 cout << " -with_projects"; 4700 else if (flags[i] == "-with_projects") 4701 cout << " -without_projects"; 4334 4702 else 4335 4703 cout << " " << flags[i]; 4336 4704 } 4337 4705 cout << endl; 4706 */ 4338 4707 break; 4339 } 4340 print (ap.mode); 4708 default: 4709 break; 4710 } 4711 4712 ostringstream os; 4713 ostringstream oh; 4714 bool reset (false); 4715 CmtSystem::cmt_string_vector flags; 4716 cmt_string strip_path_flag; 4717 bool strip_path (false); 4718 4719 bool strip_saved (get_strip_path ()); 4720 bool access_saved (Cmt::get_env_access ()); 4721 4722 switch (ap.mode) 4723 { 4724 case Requirements : 4725 4726 get_cmt_flags (flags); 4727 for (int i = 0; i < flags.size (); i++) 4728 { 4729 if (flags[i] == "-no_strip_path") 4730 strip_path_flag = "-no_strip_path"; 4731 else if (flags[i] == "-strip_path") 4732 strip_path_flag = "-strip_path"; 4733 } 4734 if (strip_path_flag != "-no_strip_path" && 4735 !get_strip_path ()) 4736 reset = Symbol::set_strip_path (true); 4737 4738 if (get_strip_path () || reset) 4739 strip_path = true; 4740 else 4741 strip_path = false; 4742 4743 Cmt::set_env_access (false); 4744 4745 print (ap.mode, os); 4746 4747 if (CmtError::get_last_error_code () == CmtError::warning && 4748 (get_strip_path () || reset)) 4749 { 4750 reset = Symbol::set_strip_path (false); 4751 if (reset) 4752 { 4753 strip_path = false; 4754 4755 CmtError::print (); 4756 CmtError::clear (); 4757 4758 if (Cmt::get_debug ()) 4759 { 4760 cerr << "|Cmt::do_setup> Failure with:\n" << os.str () 4761 << "|Cmt::do_setup> Trying again." << endl; 4762 } 4763 4764 // Try again 4765 os.str (""); 4766 print (ap.mode, os); 4767 } 4768 } 4769 4770 if (reset) Symbol::set_strip_path (strip_saved); 4771 Cmt::set_env_access (access_saved); 4772 4773 //get_cmt_flags (flags); 4774 oh << "\n# CMTFLAGS:" 4775 " -without_cmt" 4776 " -without_projects" 4777 //" -strip_path" 4778 ; 4779 for (int i = 0; i < flags.size (); i++) 4780 { 4781 if (flags[i] == "-without_cmt") 4782 oh << " -with_cmt"; 4783 else if (flags[i] == "-with_cmt") 4784 oh << " -without_cmt"; 4785 else if (flags[i] == "-without_projects") 4786 oh << " -with_projects"; 4787 else if (flags[i] == "-with_projects") 4788 oh << " -without_projects"; 4789 /* 4790 else if (flags[i] == "-no_strip_path") 4791 oh << " -strip_path"; 4792 else if (flags[i] == "-strip_path") 4793 oh << " -no_strip_path"; 4794 */ 4795 else if (flags[i] == "-no_strip_path" || 4796 flags[i] == "-strip_path") 4797 continue; 4798 else 4799 oh << " " << flags[i]; 4800 } 4801 //if (reset) oh << " -strip_path"; 4802 if (strip_path) 4803 oh << " -no_strip_path"; 4804 else 4805 oh << " -strip_path"; 4806 oh << endl; 4807 4808 cout << oh.str (); 4809 cout << os.str (); 4810 4811 break; 4812 4813 default: 4814 4815 print (ap.mode); 4816 4817 break; 4818 } 4819 4341 4820 switch (ap.mode) 4342 4821 { … … 4476 4955 4477 4956 Use& use = Use::current(); 4957 /* 4478 4958 use.get_cmtpath_and_offset (cmtpath, offset); 4479 4959 4480 4960 Project* p = Project::find_by_cmtpath (cmtpath); 4481 4482 cout << p->get_author () << endl; 4961 */ 4962 if (const Project* p = use.get_project ()) 4963 cout << p->get_author () << endl; 4483 4964 } 4484 4965 … … 4503 4984 ClientCollector collector (package, version); 4504 4985 4986 /* 4505 4987 clear (); 4506 4988 // configure (); 4507 4989 configure (ap); 4990 */ 4508 4991 4509 4992 cout << "# ----------- Clients of " << package … … 5164 5647 5165 5648 //---------------------------------------------------------- 5649 /* 5166 5650 ActionType Cmt::get_action () 5167 5651 { 5168 5652 return (Me.m_action); 5169 5653 } 5170 5654 */ 5171 5655 /* 5172 5656 const CmtSystem::cmt_string_vector& Cmt::get_cmt_path () … … 5185 5669 } 5186 5670 */ 5187 5671 /* 5188 5672 const cmt_string& Cmt::get_cmt_home () 5189 5673 { … … 5205 5689 return (Me.m_current_dir); 5206 5690 } 5207 5691 */ 5208 5692 const cmt_string Cmt::get_current_dir_real () 5209 5693 { … … 5213 5697 return (Me.m_current_dir); 5214 5698 } 5215 5699 /* 5216 5700 const cmt_string& Cmt::get_current_package () 5217 5701 { 5218 5702 return (Me.m_current_package); 5219 5703 } 5220 5704 */ 5221 5705 const cmt_string& Cmt::get_current_path () 5222 5706 { … … 5233 5717 return (Me.m_current_offset); 5234 5718 } 5235 5719 /* 5236 5720 AccessMode Cmt::get_current_access () 5237 5721 { … … 5248 5732 return (Me.m_current_style); 5249 5733 } 5250 5734 */ 5251 5735 const cmt_string& Cmt::get_current_version () 5252 5736 { 5253 5737 return (Me.m_current_version); 5254 5738 } 5255 5739 /* 5256 5740 const cmt_string& Cmt::get_current_target () 5257 5741 { 5258 5742 return (Me.m_current_target); 5259 5743 } 5260 5744 */ 5745 /* 5746 const CmtSystem::cmt_string_vector& Cmt::get_tags_remove () 5747 { 5748 return (Me.m_tags_remove); 5749 } 5750 */ 5751 /* 5261 5752 bool Cmt::get_debug () 5262 5753 { … … 5283 5774 return (Me.m_recursive); 5284 5775 } 5285 5776 */ 5286 5777 CmtScopeFilteringMode Cmt::get_scope_filtering_mode () 5287 5778 { … … 5297 5788 5298 5789 //---------------------------------------------------------- 5790 /* 5299 5791 bool Cmt::get_all_sets_done () 5300 5792 { 5301 5793 return (Me.m_all_sets_done); 5302 5794 } 5303 5795 */ 5304 5796 //---------------------------------------------------------- 5305 5797 void Cmt::get_cmt_flags (CmtSystem::cmt_string_vector& flags) … … 5421 5913 void Cmt::guess_current_project () 5422 5914 { 5915 if (!m_cmt_context.m_use_projects) return; 5916 5423 5917 Log; 5424 5918 5425 5919 log << "guess_current_project" << log_endl; 5426 5920 5427 cmt_string here = CmtSystem::pwd ();5921 // cmt_string here = CmtSystem::pwd (); 5428 5922 5429 5923 Use& use = Use::current(); … … 5438 5932 // if (Project::find_in_cmt_paths (Me.m_current_dir) == "") 5439 5933 { 5934 /* 5440 5935 if (!CmtSystem::cd (current_path)) 5441 5936 { … … 5444 5939 return; 5445 5940 } 5941 */ 5446 5942 cmt_string project_file = "cmt"; 5447 5943 project_file += CmtSystem::file_separator (); 5448 5944 project_file += Project::get_project_file_name (); 5449 5945 5450 cmt_string pwd; 5946 /* 5947 cmt_string pwd (CmtSystem::pwd ()); 5948 cmt_string pwd_prev; 5949 */ 5950 cmt_string dir_cur (current_path); 5951 cmt_string dir_par; 5952 5953 cmt_string proj_file_cur; 5451 5954 5452 5955 for (;;) 5453 5956 { 5454 pwd = CmtSystem::pwd (); 5957 /* 5958 // pwd = CmtSystem::pwd (); 5455 5959 if (CmtSystem::test_file (project_file)) 5456 5960 { … … 5462 5966 break; 5463 5967 } 5464 5465 log << "pwd=" << CmtSystem::pwd () << log_endl; 5968 */ 5969 proj_file_cur = dir_cur; 5970 proj_file_cur += CmtSystem::file_separator (); 5971 proj_file_cur += project_file; 5972 if (CmtSystem::test_file (proj_file_cur)) 5973 { 5974 //this directory should become the first entry of the CMTPATH 5975 5976 IProjectFactory& factory = ProjectFactory::instance (); 5977 factory.create_project ("", dir_cur, "CurrentProject", 0); 5978 5979 break; 5980 } 5981 5982 /* 5983 log << "pwd=" << pwd << log_endl; 5466 5984 5467 5985 if (!CmtSystem::cd ("..")) … … 5471 5989 } 5472 5990 5473 if (CmtSystem::pwd () == pwd) 5991 pwd_prev = pwd; 5992 pwd = CmtSystem::pwd (); 5993 if (pwd == pwd_prev) 5994 // if (CmtSystem::pwd () == pwd) 5474 5995 { 5475 5996 log << "Looks the same pwd..." << log_endl; 5476 5997 break; 5477 5998 } 5478 } 5479 5480 CmtSystem::cd (Me.m_current_dir); 5481 } 5999 */ 6000 log << "dir_cur=`" << dir_cur << "'" << log_endl; 6001 CmtSystem::dirname (dir_cur, dir_par); 6002 if (dir_par == dir_cur) 6003 { 6004 log << "Looks the same dir_cur..." << log_endl; 6005 break; 6006 } 6007 dir_cur = dir_par; 6008 } 6009 6010 // CmtSystem::cd (Me.m_current_dir); 6011 } // if (Project::find_in_cmt_paths (current_path) == "") 5482 6012 5483 6013 //cmt_string buffer = "path CMTPATH \n"; … … 5487 6017 // Use& use = Use::current(); 5488 6018 6019 bool autoconfigure_cmtpath_saved (Me.m_autoconfigure_cmtpath); 6020 Me.m_autoconfigure_cmtpath = false; 5489 6021 bool save_quiet = Me.m_quiet; 5490 6022 Me.m_quiet = true; … … 5493 6025 5494 6026 Me.m_quiet = save_quiet; 5495 5496 Me.m_autoconfigure_cmtpath = true; 5497 5498 CmtSystem::cd (here); 6027 Me.m_autoconfigure_cmtpath = autoconfigure_cmtpath_saved; 6028 // Me.m_autoconfigure_cmtpath = true; 6029 6030 // CmtSystem::cd (Me.m_current_dir); 6031 //CmtSystem::cd (here); 5499 6032 } 5500 6033 … … 5966 6499 fprintf (f, "endif\n"); 5967 6500 fprintf (f, "source ${CMTROOT}/mgr/setup.csh\n"); 5968 fprintf (f, "set cmt%stempfile=`${CMTROOT}/ mgr/cmt-quiet build temporary_name`\n", mangled_package.c_str ());6501 fprintf (f, "set cmt%stempfile=`${CMTROOT}/${CMTBIN}/cmt.exe -quiet build temporary_name`\n", mangled_package.c_str ()); 5969 6502 fprintf (f, "if $status != 0 then\n set cmt%stempfile=/tmp/cmt.$$\nendif\n", mangled_package.c_str ()); 5970 //fprintf (f, "${CMTROOT}/mgr/cmt setup -%s " 5971 fprintf (f, "${CMTROOT}/mgr/cmt %s -%s " 6503 fprintf (f, "${CMTROOT}/${CMTBIN}/cmt.exe %s -%s " 5972 6504 "-pack=%s -version=%s -path=%s %s $* >${cmt%stempfile}\n", 5973 6505 action.c_str (), … … 5980 6512 fprintf (f, 5981 6513 "if ( $status != 0 ) then\n" 5982 " echo \"${CMTROOT}/ mgr/cmt%s -%s "6514 " echo \"${CMTROOT}/${CMTBIN}/cmt.exe %s -%s " 5983 6515 "-pack=%s -version=%s -path=%s %s $* >${cmt%stempfile}\"\n" 5984 6516 " set cmt%sstatus=2\n" … … 6026 6558 fprintf (f, "fi\n"); 6027 6559 fprintf (f, ". ${CMTROOT}/mgr/setup.sh\n"); 6028 fprintf (f, "cmt%stempfile=`${CMTROOT}/ mgr/cmt-quiet build temporary_name`\n", mangled_package.c_str ());6560 fprintf (f, "cmt%stempfile=`${CMTROOT}/${CMTBIN}/cmt.exe -quiet build temporary_name`\n", mangled_package.c_str ()); 6029 6561 fprintf (f, "if test ! $? = 0 ; then cmt%stempfile=/tmp/cmt.$$; fi\n", mangled_package.c_str ()); 6030 //fprintf (f, "${CMTROOT}/mgr/cmt setup -%s " 6031 fprintf (f, "${CMTROOT}/mgr/cmt %s -%s " 6562 fprintf (f, "${CMTROOT}/${CMTBIN}/cmt.exe %s -%s " 6032 6563 "-pack=%s -version=%s -path=%s %s $* >${cmt%stempfile}\n", 6033 6564 action.c_str (), … … 6040 6571 fprintf (f, 6041 6572 "if test $? != 0 ; then\n" 6042 " echo >&2 \"${CMTROOT}/ mgr/cmt%s -%s "6573 " echo >&2 \"${CMTROOT}/${CMTBIN}/cmt.exe %s -%s " 6043 6574 "-pack=%s -version=%s -path=%s %s $* >${cmt%stempfile}\"\n" 6044 6575 " cmt%sstatus=2\n" … … 6074 6605 else if (mode[i] == Bat) 6075 6606 { 6076 //fprintf (f, "rem Setting %s %s in %%~d0%%~p0\n",6077 6607 fprintf (f, "rem %s %s %s in %%~d0%%~p0\n", 6078 6608 action.c_str (), … … 6409 6939 6410 6940 /** 6411 * See reach_current_packagefor an explanation of this call6941 * See apply_globals for an explanation of this call 6412 6942 */ 6413 6943 Pattern::apply_all_globals (); … … 6444 6974 Me.m_action = action_none; 6445 6975 6446 restore_all_tags (0);6976 // restore_all_tags (0); 6447 6977 6448 6978 #ifdef WIN32 … … 6481 7011 int Cmt::parser (int argc, char* argv[]) 6482 7012 { 7013 // save CMTFLAGS 7014 cmt_string cmtflags (get_cmt_flags ()); 7015 7016 clear (); 7017 Me.initialize (); 7018 6483 7019 ArgParser ap (Me); 6484 7020 … … 6493 7029 } 6494 7030 6495 // save CMTFLAGS 6496 cmt_string cmtflags (get_cmt_flags ()); 6497 6498 clear (); 7031 // clear (); 7032 7033 // Me.clear (); 7034 7035 parse_arguments (ap); 7036 // Copy ap.mode into cmt_context member/instance 7037 set_print_mode (ap.mode); 6499 7038 6500 7039 // configure (); 6501 configure (ap); 6502 6503 CmtError::clear (); 7040 switch (Me.m_action) 7041 { 7042 case action_none : 7043 case action_build_temporary_name : 7044 case action_help : 7045 break; 7046 default: 7047 configure (ap); 7048 break; 7049 } 7050 7051 // CmtError::clear (); 6504 7052 6505 7053 /* 6506 Set private if positioned inside the package7054 Set DeveloperMode if positioned inside the package 6507 7055 (which is detected since we were able to retreive the 6508 7056 Version, Package and Path) 6509 7057 */ 6510 7058 7059 if (!Use::current().located ()) 7060 /* 6511 7061 if ((Me.m_current_path.size () == 0) || 6512 7062 (Me.m_current_package.size () == 0) || 6513 7063 (Me.m_current_version.size () == 0)) 7064 */ 6514 7065 { 6515 7066 Me.m_current_access = UserMode; … … 6520 7071 } 6521 7072 6522 parse_arguments (ap);7073 // parse_arguments (ap); 6523 7074 6524 7075 if (ap.help_action == action_help) … … 6826 7377 switch (Me.m_action) 6827 7378 { 6828 case action_none :7379 //case action_none : 6829 7380 case action_awk : 6830 7381 case action_broadcast : … … 6929 7480 Me.m_warnings = false; 6930 7481 if (strlen (ap.extra_file.c_str ()) == 0) 6931 reach_current_package (); 7482 use_current_package (); 7483 // reach_current_package (); 6932 7484 else 6933 7485 use_extra_file (ap.extra_file); … … 6935 7487 if (strlen (ap.extra_line.c_str ()) > 0) 6936 7488 SyntaxParser::parse_requirements_text (ap.extra_line, "extra statement(s)", (Use*) 0); 7489 apply_globals (); 6937 7490 Me.m_warnings = w; 6938 //if (strlen (ap.extra_line.c_str ()) > 0) SyntaxParser::parse_requirements_line (ap.extra_line, &(Use::current ()));6939 7491 } 6940 7492 break; … … 6952 7504 if (use != 0 && !use->discarded && !use->m_hidden && use->located ()) 6953 7505 uses.push_back (use); 6954 uses.push_back (&(Use::current())); 7506 use = &(Use::current()); 7507 if (use != 0 && !use->discarded && !use->m_hidden && use->located ()) 7508 uses.push_back (use); 7509 // uses.push_back (&(Use::current())); 6955 7510 use = Use::find (CmtSystem::get_user_context_package ()); 6956 7511 if (use != 0 && !use->discarded && !use->m_hidden && use->located ()) … … 7424 7979 * joined with semi-colons to form one shell command. 7425 7980 */ 7426 void Cmt::print (PrintMode mode )7981 void Cmt::print (PrintMode mode, ostream& out) 7427 7982 { 7428 7983 Use::UsePtrVector& Uses = Use::get_ordered_uses (); … … 7452 8007 // 7453 8008 8009 /* 7454 8010 { 7455 8011 CmtSystem::cmt_string_vector words; … … 7477 8033 } 7478 8034 } 7479 8035 */ 7480 8036 if (mode == Requirements) 7481 8037 { … … 7487 8043 if (tag != 0) 7488 8044 { 7489 tag->show (true, cout, "apply_tag ");8045 tag->show (true, out, "apply_tag "); 7490 8046 } 7491 8047 } … … 7508 8064 if (use.m_hidden) continue; 7509 8065 7510 print_context (use, mode, tag );7511 } 7512 } 7513 7514 print_context (Use::current (), mode, tag );8066 print_context (use, mode, tag, out); 8067 } 8068 } 8069 8070 print_context (Use::current (), mode, tag, out); 7515 8071 7516 8072 if (Me.m_debug) … … 7519 8075 } 7520 8076 7521 Symbol::all_print (mode );8077 Symbol::all_print (mode, out); 7522 8078 // Script::all_print (mode); 7523 8079 … … 7532 8088 break; 7533 8089 default : 7534 cout << endl;8090 out << endl; 7535 8091 break; 7536 8092 } … … 7638 8194 7639 8195 //---------------------------------------------------------- 7640 void Cmt::print_context (Use& use, PrintMode mode, const cmt_string& tag )8196 void Cmt::print_context (Use& use, PrintMode mode, const cmt_string& tag, ostream& out) 7641 8197 { 7642 8198 if (use.get_package_name () == "cmt_standalone") return; … … 7654 8210 switch (mode) 7655 8211 { 8212 case Xml : 7656 8213 case Requirements : 7657 8214 break; … … 7670 8227 if (do_root) 7671 8228 { 7672 cout << "setenv " << prefix << "ROOT \"" <<8229 out << "setenv " << prefix << "ROOT \"" << 7673 8230 use.get_full_path () << "\"" << endl; 7674 8231 } … … 7676 8233 if (use.get_package_name () == "CMT") 7677 8234 { 7678 cout << "setenv CMTCONFIG " << system << endl;8235 out << "setenv CMTCONFIG " << system << endl; 7679 8236 } 7680 8237 else … … 7682 8239 if (do_config) 7683 8240 { 7684 cout << "setenv " << prefix << "CONFIG \"" << tag << "\"" << endl;8241 out << "setenv " << prefix << "CONFIG \"" << tag << "\"" << endl; 7685 8242 } 7686 8243 } … … 7690 8247 if (do_root) 7691 8248 { 7692 cout << prefix << "ROOT=\"" <<8249 out << prefix << "ROOT=\"" << 7693 8250 use.get_full_path () << "\"; export " << 7694 8251 prefix << "ROOT" << endl; … … 7697 8254 if (use.get_package_name () == "CMT") 7698 8255 { 7699 cout << "CMTCONFIG=" << system << "; export CMTCONFIG" << endl;8256 out << "CMTCONFIG=" << system << "; export CMTCONFIG" << endl; 7700 8257 } 7701 8258 else … … 7703 8260 if (do_config) 7704 8261 { 7705 cout << prefix << "CONFIG=\"" <<8262 out << prefix << "CONFIG=\"" << 7706 8263 tag << "\"; export " << 7707 8264 prefix << "CONFIG" << endl; … … 7713 8270 if (do_root) 7714 8271 { 7715 cout << "set " << prefix << "ROOT=" <<8272 out << "set " << prefix << "ROOT=" << 7716 8273 CmtSystem::quote (use.get_full_path (), " \t") << endl; 7717 8274 } … … 7719 8276 if (use.get_package_name () == "CMT") 7720 8277 { 7721 cout << "set CMTCONFIG=" << system << endl;8278 out << "set CMTCONFIG=" << system << endl; 7722 8279 } 7723 8280 else … … 7725 8282 if (do_config) 7726 8283 { 7727 cout << "set " << prefix << "CONFIG=" << CmtSystem::quote (tag, " \t") << endl;8284 out << "set " << prefix << "CONFIG=" << CmtSystem::quote (tag, " \t") << endl; 7728 8285 } 7729 8286 } … … 7733 8290 if (do_root) 7734 8291 { 7735 cout << "<variable><name>" << prefix << "ROOT</name>"7736 8292 out << "<variable><name>" << prefix << "ROOT</name>" 8293 << "<value>" << use.get_full_path () << "</value></variable>"; 7737 8294 } 7738 8295 7739 8296 if (use.get_package_name () == "CMT") 7740 8297 { 7741 cout << "<variable><name>CMTCONFIG</name>"7742 8298 out << "<variable><name>CMTCONFIG</name>" 8299 << "<value>" << system << "</value></variable>"; 7743 8300 } 7744 8301 else … … 7746 8303 if (do_config) 7747 8304 { 7748 cout << "<variable><name>" << prefix << "CONFIG</name>"7749 8305 out << "<variable><name>" << prefix << "CONFIG</name>" 8306 << "<value>" << tag << "</value></variable>"; 7750 8307 } 7751 8308 } … … 7756 8313 use.get_package_name () != "CMT") 7757 8314 { 7758 cout << "set " << use.prefix << "ROOT " <<8315 out << "set " << use.prefix << "ROOT " << 7759 8316 CmtSystem::quote (use.get_full_path (), " \t") << endl; 7760 8317 … … 7775 8332 if (use.get_package_name () == "CMT") 7776 8333 { 7777 cout << "set CMTCONFIG " << system << endl;8334 out << "set CMTCONFIG " << system << endl; 7778 8335 } 7779 8336 else … … 7781 8338 if (do_config) 7782 8339 { 7783 cout << "set " << use.prefix << "CONFIG " << CmtSystem::quote (tag, " \t") << endl; 8340 out << "set " << use.prefix << "CONFIG " << CmtSystem::quote (tag, " \t") << endl; 8341 8342 cmt_string name (use.prefix + "CONFIG"); 8343 Symbol* symbol = Symbol::find (name); 8344 if (symbol != 0) 8345 { 8346 symbol->printed = true; 8347 } 8348 if (symbol == 0 || symbol->type != Symbol::SymbolMacro) 8349 { 8350 CmtMessage::warning 8351 (CmtError::get_error_name (CmtError::symbol_not_found) 8352 + ": macro " + name); 8353 } 7784 8354 } 7785 8355 } … … 7939 8509 7940 8510 //---------------------------------------------------------- 7941 int Cmt:: reach_current_package ()8511 int Cmt::use_current_package () 7942 8512 { 7943 8513 Use& use = Use::current (); … … 7946 8516 if (Me.m_debug) 7947 8517 { 7948 cout << "Cmt:: reach_current_package> pwd = "8518 cout << "Cmt::use_current_package> pwd = " 7949 8519 << CmtSystem::pwd () 7950 8520 << " path=" << Me.m_current_path … … 7959 8529 if (Me.m_current_package == "cmt_standalone") 7960 8530 { 7961 if ((Me.m_current_path != "") && (Me.m_current_path != CmtSystem::pwd ())) 8531 if ((Me.m_current_path != "") && (Me.m_current_path != Me.m_current_dir)) 8532 // if ((Me.m_current_path != "") && (Me.m_current_path != CmtSystem::pwd ())) 7962 8533 { 7963 8534 if (!CmtSystem::cd (Me.m_current_path)) 7964 8535 { 7965 8536 CmtError::set (CmtError::package_not_found, 7966 "ReachCurrentPackage> Cannot reach the path directory"); 8537 "Cannot reach the path directory: " 8538 + Me.m_current_path); 7967 8539 return (0); 7968 8540 } … … 7975 8547 7976 8548 Me.m_current_structuring_style = without_version_directory; 8549 use.structuring_style = Me.m_current_structuring_style; 8550 use.change_path (Me.m_current_path, Project::get_current ()); 8551 Me.m_current_access = DeveloperMode; 7977 8552 } 7978 8553 else if (Me.m_current_package != "") 7979 8554 { 7980 if (!use.move_to () && !use.move_to ("", true)) 7981 // if (!use.move_to ()) 7982 { 7983 CmtError::set (CmtError::package_not_found, 7984 "ReachCurrentPackage> Cannot reach the path directory"); 7985 return (0); 7986 } 7987 7988 Me.m_current_path = use.real_path; 8555 if (!use.located ()) 8556 { 8557 // if (!use.move_to () && !use.move_to ("", true)) 8558 // if (!use.move_to ()) 8559 if (!use.move_to ()) 8560 { 8561 if (!CmtSystem::cd (Cmt::get_current_dir ())) 8562 { 8563 CmtError::set (CmtError::file_access_error, 8564 Cmt::get_current_dir () 8565 + " (use_current_package)"); 8566 return 0; 8567 } 8568 if (!use.move_to ("", true)) 8569 { 8570 CmtError::set (CmtError::package_not_found, use.get_info ()); 8571 return 0; 8572 } 8573 } 8574 8575 Me.m_current_path = use.real_path; 8576 Me.m_current_access = DeveloperMode; 8577 } 7989 8578 } 7990 8579 else … … 8024 8613 8025 8614 CmtError::set (CmtError::package_not_found, 8026 "ReachCurrentPackage> Cannot reach the mgr/cmt directory"); 8615 "Cannot reach the mgr/cmt directory: " 8616 + use.get_info ()); 8027 8617 return (0); 8028 8618 } … … 8030 8620 else 8031 8621 Me.m_current_style = none_style; 8622 8623 Me.m_current_access = DeveloperMode; 8032 8624 8033 8625 dir = CmtSystem::pwd (); … … 8057 8649 use.style = Me.m_current_style; 8058 8650 use.structuring_style = Me.m_current_structuring_style; 8059 } 8060 8651 8652 configure_current_dir (); 8653 build_prefix (Me.m_current_package, Me.m_current_prefix); 8654 build_config (Me.m_current_prefix, Me.m_current_config); 8655 } 8656 8657 /* 8061 8658 configure_current_dir (); 8062 8659 build_prefix (Me.m_current_package, Me.m_current_prefix); 8063 8660 build_config (Me.m_current_prefix, Me.m_current_config); 8661 */ 8064 8662 8065 8663 /* … … 8067 8665 */ 8068 8666 8069 if (Me.m_debug) cout << " reach_current_package0> current_tag=" << Me.m_current_tag << endl;8667 if (Me.m_debug) cout << "use_current_package0> current_tag=" << Me.m_current_tag << endl; 8070 8668 8071 8669 if (Me.m_current_tag == "") … … 8078 8676 Tag* tag; 8079 8677 8080 tag = Tag::add (env, PriorityConfig, " reachcurrent package", 0);8678 tag = Tag::add (env, PriorityConfig, "current package", 0); 8081 8679 tag->mark (use.get_package_name ()); 8082 8680 //Me.m_current_tag = env; 8083 8681 8084 //if (!Me.m_quiet) cerr << " reach_current_package1> current_tag=" << Me.m_current_tag << endl;8682 //if (!Me.m_quiet) cerr << "use_current_package1> current_tag=" << Me.m_current_tag << endl; 8085 8683 8086 8684 } … … 8100 8698 SyntaxParser::parse_requirements (dir, &use); 8101 8699 8102 if (Me.m_debug) cout << "reach_current_package2> current_tag=" << Me.m_current_tag << endl; 8700 if (CmtError::has_pending_error ()) return 0; 8701 8702 if (Me.m_debug) cout << "use_current_package2> current_tag=" << Me.m_current_tag << endl; 8703 8704 return 1; 8705 } 8706 8707 //---------------------------------------------------------- 8708 int Cmt::use_extra_file (const cmt_string& file) 8709 { 8710 if (!CmtSystem::test_file (file)) 8711 { 8712 CmtError::set (CmtError::path_not_found, file); 8713 return 0; 8714 } 8715 8716 // (almost) Cmt::use_current_package () 8717 Use& use = Use::current (); 8718 /* 8719 Try to access the package. 8720 */ 8721 8722 if (Me.m_current_package == "cmt_standalone") 8723 { 8724 if ((Me.m_current_path != "") && (Me.m_current_path != Me.m_current_dir)) 8725 // if ((Me.m_current_path != "") && (Me.m_current_path != CmtSystem::pwd ())) 8726 { 8727 if (!CmtSystem::cd (Me.m_current_path)) 8728 { 8729 CmtError::set (CmtError::package_not_found, 8730 "Cannot reach the path directory: " 8731 + Me.m_current_path); 8732 return (0); 8733 } 8734 } 8735 /* 8736 if (!CmtSystem::test_file ("requirements")) 8737 { 8738 return (0); 8739 } 8740 */ 8741 Me.m_current_structuring_style = without_version_directory; 8742 use.structuring_style = Me.m_current_structuring_style; 8743 use.change_path (Me.m_current_path, Project::get_current ()); 8744 Me.m_current_access = DeveloperMode; 8745 } 8746 else if (Me.m_current_package != "") 8747 { 8748 if (!use.located ()) 8749 { 8750 // if (!use.move_to () && !use.move_to ("", true)) 8751 // if (!use.move_to ()) 8752 if (!use.move_to ()) 8753 { 8754 if (!CmtSystem::cd (Cmt::get_current_dir ())) 8755 { 8756 CmtError::set (CmtError::file_access_error, 8757 Cmt::get_current_dir () 8758 + " (use_extra_file)"); 8759 return 0; 8760 } 8761 if (!use.move_to ("", true)) 8762 { 8763 CmtError::set (CmtError::package_not_found, use.get_info ()); 8764 return 0; 8765 } 8766 } 8767 8768 Me.m_current_path = use.real_path; 8769 Me.m_current_access = DeveloperMode; 8770 } 8771 } 8772 else 8773 { 8774 // 8775 // The cmt command has been given without explicit search for 8776 // a package. Thus it is expected that we are in the context of a 8777 // true package. 8778 // 8779 // This means that there should be a requirements file visible. 8780 // 8781 // If this is not true, we'll make a try into ../cmt and then 8782 // a last try into ../mgr 8783 // 8784 8785 Me.m_current_access = DeveloperMode; 8786 //... 8787 configure_current_dir (); 8788 build_prefix (Me.m_current_package, Me.m_current_prefix); 8789 build_config (Me.m_current_prefix, Me.m_current_config); 8790 } 8791 8792 /* 8793 configure_current_dir (); 8794 build_prefix (Me.m_current_package, Me.m_current_prefix); 8795 build_config (Me.m_current_prefix, Me.m_current_config); 8796 */ 8797 8798 /* 8799 Check Tag is always set up 8800 */ 8801 8802 if (Me.m_debug) cout << "use_extra_file0> current_tag=" << Me.m_current_tag << endl; 8803 8804 if (Me.m_current_tag == "") 8805 { 8806 cmt_string env; 8807 8808 env = CmtSystem::getenv (Me.m_current_config); 8809 if (env != "") 8810 { 8811 Tag* tag; 8812 8813 tag = Tag::add (env, PriorityConfig, "current package", 0); 8814 tag->mark (use.get_package_name ()); 8815 //Me.m_current_tag = env; 8816 8817 //if (!Me.m_quiet) cerr << "use_extra_file1> current_tag=" << Me.m_current_tag << endl; 8818 8819 } 8820 } 8821 8822 if (Me.m_debug) 8823 { 8824 cout << "pwd = " << CmtSystem::pwd () << endl; 8825 } 8826 8827 /* 8828 Work on the requirements file. 8829 */ 8830 8831 SyntaxParser::parse_requirements (file, &use); 8832 8833 if (CmtError::has_pending_error ()) return 0; 8834 8835 if (Me.m_debug) cout << "use_extra_file2> current_tag=" << Me.m_current_tag << endl; 8836 return 1; 8837 } 8838 8839 //---------------------------------------------------------- 8840 int Cmt::apply_globals () 8841 { 8103 8842 8104 8843 /** … … 8131 8870 Tag::restore_tree (); 8132 8871 8133 return (1); 8134 } 8135 8136 //---------------------------------------------------------- 8137 int Cmt::use_extra_file (const cmt_string& file) 8138 { 8139 if (!CmtSystem::test_file (file)) 8140 { 8141 CmtError::set (CmtError::path_not_found, file); 8142 return 0; 8143 } 8144 8145 // (almost) Cmt::reach_current_package () 8146 Use& use = Use::current (); 8147 /* 8148 Try to access the package. 8149 */ 8150 8151 if (Me.m_current_package == "cmt_standalone") 8152 { 8153 if ((Me.m_current_path != "") && (Me.m_current_path != CmtSystem::pwd ())) 8154 { 8155 if (!CmtSystem::cd (Me.m_current_path)) 8156 { 8157 CmtError::set (CmtError::package_not_found, 8158 "ReachCurrentPackage> Cannot reach the path directory"); 8159 return (0); 8160 } 8161 } 8162 /* 8163 if (!CmtSystem::test_file ("requirements")) 8164 { 8165 return (0); 8166 } 8167 */ 8168 Me.m_current_structuring_style = without_version_directory; 8169 } 8170 else if (Me.m_current_package != "") 8171 { 8172 if (!use.move_to () && !use.move_to ("", true)) 8173 // if (!use.move_to ()) 8174 { 8175 CmtError::set (CmtError::package_not_found, 8176 "ReachCurrentPackage> Cannot reach the path directory"); 8177 // return -1; 8178 return (0); 8179 } 8180 8181 Me.m_current_path = use.real_path; 8182 } 8183 else 8184 { 8185 // 8186 // The cmt command has been given without explicit search for 8187 // a package. Thus it is expected that we are in the context of a 8188 // true package. 8189 // 8190 // This means that there should be a requirements file visible. 8191 // 8192 // If this is not true, we'll make a try into ../cmt and then 8193 // a last try into ../mgr 8194 // 8195 8196 //... 8197 } 8198 8199 configure_current_dir (); 8200 build_prefix (Me.m_current_package, Me.m_current_prefix); 8201 build_config (Me.m_current_prefix, Me.m_current_config); 8202 8203 /* 8204 Check Tag is always set up 8205 */ 8206 8207 if (Me.m_debug) cout << "use_extra_file0> current_tag=" << Me.m_current_tag << endl; 8208 8209 if (Me.m_current_tag == "") 8210 { 8211 cmt_string env; 8212 8213 env = CmtSystem::getenv (Me.m_current_config); 8214 if (env != "") 8215 { 8216 Tag* tag; 8217 8218 tag = Tag::add (env, PriorityConfig, "reach current package", 0); 8219 tag->mark (use.get_package_name ()); 8220 //Me.m_current_tag = env; 8221 8222 //if (!Me.m_quiet) cerr << "use_extra_file1> current_tag=" << Me.m_current_tag << endl; 8223 8224 } 8225 } 8226 8227 if (Me.m_debug) 8228 { 8229 cout << "pwd = " << CmtSystem::pwd () << endl; 8230 } 8231 8232 /* 8233 Work on the requirements file. 8234 */ 8235 8236 SyntaxParser::parse_requirements (file, &use); 8237 8238 if (Me.m_debug) cout << "use_extra_file2> current_tag=" << Me.m_current_tag << endl; 8239 8240 /** 8241 * It would be useful to change this mechanism. Instead of 8242 * applying all global patterns at once to all use contexts, it 8243 * would be much better to apply it at the end of each 8244 * requirements file parsing, and only in the context the 8245 * appropriate Use. 8246 * 8247 * This would avoid the current flaw which is that when a global 8248 * pattern specifies a "private" definition, it is actually 8249 * applied in the scope context of the Current Use and not in 8250 * each individual Use. Therefore the private is lost. 8251 * 8252 * However, this induces problems since some pattern definitions 8253 * are done AFTER the use statements, which will NOT receive the 8254 * pattern aplications. 8255 * 8256 * Therefore it is decided to leave this "bad" mechanism until 8257 * everybody is aware of this constraint. 8258 * 8259 * 8260 */ 8261 Pattern::apply_all_globals (); 8262 8263 /* 8264 Select all possible tags 8265 */ 8266 8267 Tag::restore_tree (); 8268 8269 return (1); 8872 if (CmtError::has_pending_error ()) return 0; 8873 8874 return 1; 8270 8875 } 8271 8876 … … 9676 10281 9677 10282 //---------------------------------------------------------- 10283 /* 9678 10284 void Cmt::set_current_access (AccessMode mode) 9679 10285 { … … 9692 10298 Me.m_scope_filtering_mode = mode; 9693 10299 } 9694 10300 */ 9695 10301 //---------------------------------------------------------- 9696 10302 void Cmt::set_standard_macros () … … 9836 10442 builder.fill_for_constituent_macros (); 9837 10443 } 9838 10444 /* 9839 10445 void Cmt::set_all_sets_done () 9840 10446 { … … 9846 10452 Me.m_all_sets_done = false; 9847 10453 } 9848 10454 */ 9849 10455 //---------------------------------------------------------- 9850 10456 void Cmt::use_cmt () … … 9905 10511 if (CmtSystem::test_file (f)) 9906 10512 { 9907 use->m_located = true; 9908 } 9909 SyntaxParser::parse_requirements (f, use); 10513 use->style = none_style; 10514 use->structuring_style = without_version_directory; 10515 10516 if (name == CmtSystem::get_home_package () || 10517 name == CmtSystem::get_user_context_package ()) 10518 { 10519 const Project::ProjectPtrVector& Ordered = Project::ordered_projects (); 10520 if (0 == Ordered.size ()) 10521 { 10522 if (m_cmt_context.m_use_projects) 10523 { 10524 CmtError::set(CmtError::configuration_error, 10525 "No such ordered project: " + use->get_info ()); 10526 return; 10527 } 10528 else 10529 { 10530 use->change_path (path); 10531 } 10532 } 10533 else 10534 { 10535 if (name == CmtSystem::get_home_package ()) 10536 use->change_path (path, Ordered[Ordered.size () - 1]); 10537 else if (name == CmtSystem::get_user_context_package ()) 10538 use->change_path (path, Ordered[0]); 10539 } 10540 } 10541 else 10542 { 10543 CmtMessage::verbose 10544 (CmtError::get_error_name (CmtError::configuration_error) 10545 + ": Unknown special use: " + use->get_info ()); 10546 use->change_path (path); 10547 } 10548 // use->m_located = true; 10549 SyntaxParser::parse_requirements (f, use); 10550 } 10551 else 10552 { 10553 use->discard (); 10554 } 9910 10555 9911 10556 Me.m_recursive = recursive_copy; … … 9922 10567 { 9923 10568 const cmt_string& s = v[i]; 9924 if (s == "") continue;10569 if (s.size () == 0) continue; 9925 10570 9926 10571 if (result.size () != 0) result += separator; 9927 10572 //if (i > 0) result += separator; 9928 result += v[i];10573 result += s; 9929 10574 } 9930 10575 }
Note: See TracChangeset
for help on using the changeset viewer.