Ignore:
Timestamp:
Jan 8, 2010, 4:25:58 PM (14 years ago)
Author:
rybkin
Message:

See C.L. 418

File:
1 edited

Legend:

Unmodified
Added
Removed
  • CMT/HEAD/source/cmt_use.cxx

    r528 r531  
    133133  } CompareStatus;
    134134
    135 static CompareStatus compare_versions (const cmt_string& ref_version, const cmt_string& new_version)
     135static CompareStatus compare_versions (const cmt_string& ref_version, const cmt_string& new_version, bool match = false)
    136136{
    137137  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    }
    138162
    139163  int old_v = -1;
     
    664688
    665689        cout << "use::action1> current=" << parent->get_package_name () <<
    666           " package=" << package << " ";
     690          " package=" << package << "(" << version << ")" << " ";
    667691
    668692        for (i = 0; i < uses.size (); i++)
     
    14361460  if (Cmt::get_debug ())
    14371461    {
    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;
    14401464      cout << "Use::reach_package> native_version required "<<n_version<<endl;
    14411465    }
     
    15361560  if (CmtSystem::test_file ("cmt/requirements"))
    15371561    {
    1538       CmtSystem::cd ("cmt");
    1539 
    1540       style = no_version_style;
     1562      //      CmtSystem::cd ("cmt");
     1563
     1564      //      style = no_version_style;
    15411565
    15421566      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);
    15461571          if (Cmt::get_debug ())
    15471572            {
     
    15741599          version = "v0";
    15751600        }
     1601      CmtSystem::cd ("cmt");
     1602      style = cmt_style;
     1603      structuring_style = without_version_directory;
    15761604      return (1);
    15771605    }
     
    15821610      // There are alternate possibilities when it contains wild cards
    15831611      //
    1584       if ((version == "") || (version.find ("*") != cmt_string::npos))
     1612      //      if ((version == "") || (version.find ("*") != cmt_string::npos))
     1613      if (version.find ("*") != cmt_string::npos)
    15851614        {
    15861615          static CmtSystem::cmt_string_vector versions;
     
    15891618          name = ".";
    15901619          name += CmtSystem::file_separator ();
     1620          name += version;
     1621          /*
    15911622          if (version == "") name += "*";
    15921623          else name += version;
     1624          */
    15931625
    15941626          CmtSystem::scan_dir (name, versions);
     
    16911723            }
    16921724
     1725              /*
    16931726          if (!found)
    16941727            {
     
    17001733                }
    17011734            }
     1735              */
    17021736        }
    17031737
     
    17331767          CmtSystem::cd ("mgr");
    17341768          style = mgr_style;
     1769          structuring_style = with_version_directory;
    17351770        }
    17361771    }
     
    17391774      CmtSystem::cd ("cmt");
    17401775      style = cmt_style;
     1776      structuring_style = with_version_directory;
    17411777    }
    17421778
     
    28392875  else s = real_path;
    28402876
    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    }
    28432882 
    2844   if (style != no_version_style)
     2883  //  if (style != no_version_style)
     2884  if (structuring_style == with_version_directory)
    28452885    {
    28462886      s += CmtSystem::file_separator ();
     
    30393079      buffer += " \"";
    30403080      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)
    30443088        {
    30453089          buffer += fs;
     
    31693213  else
    31703214    {
    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        }
    31743225      s += name;
    31753226    }
     
    32983349           */
    32993350         
     3351          if (style != none_style)
     3352            {
    33003353          libname = "${";
    33013354          libname += prefix;
     
    33033356          libname += get_package_name ();
    33043357          libname += "_tag}/";
     3358            }
     3359          else
     3360            {
     3361          libname = "${";
     3362          libname += prefix;
     3363          libname += "ROOT}/";
     3364            }
    33053365          libname += "$(library_prefix)";
    33063366          libname += library;
     
    33243384      if (!is_absolute)
    33253385        {
     3386          if (style != none_style)
     3387            {
    33263388          libname = "${";
    33273389          libname += prefix;
     
    33293391          libname += get_package_name ();
    33303392          libname += "_tag}/";
     3393            }
     3394          else
     3395            {
     3396          libname = "${";
     3397          libname += prefix;
     3398          libname += "ROOT}/";
     3399            }
    33313400          libname += library;
    33323401          libname += ".bundle";
     
    38463915      if (auto_imports == Off) cout << " (no_auto_imports)";
    38473916
    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)";
    38493919
    38503920      if (m_has_native_version)
     
    42944364
    42954365//----------------------------------------------------------
     4366class PackageReader : public Awk
     4367{
     4368public:
     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 
     4389private:
     4390  cmt_string m_package;
     4391};
     4392
     4393//----------------------------------------------------------
    42964394Package* Package::find (const cmt_string& name)
    42974395{
     
    43844482          pos = v.find ('\r');
    43854483          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            }
    43884489        }
    43894490      else
     
    44224523
    44234524  return (name);
     4525}
     4526
     4527//----------------------------------------------------------
     4528bool 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;
    44244551}
    44254552
Note: See TracChangeset for help on using the changeset viewer.