Changeset 652 for CMT/HEAD/source/cmt_parser.cxx
- Timestamp:
- Nov 5, 2013, 3:40:52 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
CMT/HEAD/source/cmt_parser.cxx
r649 r652 10 10 #include <string.h> 11 11 #include <ctype.h> 12 #include <errno.h> 12 13 13 14 //---------------------------------------------------------- … … 48 49 { 49 50 clear (); 51 52 cmt_string tags = CmtSystem::getenv ("CMTEXTRATAGS"); 53 CmtSystem::cmt_string_vector words; 54 CmtSystem::split (tags, " \t,", words); 55 for (int i = 0; i < words.size (); i++) 56 { 57 bool has (false); 58 for (int j = 0; j < m_extra_tags.size (); j++) 59 { 60 if (m_extra_tags[j] == words[i]) 61 { 62 has = true; 63 break; 64 } 65 } 66 if (!has) 67 m_extra_tags.push_back (words[i]); 68 } 50 69 } 51 70 … … 59 78 m_build_nmake = false; 60 79 m_cmt_config = ""; 61 //m_cmt_path.clear ();62 //m_cmt_path_pwds.clear ();63 //m_cmt_path_sources.clear ();64 80 m_cmt_root = ""; 81 m_cmt_home = ""; 82 m_cmt_user_context = ""; 83 m_cmt_site = ""; 65 84 m_cmt_version = ""; 66 85 m_use_cmt = true; 86 67 87 m_current_dir = ""; 68 88 m_current_file_path = ""; … … 74 94 m_current_offset = ""; 75 95 76 m_current_access = DeveloperMode; 96 m_current_access = UserMode; 97 m_current_style = cmt_style; 98 m_current_structuring_style = default_structuring_style; 77 99 78 100 m_current_tag = ""; 79 101 m_current_target = ""; 80 102 m_current_version = ""; 103 104 // m_extra_tags = ""; 105 m_extra_tags.clear (); 106 m_tags.clear (); 107 m_tags_add.clear (); 108 m_tags_remove.clear (); 109 110 m_configure_error = ""; 111 112 m_debug = (::getenv ("CMTDEBUG") != 0) ? true : false; 113 81 114 m_default_path = ""; 82 83 //m_quiet = false; 84 115 m_quiet = false; 85 116 m_disable_warnings = false; 86 117 m_warnings = false; … … 91 122 92 123 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 124 m_all_sets_done = false; 125 97 126 m_autoconfigure_cmtpath = false; 98 m_debug = false;99 if (getenv ("CMTDEBUG") != 0) m_debug = true;100 127 } 101 128 … … 497 524 void Cmt::clear () 498 525 { 499 Me.m_quiet = false;500 526 Me.clear (); 527 //Me.m_quiet = false; 501 528 502 529 Database::clear (); … … 515 542 if (configured) return; 516 543 517 Me.clear ();544 // Me.clear (); 518 545 519 546 log << "configure_cmt_message" << log_endl; … … 533 560 log << "configure_site_tag" << log_endl; 534 561 configure_site_tag (0); 562 563 if (Me.m_current_package.size () != 0 && 564 Me.m_current_package != "cmt_standalone") 565 { // we have a package name (not "cmt_standalone") 566 Use& use = Use::current(); 567 use.set (Me.m_current_package, 568 Me.m_current_version, 569 Me.m_current_path); 570 if (CmtSystem::absolute_path (Me.m_current_path)) 571 { 572 if (!use.move_to ()) 573 { 574 CmtError::set (CmtError::package_not_found, use.get_info ()); 575 return; 576 } 577 } 578 else 579 { 580 if (!use.move_to ("", true)) 581 { 582 // will try again later from CMTPATH entries 583 } 584 } 585 } 586 else 587 { 588 if (Me.m_current_path.size () != 0 && 589 !CmtSystem::cd (Me.m_current_path)) 590 { 591 CmtError::set (CmtError::path_not_found, Me.m_current_path); 592 return; 593 } 594 } 595 535 596 log << "configure_current_dir" << log_endl; 536 597 configure_current_dir (); … … 540 601 // log << "configure_current_dir" << log_endl; 541 602 542 543 603 bool save_quiet = Me.m_quiet; 544 604 Me.m_quiet = true; … … 554 614 guess_current_project (); 555 615 616 if (Me.m_current_package.size () != 0 && 617 Me.m_current_package != "cmt_standalone") 618 { 619 Use& use = Use::current(); 620 if (!use.located ()) 621 { 622 if (!use.move_to ()) 623 { 624 CmtError::set (CmtError::package_not_found, use.get_info ()); 625 return; 626 } 627 else 628 { 629 use.get_full_path (Me.m_current_dir); 630 switch (use.style) 631 { 632 case cmt_style: 633 Me.m_current_dir += CmtSystem::file_separator (); 634 Me.m_current_dir += "cmt"; 635 break; 636 case mgr_style: 637 Me.m_current_dir += CmtSystem::file_separator (); 638 Me.m_current_dir += "mgr"; 639 break; 640 default: 641 break; 642 } 643 Me.m_current_file_path = Me.m_current_dir; 644 645 Project::order_all (); 646 Cmt::guess_current_project (); 647 } 648 } 649 } 650 556 651 log << "configure_current_structuring_style" << log_endl; 557 652 // configure_current_structuring_style (); … … 562 657 563 658 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); 659 if (!use.located ()) 660 { 661 use.set (Me.m_current_package, 662 Me.m_current_version, 663 Me.m_current_path); 664 use.style = Me.m_current_style; 665 666 if (use.style != none_style) 667 { 668 use.structuring_style = Me.m_current_structuring_style; 669 use.change_path (Me.m_current_path, Project::get_current ()); 670 } 671 else 672 { 673 use.real_path = Me.m_current_path; 674 } 675 } 676 else if (const Project * p = Project::get_current ()) 677 { 678 use.set_project (p); 679 } 575 680 576 681 if (CmtError::has_pending_error ()) … … 621 726 { 622 727 Use& current_use = Use::current (); 623 728 current_use.get_cmtpath_and_offset (Me.m_current_cmtpath, Me.m_current_offset); 729 /* 624 730 Me.m_current_cmtpath = ""; 625 731 Me.m_current_offset = ""; … … 633 739 634 740 Me.m_current_offset = current_use.path; 635 741 */ 636 742 /** 637 743 try to remove this current CMTPATH entry from path. This … … 639 745 absolute path. 640 746 */ 641 747 /* 642 748 Me.m_current_offset.replace (Me.m_current_cmtpath, empty_string); 643 749 if (Me.m_current_offset[0] == CmtSystem::file_separator ()) … … 648 754 } 649 755 } 756 */ 650 757 } 651 758 … … 788 895 Me.m_current_file_path = mount_filter.get_current_dir (); 789 896 790 cmt_string t = Me.m_current_file_path;897 // cmt_string t = Me.m_current_file_path; 791 898 } 792 899 … … 800 907 standard directory tree (i.e. <package>/<version>/cmt or mgr) 801 908 */ 909 Use& use = Use::current(); 910 if (use.located ()) 911 { 912 Me.m_current_style = use.style; 913 build_prefix (Me.m_current_package, Me.m_current_prefix); 914 build_config (Me.m_current_prefix, Me.m_current_config); 915 return; 916 } 802 917 803 918 cmt_string req = ".."; … … 1062 1177 // Do NOT (re)set m_current_structuring_style yet 1063 1178 // (as requirements may NOT exist, so this is not a package) 1064 // rather do it in reach_current_package (if/when requirements is read)1179 // rather do it in use_current_package (if/when requirements is read) 1065 1180 //Me.m_current_structuring_style = without_version_directory; 1066 1181 build_prefix (Me.m_current_package, Me.m_current_prefix); … … 1074 1189 { 1075 1190 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") 1191 if (Me.m_current_structuring_style == default_structuring_style) 1192 { 1193 s = CmtSystem::getenv ("CMTSTRUCTURINGSTYLE"); 1194 if (s == "without_version_directory") 1092 1195 { 1093 1196 Me.m_current_structuring_style = without_version_directory; 1094 1197 } 1095 else if ( flag == "-with_version_directory")1198 else if (s == "with_version_directory") 1096 1199 { 1097 1200 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'"); 1201 } 1202 1203 CmtSystem::cmt_string_vector flags; 1204 Cmt::get_cmt_flags (flags); 1205 for (int i = 0; i < flags.size (); i++) 1206 { 1207 const cmt_string& flag = flags[i]; 1208 if (flag == "-without_version_directory") 1209 { 1210 Me.m_current_structuring_style = without_version_directory; 1211 } 1212 else if (flag == "-with_version_directory") 1213 { 1214 Me.m_current_structuring_style = with_version_directory; 1215 } 1216 } 1217 } 1218 1219 if (Me.m_current_structuring_style != default_structuring_style) 1220 { 1221 StrategyDef* def = StrategyMgr::find_strategy ("VersionDirectory"); 1222 if (def != 0) 1223 { 1224 def->m_default_value = 1225 Me.m_current_structuring_style == with_version_directory; 1226 def->m_priority_value = 1227 Me.m_current_structuring_style == without_version_directory; 1154 1228 } 1155 1229 } … … 1171 1245 void Cmt::configure_home (Use* use) 1172 1246 { 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"); 1247 if (Me.m_cmt_home.size () == 0) 1248 { 1249 // if not passed on the command line 1250 if (const Symbol* symbol = Symbol::find ("CMTHOME")) 1251 { 1252 Me.m_cmt_home = symbol->build_macro_value (); 1253 Symbol::expand (Me.m_cmt_home); 1254 } 1255 else if (CmtSystem::testenv ("CMTHOME")) 1256 { 1257 Me.m_cmt_home = CmtSystem::getenv ("CMTHOME"); 1258 } 1184 1259 } 1185 1260 … … 1195 1270 void Cmt::configure_user_context (Use* use) 1196 1271 { 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"); 1272 if (Me.m_cmt_user_context.size () == 0) 1273 { 1274 // if not passed on the command line 1275 if (const Symbol* symbol = Symbol::find ("CMTUSERCONTEXT")) 1276 { 1277 Me.m_cmt_user_context = symbol->build_macro_value (); 1278 Symbol::expand (Me.m_cmt_user_context); 1279 } 1280 else if (CmtSystem::testenv ("CMTUSERCONTEXT")) 1281 { 1282 Me.m_cmt_user_context = CmtSystem::getenv ("CMTUSERCONTEXT"); 1283 } 1208 1284 } 1209 1285 … … 1272 1348 1273 1349 Cmt::configure_tags (use); 1350 1351 cmt_string s, t; 1352 if (0 < Me.m_extra_tags.size ()) 1353 { 1354 s = "CMTEXTRATAGS"; 1355 t = use != 0 ? use->get_package_name () : s; 1356 } 1357 for (int i = 0; i < Me.m_extra_tags.size (); i++) 1358 { 1359 Tag* tag = Tag::add (Me.m_extra_tags[i], PriorityUserTag, s, use); 1360 tag->mark (t); 1361 } 1362 1363 for (int i = 0; i < Me.m_tags.size (); i++) 1364 { 1365 const cmt_string& a = Me.m_tags[i]; 1366 if (i == 0) 1367 { 1368 Me.m_current_tag = a; 1369 } 1370 // // Then restore uname if the specified tag is CMTCONFIG 1371 // if (a == CmtSystem::get_cmt_config ()) 1372 // { 1373 // Cmt::configure_uname_tag (); 1374 // } 1375 Tag* tag = Tag::add (a, PriorityArgument, "arguments", 0); 1376 tag->mark ("arguments"); 1377 } 1378 1379 for (int i = 0; i < Me.m_tags_add.size (); i++) 1380 { 1381 const cmt_string& a = Me.m_tags_add[i]; 1382 // // Then restore uname if the specified tag is CMTCONFIG 1383 // if (a == CmtSystem::get_cmt_config ()) 1384 // { 1385 // Cmt::configure_uname_tag (); 1386 // } 1387 Tag* tag = Tag::add (a, PriorityUserTag, "arguments", 0); 1388 tag->mark ("arguments"); 1389 } 1274 1390 1275 1391 /* … … 1277 1393 */ 1278 1394 1395 /* 1279 1396 if (CmtSystem::testenv ("CMTEXTRATAGS")) 1280 1397 { … … 1309 1426 } 1310 1427 } 1428 */ 1311 1429 } 1312 1430 … … 1319 1437 1320 1438 log << "current_tag=" << Me.m_current_tag << log_endl; 1439 1440 cmt_string s = "CMTCONFIG"; 1321 1441 1322 1442 Symbol* symbol = Symbol::find ("CMTCONFIG"); … … 1347 1467 { 1348 1468 config_tag = CmtSystem::getenv ("CMTBIN"); 1469 s = "CMTBIN"; 1349 1470 } 1350 1471 … … 1352 1473 { 1353 1474 CmtSystem::get_uname (config_tag); 1475 s = "uname"; 1354 1476 } 1355 1477 1356 1478 log << "current_tag=" << Me.m_current_tag << log_endl; 1357 1479 1358 cmt_string s = "CMTCONFIG";1480 // cmt_string s = "CMTCONFIG"; 1359 1481 cmt_string t = s; 1360 1482 … … 1552 1674 if (CmtMessage::level () != Warning) 1553 1675 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 1676 } 1622 1677 } … … 1668 1723 1669 1724 CmtSystem::cmt_string_vector uses; 1725 cmt_vector<int> use_indexes; 1670 1726 CmtSystem::cmt_string_vector packages; 1671 1727 CmtSystem::cmt_string_vector versions; 1672 CmtSystem::cmt_string_vector path_selections; 1728 Project::ConstProjectPtrVector path_selections; 1729 // CmtSystem::cmt_string_vector path_selections; 1730 Project::ConstProjectPtrVector path_exclusions; 1673 1731 CmtSystem::cmt_string_vector selections; 1674 1732 CmtSystem::cmt_string_vector exclusions; … … 1677 1735 bool is_cmt = false; 1678 1736 int first = 0; 1679 int i;1680 1737 bool ignore_errors = false; 1681 1738 bool all_packages = false; 1682 1739 int depth (1); 1683 1740 bool local = true; 1684 1685 for (i = 0; i < ap.arguments.size (); i++) 1741 bool global (false); 1742 1743 for (int i = 0; i < ap.arguments.size (); i++) 1686 1744 { 1687 1745 const cmt_string& w = ap.arguments[i]; … … 1699 1757 { 1700 1758 local = false; 1759 global = false; 1701 1760 1702 1761 cmt_string depth_str; 1703 int depth_value = 0;1762 int depth_value; 1704 1763 1705 1764 w.substr (7, depth_str); 1706 if ((sscanf (depth_str.c_str (), "%d", &depth_value) < 1) || 1707 (depth_value < 1)) 1708 { 1765 int n = sscanf (depth_str.c_str (), "%d", &depth_value); 1766 cmt_string msg; 1767 switch (n) 1768 { 1769 case EOF: 1770 msg = "Cannot read `depth' value `"; 1771 msg += depth_str; 1772 msg += cmt_string ("'"); 1773 if (errno) 1774 msg += cmt_string (strerror (errno)); 1775 CmtError::set (CmtError::system_error, msg); 1776 return; 1777 break; 1778 case 0: 1779 msg = "Invalid `depth' value `"; 1780 msg += depth_str; 1781 msg += cmt_string ("'"); 1782 CmtError::set (CmtError::syntax_error, msg); 1783 return; 1784 break; 1785 case 1: 1786 if (depth_value < -1) 1787 { 1788 char num[32]; sprintf (num, "%lu", -depth_value); 1789 msg = "Invalid `depth' value `-"; 1790 msg += num; 1791 msg += cmt_string ("'"); 1792 CmtError::set (CmtError::syntax_error, msg); 1793 return; 1794 } 1795 depth = depth_value; 1796 //cerr << "depth: " << depth << endl; 1797 break; 1798 default: 1799 break; 1800 } 1801 // if ((sscanf (depth_str.c_str (), "%d", &depth_value) < 1) || 1802 // (depth_value < 1)) 1803 // { 1709 1804 // Syntax error 1710 1805 // We shall restrict to packages found within … … 1712 1807 // If CMTPATH is empty, nothing is selected. 1713 1808 // depth=1 is equivalent to local 1714 }1715 1716 Project::fill_selection (depth_value, path_selections);1809 // } 1810 1811 // Project::fill_selection (depth_value, path_selections); 1717 1812 } 1718 1813 else if (w.substr (0, 9) == "-exclude=") … … 1738 1833 else if (w.substr (0, 7) == "-global") 1739 1834 { 1740 path_selections.clear ();1741 1835 //path_selections.clear (); 1836 global = true; 1742 1837 local = false; 1743 1838 } … … 1745 1840 { 1746 1841 local = true; 1842 global = false; 1747 1843 } 1748 1844 else if (w.substr (0, 8) == "-select=") … … 1787 1883 } 1788 1884 1789 if (local) 1790 { 1791 Project::fill_selection (1, path_selections); 1885 const Project* p_cur (Project::get_current ()); 1886 if (global) 1887 { 1888 Project::fill_exclusion (path_exclusions); 1889 } 1890 else if (local) 1891 { 1892 if (p_cur) 1893 Project::fill_selection (1, path_selections); 1894 else 1895 path_selections.push_back (0); // means that we want Use::current () 1896 // path_selections.push_back ((Use::current ()).get_realpath ()); 1897 } 1898 else 1899 { 1900 if (!p_cur 1901 && depth != 0 1902 && depth != -1) 1903 path_selections.push_back (0); // means that we want Use::current () 1904 // path_selections.push_back ((Use::current ()).get_realpath ()); 1905 Project::fill_selection (depth, path_selections); 1906 /* 1907 cerr << "depth: " << depth << endl; 1908 for (int j = 0; j < path_selections.size (); j++) 1909 { 1910 const Project* sp = path_selections[j]; 1911 cerr << "path_selections: " << (sp ? sp->get_cmtpath () : "current use") << endl; 1912 } 1913 */ 1792 1914 } 1793 1915 … … 1800 1922 //if (command.substr (0, 3) == "cmt") is_cmt = true; 1801 1923 1802 cmt_string curuse = CmtSystem::pwd ();1924 //cmt_string curuse = CmtSystem::pwd (); 1803 1925 if (all_packages) 1804 1926 { … … 1806 1928 PathScanner scanner; 1807 1929 Project::scan_paths (scanner, selector); 1930 return; 1808 1931 } 1809 1932 else 1810 1933 { 1811 for (i = Uses.size () - 1; i >= 0; i--)1934 for (int i = Uses.size () - 1; i >= 0; i--) 1812 1935 { 1813 1936 Use* use = Uses[i]; … … 1815 1938 if (use->discarded) continue; 1816 1939 if (use->m_hidden) continue; 1817 1818 1940 if (!use->located ()) 1819 1941 { 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 */ 1942 CmtMessage::warning 1943 (CmtError::get_error_name (CmtError::package_not_found) 1944 + ": " + use->get_info ()); 1945 continue; 1832 1946 } 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 } 1947 if (use->get_package_name () == "CMT") continue; 1948 1949 cmt_string& s = uses.add (); 1950 use->get_full_path (s); 1951 switch (use->style) 1952 { 1953 case cmt_style: 1954 s += CmtSystem::file_separator (); 1955 s += "cmt"; 1956 break; 1957 case mgr_style: 1958 s += CmtSystem::file_separator (); 1959 s += "mgr"; 1960 break; 1961 default: 1962 break; 1963 } 1964 // if (use->style == mgr_style) s += "mgr"; 1965 // else s += "cmt"; 1966 1967 cmt_string& v = versions.add (); 1968 v = use->version; 1969 1970 cmt_string& p = packages.add (); 1971 p = use->get_package_name (); 1972 1973 int& use_index = use_indexes.add (); 1974 use_index = i; 1975 } 1853 1976 1854 1977 { 1978 Use* use = &(Use::current ()); 1979 1855 1980 cmt_string& s = uses.add (); 1981 use->get_full_path (s); 1982 switch (use->style) 1983 { 1984 case cmt_style: 1985 s += CmtSystem::file_separator (); 1986 s += "cmt"; 1987 break; 1988 case mgr_style: 1989 s += CmtSystem::file_separator (); 1990 s += "mgr"; 1991 break; 1992 default: 1993 break; 1994 } 1995 // if (use->get_package_name ().find ("cmt_standalone") != cmt_string::npos) 1996 // { 1997 // s = CmtSystem::pwd (); 1998 // } 1999 // else 2000 // { 2001 // use->get_full_path (s); 2002 2003 // s += CmtSystem::file_separator (); 1856 2004 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; 2005 // if (use->style == mgr_style) s += "mgr"; 2006 // else s += "cmt"; 2007 // } 2008 //curuse = s; 1874 2009 1875 2010 cmt_string& v = versions.add (); … … 1878 2013 cmt_string& p = packages.add (); 1879 2014 p = use->get_package_name (); 2015 2016 int& use_index = use_indexes.add (); 2017 use_index = -1; 1880 2018 } 1881 2019 } … … 1891 2029 CmtSystem::putenv ("CMTBCAST", ""); 1892 2030 1893 for (i = 0; i < uses.size (); i++)2031 for (int i = 0; i < uses.size (); i++) 1894 2032 { 1895 2033 const cmt_string& s = uses[i]; 1896 2034 const cmt_string& v = versions[i]; 1897 2035 const cmt_string& p = packages[i]; 2036 const int use_index = use_indexes[i]; 2037 2038 const Use* use = use_index >= 0 ? Uses[use_index] : &(Use::current ()); 2039 const Project* up = use->get_project (); 2040 1898 2041 cmt_string cmtpath; 1899 2042 1900 2043 bool ok = true; 1901 bool selected = true;2044 bool selected = global ? true : false; 1902 2045 bool excluded = false; 1903 2046 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) 2047 ok = selected; 2048 if (path_selections.size () > 0) 1910 2049 { 1911 2050 selected = false; 1912 1913 2051 for (int j = 0; j < path_selections.size (); j++) 1914 2052 { 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 2053 const Project* sp = path_selections[j]; 2054 if (sp) 2055 { 2056 if (up) 2057 { 2058 if (up == sp) 2059 { 2060 cmtpath = sp->get_cmtpath (); 2061 selected = true; 2062 break; 2063 } 2064 } 2065 else 2066 { 2067 if (use->get_realpath ().find (sp->get_cmtpath_real ()) == 0) 2068 { 2069 cmtpath = sp->get_cmtpath (); 2070 selected = true; 2071 break; 2072 } 2073 } 2074 } 2075 else if (use == &(Use::current ())) 2076 { 2077 // means that we want Use::current () 2078 // cmtpath = sp->get_cmtpath (); 2079 if (up) 2080 cmtpath = up->get_cmtpath (); 2081 else 2082 cmtpath = ""; 2083 selected = true; 2084 break; 2085 } 2086 // const cmt_string& sel = path_selections[j]; 2087 // if (s.find (sel) != cmt_string::npos) 2088 // { 2089 // cmtpath = sel; 2090 // selected = true; 2091 // break; 2092 // } 2093 } 1925 2094 ok = selected; 1926 2095 } … … 1960 2129 } 1961 2130 1962 1963 2131 if (ok) 1964 2132 { … … 1974 2142 break; 1975 2143 } 2144 } 2145 2146 if (excluded) ok = false; 2147 } 2148 2149 if (ok) 2150 { 2151 excluded = false; 2152 for (int j = 0; j < path_exclusions.size (); j++) 2153 { 2154 const Project* sp = path_exclusions[j]; 2155 if (up) 2156 { 2157 if (up == sp) 2158 { 2159 excluded = true; 2160 break; 2161 } 2162 } 2163 else 2164 { 2165 if (use->get_realpath ().find (sp->get_cmtpath_real ()) == 0) 2166 { 2167 excluded = true; 2168 break; 2169 } 2170 } 1976 2171 } 1977 2172 … … 2021 2216 } 2022 2217 2218 /* 2023 2219 if (cmtpath == "") 2024 2220 { … … 2026 2222 cmtpath = Project::find_in_cmt_paths (sel); 2027 2223 } 2224 */ 2028 2225 2029 2226 cmt_string cmd = command; … … 2041 2238 static const cmt_string empty_string; 2042 2239 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 { 2240 cmt_string offset; 2241 if (cmtpath.size ()) 2242 { 2243 offset = s; 2244 offset.replace (cmtpath, empty_string); 2245 if (offset[0] == CmtSystem::file_separator ()) 2246 { 2247 offset.replace (fs, empty_string); 2248 } 2055 2249 CmtSystem::dirname (offset, offset); 2250 2251 cmt_string n; 2252 CmtSystem::basename (offset, n); 2253 if (n == p) 2254 { 2255 CmtSystem::dirname (offset, offset); 2256 } 2257 else 2258 { 2259 CmtSystem::dirname (offset, offset); 2260 CmtSystem::dirname (offset, offset); 2261 } 2056 2262 } 2057 2263 else 2058 2264 { 2059 CmtSystem::dirname (offset, offset); 2060 CmtSystem::dirname (offset, offset); 2061 } 2062 2265 offset = use->real_path; 2266 } 2063 2267 cmd.replace_all (offset_template, offset); 2064 2268 … … 2904 3108 } 2905 3109 2906 static CmtSystem::cmt_string_vector tags;3110 // static CmtSystem::cmt_string_vector tags; 2907 3111 2908 3112 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; 3113 { 3114 // CmtSystem::split (Me.m_extra_tags, " \t,", tags); 3115 3116 // for (int i = 0; i < tags.size (); i++) 3117 // { 3118 // const cmt_string& t = tags[i]; 3119 for (int i = 0; i < Me.m_extra_tags.size (); i++) 3120 { 3121 const cmt_string& t = Me.m_extra_tags[i]; 3122 tag = Tag::find (t); 3123 if (tag == 0) continue; 3124 if (!Tag::check_tag_used (tag) && !Symbol::check_tag_used (tag)) 3125 { 3126 CmtMessage::warning ("The tag " + t + " is not used in any tag expression. Please check spelling"); 3127 } 3128 } 3129 for (int i = 0; i < Me.m_tags.size (); i++) 3130 { 3131 const cmt_string& t = Me.m_tags[i]; 3132 tag = Tag::find (t); 3133 if (tag == 0) continue; 3134 if (!Tag::check_tag_used (tag) && !Symbol::check_tag_used (tag)) 3135 { 3136 CmtMessage::warning ("The tag " + t + " is not used in any tag expression. Please check spelling"); 3137 } 3138 } 3139 for (int i = 0; i < Me.m_tags_add.size (); i++) 3140 { 3141 const cmt_string& t = Me.m_tags_add[i]; 3142 tag = Tag::find (t); 3143 if (tag == 0) continue; 3144 if (!Tag::check_tag_used (tag) && !Symbol::check_tag_used (tag)) 3145 { 3146 CmtMessage::warning ("The tag " + t + " is not used in any tag expression. Please check spelling"); 3147 } 2922 3148 } 2923 3149 } … … 2940 3166 { 2941 3167 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 3168 } 2944 3169 … … 4476 4701 4477 4702 Use& use = Use::current(); 4703 /* 4478 4704 use.get_cmtpath_and_offset (cmtpath, offset); 4479 4705 4480 4706 Project* p = Project::find_by_cmtpath (cmtpath); 4481 4482 cout << p->get_author () << endl; 4707 */ 4708 if (const Project* p = use.get_project ()) 4709 cout << p->get_author () << endl; 4483 4710 } 4484 4711 … … 4503 4730 ClientCollector collector (package, version); 4504 4731 4732 /* 4505 4733 clear (); 4506 4734 // configure (); 4507 4735 configure (ap); 4736 */ 4508 4737 4509 4738 cout << "# ----------- Clients of " << package … … 5425 5654 log << "guess_current_project" << log_endl; 5426 5655 5427 cmt_string here = CmtSystem::pwd ();5656 // cmt_string here = CmtSystem::pwd (); 5428 5657 5429 5658 Use& use = Use::current(); … … 5438 5667 // if (Project::find_in_cmt_paths (Me.m_current_dir) == "") 5439 5668 { 5669 /* 5440 5670 if (!CmtSystem::cd (current_path)) 5441 5671 { … … 5444 5674 return; 5445 5675 } 5676 */ 5446 5677 cmt_string project_file = "cmt"; 5447 5678 project_file += CmtSystem::file_separator (); 5448 5679 project_file += Project::get_project_file_name (); 5449 5680 5450 cmt_string pwd; 5681 /* 5682 cmt_string pwd (CmtSystem::pwd ()); 5683 cmt_string pwd_prev; 5684 */ 5685 cmt_string dir_cur (current_path); 5686 cmt_string dir_par; 5687 5688 cmt_string proj_file_cur; 5451 5689 5452 5690 for (;;) 5453 5691 { 5454 pwd = CmtSystem::pwd (); 5692 /* 5693 // pwd = CmtSystem::pwd (); 5455 5694 if (CmtSystem::test_file (project_file)) 5456 5695 { … … 5462 5701 break; 5463 5702 } 5464 5465 log << "pwd=" << CmtSystem::pwd () << log_endl; 5703 */ 5704 proj_file_cur = dir_cur; 5705 proj_file_cur += CmtSystem::file_separator (); 5706 proj_file_cur += project_file; 5707 if (CmtSystem::test_file (proj_file_cur)) 5708 { 5709 //this directory should become the first entry of the CMTPATH 5710 5711 IProjectFactory& factory = ProjectFactory::instance (); 5712 factory.create_project ("", dir_cur, "CurrentProject", 0); 5713 5714 break; 5715 } 5716 5717 /* 5718 log << "pwd=" << pwd << log_endl; 5466 5719 5467 5720 if (!CmtSystem::cd ("..")) … … 5471 5724 } 5472 5725 5473 if (CmtSystem::pwd () == pwd) 5726 pwd_prev = pwd; 5727 pwd = CmtSystem::pwd (); 5728 if (pwd == pwd_prev) 5729 // if (CmtSystem::pwd () == pwd) 5474 5730 { 5475 5731 log << "Looks the same pwd..." << log_endl; 5476 5732 break; 5477 5733 } 5478 } 5479 5480 CmtSystem::cd (Me.m_current_dir); 5481 } 5734 */ 5735 log << "dir_cur=`" << dir_cur << "'" << log_endl; 5736 CmtSystem::dirname (dir_cur, dir_par); 5737 if (dir_par == dir_cur) 5738 { 5739 log << "Looks the same dir_cur..." << log_endl; 5740 break; 5741 } 5742 dir_cur = dir_par; 5743 } 5744 5745 // CmtSystem::cd (Me.m_current_dir); 5746 } // if (Project::find_in_cmt_paths (current_path) == "") 5482 5747 5483 5748 //cmt_string buffer = "path CMTPATH \n"; … … 5496 5761 Me.m_autoconfigure_cmtpath = true; 5497 5762 5498 CmtSystem::cd (here); 5763 // CmtSystem::cd (Me.m_current_dir); 5764 //CmtSystem::cd (here); 5499 5765 } 5500 5766 … … 6409 6675 6410 6676 /** 6411 * See reach_current_packagefor an explanation of this call6677 * See apply_globals for an explanation of this call 6412 6678 */ 6413 6679 Pattern::apply_all_globals (); … … 6444 6710 Me.m_action = action_none; 6445 6711 6446 restore_all_tags (0);6712 // restore_all_tags (0); 6447 6713 6448 6714 #ifdef WIN32 … … 6498 6764 clear (); 6499 6765 6766 // Me.clear (); 6767 6768 parse_arguments (ap); 6769 6500 6770 // configure (); 6501 configure (ap); 6502 6503 CmtError::clear (); 6771 switch (Me.m_action) 6772 { 6773 case action_none : 6774 case action_build_temporary_name : 6775 case action_help : 6776 break; 6777 default: 6778 configure (ap); 6779 restore_all_tags (0); 6780 break; 6781 } 6782 6783 // CmtError::clear (); 6504 6784 6505 6785 /* 6506 Set private if positioned inside the package6786 Set DeveloperMode if positioned inside the package 6507 6787 (which is detected since we were able to retreive the 6508 6788 Version, Package and Path) 6509 6789 */ 6510 6790 6791 if (!Use::current().located ()) 6792 /* 6511 6793 if ((Me.m_current_path.size () == 0) || 6512 6794 (Me.m_current_package.size () == 0) || 6513 6795 (Me.m_current_version.size () == 0)) 6796 */ 6514 6797 { 6515 6798 Me.m_current_access = UserMode; … … 6520 6803 } 6521 6804 6522 parse_arguments (ap);6805 // parse_arguments (ap); 6523 6806 6524 6807 if (ap.help_action == action_help) … … 6929 7212 Me.m_warnings = false; 6930 7213 if (strlen (ap.extra_file.c_str ()) == 0) 6931 reach_current_package (); 7214 use_current_package (); 7215 // reach_current_package (); 6932 7216 else 6933 7217 use_extra_file (ap.extra_file); … … 6935 7219 if (strlen (ap.extra_line.c_str ()) > 0) 6936 7220 SyntaxParser::parse_requirements_text (ap.extra_line, "extra statement(s)", (Use*) 0); 7221 apply_globals (); 6937 7222 Me.m_warnings = w; 6938 //if (strlen (ap.extra_line.c_str ()) > 0) SyntaxParser::parse_requirements_line (ap.extra_line, &(Use::current ()));6939 7223 } 6940 7224 break; … … 6952 7236 if (use != 0 && !use->discarded && !use->m_hidden && use->located ()) 6953 7237 uses.push_back (use); 6954 uses.push_back (&(Use::current())); 7238 use = &(Use::current()); 7239 if (use != 0 && !use->discarded && !use->m_hidden && use->located ()) 7240 uses.push_back (use); 7241 // uses.push_back (&(Use::current())); 6955 7242 use = Use::find (CmtSystem::get_user_context_package ()); 6956 7243 if (use != 0 && !use->discarded && !use->m_hidden && use->located ()) … … 7452 7739 // 7453 7740 7741 /* 7454 7742 { 7455 7743 CmtSystem::cmt_string_vector words; … … 7477 7765 } 7478 7766 } 7479 7767 */ 7480 7768 if (mode == Requirements) 7481 7769 { … … 7939 8227 7940 8228 //---------------------------------------------------------- 7941 int Cmt:: reach_current_package ()8229 int Cmt::use_current_package () 7942 8230 { 7943 8231 Use& use = Use::current (); … … 7946 8234 if (Me.m_debug) 7947 8235 { 7948 cout << "Cmt:: reach_current_package> pwd = "8236 cout << "Cmt::use_current_package> pwd = " 7949 8237 << CmtSystem::pwd () 7950 8238 << " path=" << Me.m_current_path … … 7959 8247 if (Me.m_current_package == "cmt_standalone") 7960 8248 { 7961 if ((Me.m_current_path != "") && (Me.m_current_path != CmtSystem::pwd ())) 8249 if ((Me.m_current_path != "") && (Me.m_current_path != Me.m_current_dir)) 8250 // if ((Me.m_current_path != "") && (Me.m_current_path != CmtSystem::pwd ())) 7962 8251 { 7963 8252 if (!CmtSystem::cd (Me.m_current_path)) 7964 8253 { 7965 8254 CmtError::set (CmtError::package_not_found, 7966 "ReachCurrentPackage> Cannot reach the path directory"); 8255 "Cannot reach the path directory: " 8256 + Me.m_current_path); 7967 8257 return (0); 7968 8258 } … … 7975 8265 7976 8266 Me.m_current_structuring_style = without_version_directory; 8267 use.structuring_style = Me.m_current_structuring_style; 8268 use.change_path (Me.m_current_path, Project::get_current ()); 8269 Me.m_current_access = DeveloperMode; 7977 8270 } 7978 8271 else if (Me.m_current_package != "") 7979 8272 { 7980 if (!use.move_to () && !use.move_to ("", true)) 7981 // if (!use.move_to ()) 7982 { 7983 CmtError::set (CmtError::package_not_found, use.get_info ()); 7984 // CmtError::set (CmtError::package_not_found, 7985 // "ReachCurrentPackage> Cannot reach the path directory"); 7986 return (0); 7987 } 7988 7989 Me.m_current_path = use.real_path; 8273 if (!use.located ()) 8274 { 8275 // if (!use.move_to () && !use.move_to ("", true)) 8276 // if (!use.move_to ()) 8277 if (!use.move_to ()) 8278 { 8279 if (!CmtSystem::cd (Cmt::get_current_dir ())) 8280 { 8281 CmtError::set (CmtError::file_access_error, 8282 Cmt::get_current_dir () 8283 + " (use_current_package)"); 8284 return 0; 8285 } 8286 if (!use.move_to ("", true)) 8287 { 8288 CmtError::set (CmtError::package_not_found, use.get_info ()); 8289 return 0; 8290 } 8291 } 8292 8293 Me.m_current_path = use.real_path; 8294 Me.m_current_access = DeveloperMode; 8295 } 7990 8296 } 7991 8297 else … … 8025 8331 8026 8332 CmtError::set (CmtError::package_not_found, 8027 "ReachCurrentPackage> Cannot reach the mgr/cmt directory"); 8333 "Cannot reach the mgr/cmt directory: " 8334 + use.get_info ()); 8028 8335 return (0); 8029 8336 } … … 8031 8338 else 8032 8339 Me.m_current_style = none_style; 8340 8341 Me.m_current_access = DeveloperMode; 8033 8342 8034 8343 dir = CmtSystem::pwd (); … … 8058 8367 use.style = Me.m_current_style; 8059 8368 use.structuring_style = Me.m_current_structuring_style; 8060 } 8061 8369 8370 configure_current_dir (); 8371 build_prefix (Me.m_current_package, Me.m_current_prefix); 8372 build_config (Me.m_current_prefix, Me.m_current_config); 8373 } 8374 8375 /* 8062 8376 configure_current_dir (); 8063 8377 build_prefix (Me.m_current_package, Me.m_current_prefix); 8064 8378 build_config (Me.m_current_prefix, Me.m_current_config); 8379 */ 8065 8380 8066 8381 /* … … 8068 8383 */ 8069 8384 8070 if (Me.m_debug) cout << " reach_current_package0> current_tag=" << Me.m_current_tag << endl;8385 if (Me.m_debug) cout << "use_current_package0> current_tag=" << Me.m_current_tag << endl; 8071 8386 8072 8387 if (Me.m_current_tag == "") … … 8079 8394 Tag* tag; 8080 8395 8081 tag = Tag::add (env, PriorityConfig, " reachcurrent package", 0);8396 tag = Tag::add (env, PriorityConfig, "current package", 0); 8082 8397 tag->mark (use.get_package_name ()); 8083 8398 //Me.m_current_tag = env; 8084 8399 8085 //if (!Me.m_quiet) cerr << " reach_current_package1> current_tag=" << Me.m_current_tag << endl;8400 //if (!Me.m_quiet) cerr << "use_current_package1> current_tag=" << Me.m_current_tag << endl; 8086 8401 8087 8402 } … … 8101 8416 SyntaxParser::parse_requirements (dir, &use); 8102 8417 8103 if (Me.m_debug) cout << "reach_current_package2> current_tag=" << Me.m_current_tag << endl; 8418 if (CmtError::has_pending_error ()) return 0; 8419 8420 if (Me.m_debug) cout << "use_current_package2> current_tag=" << Me.m_current_tag << endl; 8421 8422 return 1; 8423 } 8424 8425 //---------------------------------------------------------- 8426 int Cmt::use_extra_file (const cmt_string& file) 8427 { 8428 if (!CmtSystem::test_file (file)) 8429 { 8430 CmtError::set (CmtError::path_not_found, file); 8431 return 0; 8432 } 8433 8434 // (almost) Cmt::use_current_package () 8435 Use& use = Use::current (); 8436 /* 8437 Try to access the package. 8438 */ 8439 8440 if (Me.m_current_package == "cmt_standalone") 8441 { 8442 if ((Me.m_current_path != "") && (Me.m_current_path != Me.m_current_dir)) 8443 // if ((Me.m_current_path != "") && (Me.m_current_path != CmtSystem::pwd ())) 8444 { 8445 if (!CmtSystem::cd (Me.m_current_path)) 8446 { 8447 CmtError::set (CmtError::package_not_found, 8448 "Cannot reach the path directory: " 8449 + Me.m_current_path); 8450 return (0); 8451 } 8452 } 8453 /* 8454 if (!CmtSystem::test_file ("requirements")) 8455 { 8456 return (0); 8457 } 8458 */ 8459 Me.m_current_structuring_style = without_version_directory; 8460 use.structuring_style = Me.m_current_structuring_style; 8461 use.change_path (Me.m_current_path, Project::get_current ()); 8462 Me.m_current_access = DeveloperMode; 8463 } 8464 else if (Me.m_current_package != "") 8465 { 8466 if (!use.located ()) 8467 { 8468 // if (!use.move_to () && !use.move_to ("", true)) 8469 // if (!use.move_to ()) 8470 if (!use.move_to ()) 8471 { 8472 if (!CmtSystem::cd (Cmt::get_current_dir ())) 8473 { 8474 CmtError::set (CmtError::file_access_error, 8475 Cmt::get_current_dir () 8476 + " (use_extra_file)"); 8477 return 0; 8478 } 8479 if (!use.move_to ("", true)) 8480 { 8481 CmtError::set (CmtError::package_not_found, use.get_info ()); 8482 return 0; 8483 } 8484 } 8485 8486 Me.m_current_path = use.real_path; 8487 Me.m_current_access = DeveloperMode; 8488 } 8489 } 8490 else 8491 { 8492 // 8493 // The cmt command has been given without explicit search for 8494 // a package. Thus it is expected that we are in the context of a 8495 // true package. 8496 // 8497 // This means that there should be a requirements file visible. 8498 // 8499 // If this is not true, we'll make a try into ../cmt and then 8500 // a last try into ../mgr 8501 // 8502 8503 Me.m_current_access = DeveloperMode; 8504 //... 8505 configure_current_dir (); 8506 build_prefix (Me.m_current_package, Me.m_current_prefix); 8507 build_config (Me.m_current_prefix, Me.m_current_config); 8508 } 8509 8510 /* 8511 configure_current_dir (); 8512 build_prefix (Me.m_current_package, Me.m_current_prefix); 8513 build_config (Me.m_current_prefix, Me.m_current_config); 8514 */ 8515 8516 /* 8517 Check Tag is always set up 8518 */ 8519 8520 if (Me.m_debug) cout << "use_extra_file0> current_tag=" << Me.m_current_tag << endl; 8521 8522 if (Me.m_current_tag == "") 8523 { 8524 cmt_string env; 8525 8526 env = CmtSystem::getenv (Me.m_current_config); 8527 if (env != "") 8528 { 8529 Tag* tag; 8530 8531 tag = Tag::add (env, PriorityConfig, "current package", 0); 8532 tag->mark (use.get_package_name ()); 8533 //Me.m_current_tag = env; 8534 8535 //if (!Me.m_quiet) cerr << "use_extra_file1> current_tag=" << Me.m_current_tag << endl; 8536 8537 } 8538 } 8539 8540 if (Me.m_debug) 8541 { 8542 cout << "pwd = " << CmtSystem::pwd () << endl; 8543 } 8544 8545 /* 8546 Work on the requirements file. 8547 */ 8548 8549 SyntaxParser::parse_requirements (file, &use); 8550 8551 if (CmtError::has_pending_error ()) return 0; 8552 8553 if (Me.m_debug) cout << "use_extra_file2> current_tag=" << Me.m_current_tag << endl; 8554 return 1; 8555 } 8556 8557 //---------------------------------------------------------- 8558 int Cmt::apply_globals () 8559 { 8104 8560 8105 8561 /** … … 8132 8588 Tag::restore_tree (); 8133 8589 8134 return (1); 8135 } 8136 8137 //---------------------------------------------------------- 8138 int Cmt::use_extra_file (const cmt_string& file) 8139 { 8140 if (!CmtSystem::test_file (file)) 8141 { 8142 CmtError::set (CmtError::path_not_found, file); 8143 return 0; 8144 } 8145 8146 // (almost) Cmt::reach_current_package () 8147 Use& use = Use::current (); 8148 /* 8149 Try to access the package. 8150 */ 8151 8152 if (Me.m_current_package == "cmt_standalone") 8153 { 8154 if ((Me.m_current_path != "") && (Me.m_current_path != CmtSystem::pwd ())) 8155 { 8156 if (!CmtSystem::cd (Me.m_current_path)) 8157 { 8158 CmtError::set (CmtError::package_not_found, 8159 "ReachCurrentPackage> Cannot reach the path directory"); 8160 return (0); 8161 } 8162 } 8163 /* 8164 if (!CmtSystem::test_file ("requirements")) 8165 { 8166 return (0); 8167 } 8168 */ 8169 Me.m_current_structuring_style = without_version_directory; 8170 } 8171 else if (Me.m_current_package != "") 8172 { 8173 if (!use.move_to () && !use.move_to ("", true)) 8174 // if (!use.move_to ()) 8175 { 8176 CmtError::set (CmtError::package_not_found, use.get_info ()); 8177 // CmtError::set (CmtError::package_not_found, 8178 // "ReachCurrentPackage> Cannot reach the path directory"); 8179 // return -1; 8180 return (0); 8181 } 8182 8183 Me.m_current_path = use.real_path; 8184 } 8185 else 8186 { 8187 // 8188 // The cmt command has been given without explicit search for 8189 // a package. Thus it is expected that we are in the context of a 8190 // true package. 8191 // 8192 // This means that there should be a requirements file visible. 8193 // 8194 // If this is not true, we'll make a try into ../cmt and then 8195 // a last try into ../mgr 8196 // 8197 8198 //... 8199 } 8200 8201 configure_current_dir (); 8202 build_prefix (Me.m_current_package, Me.m_current_prefix); 8203 build_config (Me.m_current_prefix, Me.m_current_config); 8204 8205 /* 8206 Check Tag is always set up 8207 */ 8208 8209 if (Me.m_debug) cout << "use_extra_file0> current_tag=" << Me.m_current_tag << endl; 8210 8211 if (Me.m_current_tag == "") 8212 { 8213 cmt_string env; 8214 8215 env = CmtSystem::getenv (Me.m_current_config); 8216 if (env != "") 8217 { 8218 Tag* tag; 8219 8220 tag = Tag::add (env, PriorityConfig, "reach current package", 0); 8221 tag->mark (use.get_package_name ()); 8222 //Me.m_current_tag = env; 8223 8224 //if (!Me.m_quiet) cerr << "use_extra_file1> current_tag=" << Me.m_current_tag << endl; 8225 8226 } 8227 } 8228 8229 if (Me.m_debug) 8230 { 8231 cout << "pwd = " << CmtSystem::pwd () << endl; 8232 } 8233 8234 /* 8235 Work on the requirements file. 8236 */ 8237 8238 SyntaxParser::parse_requirements (file, &use); 8239 8240 if (Me.m_debug) cout << "use_extra_file2> current_tag=" << Me.m_current_tag << endl; 8241 8242 /** 8243 * It would be useful to change this mechanism. Instead of 8244 * applying all global patterns at once to all use contexts, it 8245 * would be much better to apply it at the end of each 8246 * requirements file parsing, and only in the context the 8247 * appropriate Use. 8248 * 8249 * This would avoid the current flaw which is that when a global 8250 * pattern specifies a "private" definition, it is actually 8251 * applied in the scope context of the Current Use and not in 8252 * each individual Use. Therefore the private is lost. 8253 * 8254 * However, this induces problems since some pattern definitions 8255 * are done AFTER the use statements, which will NOT receive the 8256 * pattern aplications. 8257 * 8258 * Therefore it is decided to leave this "bad" mechanism until 8259 * everybody is aware of this constraint. 8260 * 8261 * 8262 */ 8263 Pattern::apply_all_globals (); 8264 8265 /* 8266 Select all possible tags 8267 */ 8268 8269 Tag::restore_tree (); 8270 8271 return (1); 8590 if (CmtError::has_pending_error ()) return 0; 8591 8592 return 1; 8272 8593 } 8273 8594 … … 9972 10293 if (CmtSystem::test_file (f)) 9973 10294 { 9974 use->m_located = true; 9975 } 9976 SyntaxParser::parse_requirements (f, use); 10295 use->style = none_style; 10296 use->structuring_style = without_version_directory; 10297 10298 if (name == CmtSystem::get_home_package () || 10299 name == CmtSystem::get_user_context_package ()) 10300 { 10301 const Project::ProjectPtrVector& Ordered = Project::ordered_projects (); 10302 if (0 == Ordered.size ()) 10303 { 10304 CmtError::set(CmtError::configuration_error, 10305 "No ordered project: " + use->get_info ()); 10306 return; 10307 } 10308 if (name == CmtSystem::get_home_package ()) 10309 use->change_path (path, Ordered[Ordered.size () - 1]); 10310 else if (name == CmtSystem::get_user_context_package ()) 10311 use->change_path (path, Ordered[0]); 10312 } 10313 else 10314 { 10315 CmtMessage::verbose 10316 (CmtError::get_error_name (CmtError::configuration_error) 10317 + ": Unknown special use: " + use->get_info ()); 10318 use->change_path (path); 10319 } 10320 // use->m_located = true; 10321 SyntaxParser::parse_requirements (f, use); 10322 } 10323 else 10324 { 10325 use->discard (); 10326 } 9977 10327 9978 10328 Me.m_recursive = recursive_copy;
Note: See TracChangeset
for help on using the changeset viewer.