Changeset 531 for CMT/HEAD


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

See C.L. 418

Location:
CMT/HEAD
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • CMT/HEAD/ChangeLog

    r530 r531  
     12010-01-08    <rybkin@lal.in2p3.fr> 418
     2
     3        * source/cmt_use.cxx: In function compare_versions, introduce optional
     4        argument "match" and implement mode in which versions are compared
     5        literally (with * matching any string), in function Use::reach_package,
     6        make use of compare_versions in "match" mode when structuring style is
     7        "without_version_directory", make use of 2 use class members - style and
     8        structuring_style, do not consider version == "" where it is not possible,
     9        in functions Use::get_full_path, Use::fill_standard_macros, install_library,
     10        Use::build_library_links, Use::show_sub_uses do not use "no_version_style"
     11        as value of style member, use also structuring_style instead, allow for
     12        standalone package case, introduce helper class PackageReader to deduce
     13        package name from requirements file and implement Package::get_name function
     14        making use of the class
     15        * source/cmt_use.h: Introduce Use class member structuring_style, function
     16        Package::get_name
     17        * source/cmt_parser.h: Exclude "no_version_style" value from CmtDirStyle
     18        enum
     19        * source/cmt_parser.cxx: In function Cmt::configure_current_package, use
     20        directory structure and package statement in requirements to determine
     21        structuring style, in function Cmt::do_create, do not use "no_version_style"
     22        as value of CmtContext m_current_style, in function Cmt::do_run, for
     23        "cmt run" command, check exit status and set execution_failed error, when
     24        appropriate, in function dos_script_prefix, do not use "no_version_style"
     25        value no_version_style, in function Cmt::load do not use "no_version_style"
     26        as value of CmtContext m_current_style, in StandardMacroBuilder
     27        fill_for_use_requirements function, allow for standalone package case
     28        * source/cmt_symbol.cxx: In function Symbol::action, allow for standalone
     29        package case, do not use "no_version_style" as value of Use style member
     30       
    1312009-11-28    <rybkin@lal.in2p3.fr> 417
    232
  • CMT/HEAD/source/cmt_parser.cxx

    r530 r531  
    567567
    568568  use.style = Me.m_current_style;
     569  use.structuring_style = Me.m_current_structuring_style;
    569570
    570571  use.change_path (Me.m_current_path);
     
    840841      CmtSystem::basename (up_dir, up_branch);
    841842
    842       cmt_string version_file = "..";
    843       version_file += CmtSystem::file_separator ();
     843      cmt_string cmt_dir = "..";
     844      cmt_dir += CmtSystem::file_separator ();
    844845      switch (Me.m_current_style)
    845846        {
    846847        case cmt_style:
    847           version_file += "cmt";
     848          cmt_dir += "cmt";
    848849          break;
    849850        case mgr_style:
    850           version_file += "mgr";
     851          cmt_dir += "mgr";
    851852          break;
    852853        default:
     
    857858
    858859      //      if (CmtSystem::test_file (version_file))
    859       if (CmtSystem::test_file (version_file
     860      if (CmtSystem::test_file (cmt_dir
    860861                                + CmtSystem::file_separator ()
    861862                                + Package::get_version_file_name ())
     
    888889          */
    889890          cmt_string v;
    890           if (Package::get_version (v, version_file))
     891          //      if (Package::get_version (v, version_file))
     892          if (Package::get_version (v, cmt_dir))
    891893            {
    892894              Me.m_current_version = v;
     
    896898              Me.m_current_version = "v*";
    897899              CmtMessage::warning ("Structuring style used `without_version_directory'."
    898                                    " Could not determine version in `" + version_file + "'."
     900                                   " Could not determine version in `" + cmt_dir + "'."
    899901                                   " Default version `" + Me.m_current_version + "'");
    900902            }
     
    910912            }
    911913
    912           Me.m_current_style = no_version_style;
     914          Me.m_current_structuring_style = without_version_directory;
     915          //          Me.m_current_style = no_version_style;
    913916        }
    914917      else
    915918        {
     919          // Try to use directory structure and
     920          // package statement in requirements, if available
     921          cmt_string up_up_dir;
     922          cmt_string up_up_branch;
     923          CmtSystem::dirname (up_dir, up_up_dir);
     924          CmtSystem::basename (up_up_dir, up_up_branch);
     925
     926          cmt_string n;
     927          bool done (false);
     928          if (Package::get_name (n, cmt_dir))
     929            {
     930              if (n == up_branch)
     931                {
     932                  Me.m_current_package = up_branch;
     933                  Me.m_current_path = up_up_dir;
     934                  Me.m_current_structuring_style = without_version_directory;
     935                  cmt_string v;
     936                  if (Package::get_version (v, cmt_dir))
     937                    {
     938                      Me.m_current_version = v;
     939                    }
     940                  else
     941                    {
     942                      // No version descriptor
     943                      // No version directory. The version is defaulted to v*
     944                      Me.m_current_version = "v*";
     945                      CmtMessage::warning ("Structuring style used `without_version_directory'."
     946                                           " Could not determine version in `" + cmt_dir + "'."
     947                                           " Default version `" + Me.m_current_version + "'");
     948                    }
     949                  done =true;
     950                }
     951              else if (n == up_up_branch)
     952                {
     953                  // The up branch IS a version directory.
     954                  Me.m_current_version = up_branch;
     955                  Me.m_current_package = up_up_branch;
     956                  CmtSystem::dirname (up_up_dir, Me.m_current_path);
     957                  Me.m_current_structuring_style = with_version_directory;
     958                  done =true;
     959                }
     960              else
     961                {
     962                  CmtMessage::warning ("Package name `" + n + "' in `" + cmt_dir +
     963                                       "' does not correspond to directory"
     964                                       " structure");
     965                }
     966            }
     967
     968          if (!done)
     969            {
    916970          // Try to determine the structuring style from:
    917971          //
     
    9551009            {
    9561010              // The up branch IS a version directory.
    957              
    9581011              Me.m_current_version = up_branch;
     1012              Me.m_current_package = up_up_branch;
     1013              CmtSystem::dirname (up_up_dir, Me.m_current_path);
     1014              /*
    9591015              CmtSystem::dirname (up_dir, up_dir);
    9601016              CmtSystem::basename (up_dir, Me.m_current_package);
    9611017              CmtSystem::dirname (up_dir, Me.m_current_path);
     1018              */
     1019              Me.m_current_structuring_style = with_version_directory;
    9621020            }
    9631021          else
     
    9691027                }
    9701028              Me.m_current_package = up_branch;
    971               CmtSystem::dirname (up_dir, Me.m_current_path);
    972 
     1029              Me.m_current_path = up_up_dir;
     1030              //              CmtSystem::dirname (up_dir, Me.m_current_path);
     1031              Me.m_current_structuring_style = without_version_directory;
    9731032              cmt_string v;
    974               if (Package::get_version (v, version_file))
     1033              if (Package::get_version (v, cmt_dir))
    9751034                {
    9761035                  Me.m_current_version = v;
     
    9801039              // No version descriptor
    9811040              // No version directory. The version is defaulted to v*
    982              
    9831041                  Me.m_current_version = "v*";
    9841042                  CmtMessage::warning ("Structuring style used `without_version_directory'."
    985                                        " Could not determine version in `" + version_file + "'."
     1043                                       " Could not determine version in `" + cmt_dir + "'."
    9861044                                       " Default version `" + Me.m_current_version + "'");
    9871045                }
    9881046             
    989               Me.m_current_style = no_version_style;
     1047              //              Me.m_current_style = no_version_style;
     1048            }
    9901049            }
    9911050        }
     
    9961055    {
    9971056      Me.m_current_package = "cmt_standalone";
    998       Me.m_current_version = "";
     1057      Me.m_current_version = "v0";
    9991058      Me.m_current_path = Me.m_current_dir;
     1059      Me.m_current_structuring_style = without_version_directory;
     1060      //      Me.m_current_style = none_style;
    10001061      build_prefix (Me.m_current_package, Me.m_current_prefix);
    10011062      build_config (Me.m_current_prefix, Me.m_current_config);
    1002       Me.m_current_style = none_style;
    10031063    }
    10041064}
     
    25682628  use.change_path (Me.m_current_path);
    25692629  use.style     = Me.m_current_style;
     2630  use.structuring_style = Me.m_current_structuring_style;
    25702631
    25712632  Me.m_quiet = true;
     
    27022763  use.change_path (Me.m_current_path);
    27032764  use.style     = Me.m_current_style;
     2765  use.structuring_style = Me.m_current_structuring_style;
    27042766
    27052767  Me.m_quiet = true;
     
    29062968          else
    29072969            {
     2970              Me.m_current_style = cmt_style;
    29082971              if (with_version_dir)
    29092972                {
    2910                   Me.m_current_style = cmt_style;
     2973                  Me.m_current_structuring_style = with_version_directory;
    29112974                }
    29122975              else
    29132976                {
    2914                   Me.m_current_style = no_version_style;
     2977                  Me.m_current_structuring_style = without_version_directory;
     2978                  //                  Me.m_current_style = no_version_style;
    29152979                }
    29162980
     
    29212985      else
    29222986        {
     2987          Me.m_current_style = mgr_style;
    29232988          if (with_version_dir)
    29242989            {
    2925               Me.m_current_style = mgr_style;
     2990              Me.m_current_structuring_style = with_version_directory;
     2991              //              Me.m_current_style = mgr_style;
    29262992            }
    29272993          else
    29282994            {
    2929               Me.m_current_style = no_version_style;
     2995              Me.m_current_structuring_style = without_version_directory;
     2996              //              Me.m_current_style = no_version_style;
    29302997            }
    29312998         
     
    29363003  else
    29373004    {
     3005      Me.m_current_style = cmt_style;
    29383006      if (with_version_dir)
    29393007        {
    2940           Me.m_current_style = cmt_style;
     3008          Me.m_current_structuring_style = with_version_directory;
     3009          //          Me.m_current_style = cmt_style;
    29413010        }
    29423011      else
    29433012        {
    2944           Me.m_current_style = no_version_style;
     3013          Me.m_current_structuring_style = without_version_directory;
     3014          //          Me.m_current_style = no_version_style;
    29453015        }
    29463016
     
    29723042    {
    29733043    case cmt_style:
    2974     case no_version_style:
     3044      //    case no_version_style:
    29753045      CmtSystem::cd ("cmt");
    29763046      break;
     
    35903660        }
    35913661
    3592       CmtSystem::execute (cmd);
     3662      int status = CmtSystem::execute (cmd);
     3663      if (status != 0)
     3664        {
     3665          CmtError::set (CmtError::execution_failed, ap.arguments[0], status);
     3666        }
     3667      //      CmtSystem::execute (cmd);
    35933668    }
    35943669}
     
    47464821    {
    47474822      no_device = "..\\..\\..";
    4748       if (Cmt::get_current_style () == no_version_style)
     4823      if (Cmt::get_current_structuring_style () == without_version_directory)
     4824        //      if (Cmt::get_current_style () == no_version_style)
    47494825        {
    47504826          no_device = "..\\..";
     
    55475623
    55485624  Me.m_current_style = none_style;
     5625  Me.m_current_structuring_style = without_version_directory;
    55495626
    55505627  if (!CmtSystem::cd (Me.m_current_version))
     
    55675644      else
    55685645        {
    5569           Me.m_current_style = no_version_style;
     5646          Me.m_current_style = cmt_style;
     5647          Me.m_current_structuring_style = without_version_directory;
     5648          //          Me.m_current_style = no_version_style;
    55705649        }
    55715650    }
     
    55755654      dir += CmtSystem::file_separator ();
    55765655      dir += "cmt";
    5577       if (Me.m_current_style == none_style) Me.m_current_style = cmt_style;
     5656      if (Me.m_current_style == none_style)
     5657        {
     5658          Me.m_current_style = cmt_style;
     5659          Me.m_current_structuring_style = with_version_directory;
     5660        }
    55785661    }
    55795662  else
     
    55905673          dir += CmtSystem::file_separator ();
    55915674          dir += "mgr";
    5592           if (Me.m_current_style == none_style) Me.m_current_style = mgr_style;
     5675          if (Me.m_current_style == none_style)
     5676            {
     5677              Me.m_current_style = mgr_style;
     5678              Me.m_current_structuring_style = with_version_directory;
     5679            }
    55935680        }
    55945681      else
     
    56555742  use->done    = false;
    56565743  use->style   = Me.m_current_style;
     5744  use->structuring_style  = Me.m_current_structuring_style;
    56575745
    56585746  /*
     
    70587146            }
    70597147        }
     7148      else
     7149        Me.m_current_style = none_style;
    70607150
    70617151      dir = CmtSystem::pwd ();
     
    70697159          CmtSystem::basename (Me.m_current_path, Me.m_current_package);
    70707160          CmtSystem::dirname (Me.m_current_path, Me.m_current_path);
     7161          Me.m_current_structuring_style = with_version_directory;
    70717162        }
    70727163      else
     
    70757166          Me.m_current_version = "";
    70767167          CmtSystem::dirname (Me.m_current_path, Me.m_current_path);
    7077 
    7078           Me.m_current_style = no_version_style;
     7168          Me.m_current_structuring_style = without_version_directory;
     7169          //          Me.m_current_style = no_version_style;
    70797170        }
    70807171
     
    70837174      use.path    = Me.m_current_path;
    70847175      use.style   = Me.m_current_style;
     7176      use.structuring_style = Me.m_current_structuring_style;
    70857177    }
    70867178
     
    76037695//                 buffer += use->prefix;
    76047696//                 buffer += "ROOT)";
    7605                 buffer += fs;
    76067697               
    7607                 if (use->style == mgr_style) buffer += "mgr";
    7608                 else buffer += "cmt";
     7698                if (use->style == cmt_style)
     7699                  {
     7700                    buffer += fs;
     7701                    buffer += "cmt";
     7702                  }
     7703                else if (use->style == mgr_style)
     7704                  {
     7705                    buffer += fs;
     7706                    buffer += "mgr";
     7707                  }
     7708                //                else buffer += "cmt";
    76097709               
    76107710                buffer += fs;
  • CMT/HEAD/source/cmt_parser.h

    r525 r531  
    2525  mgr_style,
    2626  cmt_style,
    27   no_version_style,
     27  //  no_version_style,
    2828  none_style
    2929} CmtDirStyle;
  • CMT/HEAD/source/cmt_symbol.cxx

    r530 r531  
    992992              full_name = use->get_full_path ();
    993993                }
    994               full_name += CmtSystem::file_separator ();
    995               if (use->style == cmt_style) full_name += "cmt";
    996               else if (use->style == no_version_style) full_name += "cmt";
    997               else full_name += "mgr";
     994              if (use->style == cmt_style)
     995                {
     996                  full_name += CmtSystem::file_separator ();
     997                  full_name += "cmt";
     998                }
     999              else if (use->style == mgr_style)
     1000                {
     1001                  full_name += CmtSystem::file_separator ();
     1002                  full_name += "mgr";
     1003                }
     1004              //              else if (use->style == no_version_style) full_name += "cmt";
     1005              //              else full_name += "mgr";
    9981006              full_name += CmtSystem::file_separator ();
    9991007              full_name += name;
  • 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
  • CMT/HEAD/source/cmt_use.h

    r461 r531  
    148148  cmt_string real_path;
    149149  cmt_string native_version;     /* idem                            */
    150   CmtDirStyle style;             /* May be cmt or mgr               */
     150  CmtDirStyle style;             /* May be cmt, or mgr, or none_style */
     151  CmtStructuringStyle structuring_style; /* with or without version directory */
    151152
    152153  cmt_string prefix;             /* upper case copy of package      */
     
    237238  static bool get_version (cmt_string& version, const cmt_string& path = ".");
    238239  static const cmt_string& get_version_file_name ();
     240  static bool get_name (cmt_string& name, const cmt_string& path = ".");
    239241
    240242public:
Note: See TracChangeset for help on using the changeset viewer.