Changeset 531 for CMT/HEAD/source/cmt_use.cxx
- Timestamp:
- Jan 8, 2010, 4:25:58 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
CMT/HEAD/source/cmt_use.cxx
r528 r531 133 133 } CompareStatus; 134 134 135 static CompareStatus compare_versions (const cmt_string& ref_version, const cmt_string& new_version )135 static CompareStatus compare_versions (const cmt_string& ref_version, const cmt_string& new_version, bool match = false) 136 136 { 137 137 CompareStatus result = IdenticalIds; 138 139 if (match) 140 { 141 if (ref_version == "" || 142 ref_version == "*" || 143 ref_version == "v*") 144 return IdenticalIds; 145 146 int wild_card = ref_version.find ('*'); 147 if (wild_card != cmt_string::npos) 148 { 149 cmt_string ref_ver (ref_version.substr (0, wild_card)); 150 if (ref_ver.size () > new_version.size ()) 151 return IncompatibleMajorIds; 152 else if (strncmp (ref_ver.c_str (), new_version.c_str (), wild_card) == 0) 153 return IdenticalIds; 154 else 155 return IncompatibleMajorIds; 156 } 157 else if (ref_version == new_version) 158 return IdenticalIds; 159 else 160 return IncompatibleMajorIds; 161 } 138 162 139 163 int old_v = -1; … … 664 688 665 689 cout << "use::action1> current=" << parent->get_package_name () << 666 " package=" << package << " ";690 " package=" << package << "(" << version << ")" << " "; 667 691 668 692 for (i = 0; i < uses.size (); i++) … … 1436 1460 if (Cmt::get_debug ()) 1437 1461 { 1438 cout << "Use::reach_package> (" << get_package_name () << " "1439 << version << ")from " << from_path << endl;1462 cout << "Use::reach_package> " << get_package_name () 1463 << "(" << version << ") from " << from_path << endl; 1440 1464 cout << "Use::reach_package> native_version required "<<n_version<<endl; 1441 1465 } … … 1536 1560 if (CmtSystem::test_file ("cmt/requirements")) 1537 1561 { 1538 CmtSystem::cd ("cmt");1539 1540 style = no_version_style;1562 // CmtSystem::cd ("cmt"); 1563 1564 // style = no_version_style; 1541 1565 1542 1566 cmt_string v; 1543 if (Package::get_version (v)) 1544 { 1545 CompareStatus s = compare_versions (version, v); 1567 // if (Package::get_version (v)) 1568 if (Package::get_version (v, "cmt")) 1569 { 1570 CompareStatus s = compare_versions (version, v, true); 1546 1571 if (Cmt::get_debug ()) 1547 1572 { … … 1574 1599 version = "v0"; 1575 1600 } 1601 CmtSystem::cd ("cmt"); 1602 style = cmt_style; 1603 structuring_style = without_version_directory; 1576 1604 return (1); 1577 1605 } … … 1582 1610 // There are alternate possibilities when it contains wild cards 1583 1611 // 1584 if ((version == "") || (version.find ("*") != cmt_string::npos)) 1612 // if ((version == "") || (version.find ("*") != cmt_string::npos)) 1613 if (version.find ("*") != cmt_string::npos) 1585 1614 { 1586 1615 static CmtSystem::cmt_string_vector versions; … … 1589 1618 name = "."; 1590 1619 name += CmtSystem::file_separator (); 1620 name += version; 1621 /* 1591 1622 if (version == "") name += "*"; 1592 1623 else name += version; 1624 */ 1593 1625 1594 1626 CmtSystem::scan_dir (name, versions); … … 1691 1723 } 1692 1724 1725 /* 1693 1726 if (!found) 1694 1727 { … … 1700 1733 } 1701 1734 } 1735 */ 1702 1736 } 1703 1737 … … 1733 1767 CmtSystem::cd ("mgr"); 1734 1768 style = mgr_style; 1769 structuring_style = with_version_directory; 1735 1770 } 1736 1771 } … … 1739 1774 CmtSystem::cd ("cmt"); 1740 1775 style = cmt_style; 1776 structuring_style = with_version_directory; 1741 1777 } 1742 1778 … … 2839 2875 else s = real_path; 2840 2876 2841 s += CmtSystem::file_separator (); 2842 s += get_package_name (); 2877 if (style != none_style) 2878 { 2879 s += CmtSystem::file_separator (); 2880 s += get_package_name (); 2881 } 2843 2882 2844 if (style != no_version_style) 2883 // if (style != no_version_style) 2884 if (structuring_style == with_version_directory) 2845 2885 { 2846 2886 s += CmtSystem::file_separator (); … … 3039 3079 buffer += " \""; 3040 3080 buffer += real_path; 3041 buffer += fs; 3042 buffer += package_name; 3043 if (style != no_version_style) 3081 if (style != none_style) 3082 { 3083 buffer += fs; 3084 buffer += package_name; 3085 } 3086 // if (style != no_version_style) 3087 if (structuring_style == with_version_directory) 3044 3088 { 3045 3089 buffer += fs; … … 3169 3213 else 3170 3214 { 3171 s = "../$("; 3172 s += current_use.get_package_name (); 3173 s += "_tag)/"; 3215 if (current_use.style != none_style) 3216 { 3217 s = "../$("; 3218 s += current_use.get_package_name (); 3219 s += "_tag)/"; 3220 } 3221 else 3222 { 3223 s = "./"; 3224 } 3174 3225 s += name; 3175 3226 } … … 3298 3349 */ 3299 3350 3351 if (style != none_style) 3352 { 3300 3353 libname = "${"; 3301 3354 libname += prefix; … … 3303 3356 libname += get_package_name (); 3304 3357 libname += "_tag}/"; 3358 } 3359 else 3360 { 3361 libname = "${"; 3362 libname += prefix; 3363 libname += "ROOT}/"; 3364 } 3305 3365 libname += "$(library_prefix)"; 3306 3366 libname += library; … … 3324 3384 if (!is_absolute) 3325 3385 { 3386 if (style != none_style) 3387 { 3326 3388 libname = "${"; 3327 3389 libname += prefix; … … 3329 3391 libname += get_package_name (); 3330 3392 libname += "_tag}/"; 3393 } 3394 else 3395 { 3396 libname = "${"; 3397 libname += prefix; 3398 libname += "ROOT}/"; 3399 } 3331 3400 libname += library; 3332 3401 libname += ".bundle"; … … 3846 3915 if (auto_imports == Off) cout << " (no_auto_imports)"; 3847 3916 3848 if (style == no_version_style) cout << " (no_version_directory)"; 3917 if (structuring_style == without_version_directory) cout << " (no_version_directory)"; 3918 // if (style == no_version_style) cout << " (no_version_directory)"; 3849 3919 3850 3920 if (m_has_native_version) … … 4294 4364 4295 4365 //---------------------------------------------------------- 4366 class PackageReader : public Awk 4367 { 4368 public: 4369 4370 PackageReader () 4371 { 4372 } 4373 4374 const cmt_string& get_package () const 4375 { 4376 return (m_package); 4377 } 4378 4379 void filter (const cmt_string& line) 4380 { 4381 CmtSystem::cmt_string_vector words; 4382 CmtSystem::split (line, " \t", words); 4383 if (words[0] == "package") 4384 { 4385 m_package = words[1]; 4386 } 4387 } 4388 4389 private: 4390 cmt_string m_package; 4391 }; 4392 4393 //---------------------------------------------------------- 4296 4394 Package* Package::find (const cmt_string& name) 4297 4395 { … … 4384 4482 pos = v.find ('\r'); 4385 4483 if (pos != cmt_string::npos) v.erase (pos); 4386 version = v; 4387 return true; 4484 if (v != "") 4485 { 4486 version = v; 4487 return true; 4488 } 4388 4489 } 4389 4490 else … … 4422 4523 4423 4524 return (name); 4525 } 4526 4527 //---------------------------------------------------------- 4528 bool Package::get_name (cmt_string& name, const cmt_string& path) 4529 { 4530 cmt_string name_file = path; 4531 name_file += CmtSystem::file_separator (); 4532 name_file += "requirements"; 4533 cmt_string text; 4534 if (text.read (name_file)) 4535 { 4536 PackageReader reader; 4537 reader.run (text); 4538 cmt_string v = reader.get_package (); 4539 if (v != "") 4540 { 4541 name = v; 4542 return true; 4543 } 4544 } 4545 else 4546 { 4547 CmtMessage::warning ("Could not read `" + name_file + "'."); 4548 } 4549 4550 return false; 4424 4551 } 4425 4552
Note: See TracChangeset
for help on using the changeset viewer.