Changeset 608 for CMT


Ignore:
Timestamp:
Apr 5, 2012, 1:43:26 PM (12 years ago)
Author:
rybkin
Message:

See C.L. 483

Location:
CMT/HEAD
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • CMT/HEAD/ChangeLog

    r607 r608  
     12012-04-05    <rybkin@lal.in2p3.fr> 483
     2
     3        * source/cmt_project.h: In class Project function find_in_cmt_paths, add
     4        second boolean parameter to specify whether first argument is real path
     5        * source/cmt_project.cxx: In class Project, in function find_in_cmt_paths,
     6        do not call CmtSystem::realpath_ if boolean parameter is true, in function
     7        order_all, make use of m_realpath from class Use
     8        * source/cmt_use.h: In class Use, introduce member m_realpath to hold
     9        canonicalized absolute real_path, and member function get_realpath
     10        * source/cmt_use.cxx: In class Use, in function change_path, calculate
     11        m_realpath, in functions get_cmtpath_and_offset and get_strategy, make use
     12        of m_realpath when calling Project::find_in_cmt_paths
     13        * source/cmt_symbol.cxx: In find_path_entry helper function, introduce
     14        static cache of real paths in order to optimise CmtSystem::realpath_ usage
     15       
    1162012-04-03    <rybkin@lal.in2p3.fr> 482
    217
  • CMT/HEAD/source/cmt_project.cxx

    r607 r608  
    987987
    988988  Use& use = Use::current();
    989   cmt_string current_path (Cmt::get_current_dir ());
     989  cmt_string current_path;
     990  cmt_string current_path_real;
    990991  if (use.located ())
    991992    {
    992       current_path = use.real_path;
    993       CmtMessage::verbose ("Using current use real_path `" + current_path + "'");
    994     }
    995 
    996   cmt_string current_path_real;
    997   if (!CmtSystem::realpath_ (current_path, current_path_real))
     993      current_path_real = use.get_realpath ();
     994      if (current_path_real.size ())
     995        CmtMessage::verbose ("Using current use realpath `" + current_path_real + "'");
     996      else
     997        {
     998          current_path = use.real_path;
     999          CmtMessage::verbose ("Using current use real_path `" + current_path + "'");
     1000        }
     1001    }
     1002  else
     1003    current_path = Cmt::get_current_dir ();
     1004
     1005  if (0 == current_path_real.size () &&
     1006      !CmtSystem::realpath_ (current_path, current_path_real))
    9981007    {
    9991008      CmtError::set (CmtError::file_access_error, "Cannot compute real path `" +
     
    16501659
    16511660//----------------------------------------------------------
    1652 cmt_string Project::find_in_cmt_paths (const cmt_string& path)
     1661cmt_string Project::find_in_cmt_paths (const cmt_string& path, bool realpath)
    16531662{
    16541663  //const cmt_string pwd = CmtSystem::pwd ();
     
    16571666  cmt_string path_real;
    16581667  //cerr << "realpath_: find_in_cmt_paths" << endl;
    1659   if (!CmtSystem::realpath_ (path, path_real))
     1668  if (realpath)
     1669    path_real = path;
     1670  else if (!CmtSystem::realpath_ (path, path_real))
    16601671    return ("");
    16611672
  • CMT/HEAD/source/cmt_project.h

    r581 r608  
    127127  static void scan_paths_for_package (PathScanner& scanner, const cmt_string& name);
    128128
    129   static cmt_string find_in_cmt_paths (const cmt_string& path);
     129  static cmt_string find_in_cmt_paths (const cmt_string& path, bool realpath = false);
    130130
    131131  static void fill_cmtpaths (cmt_string& buffer);
  • CMT/HEAD/source/cmt_symbol.cxx

    r607 r608  
    22232223{
    22242224  static const cmt_string path_separator = CmtSystem::path_separator ();
    2225 
    2226   //  cmt_string here = CmtSystem::pwd ();
    2227   cmt_string rvalue = value;
    2228 
    2229   /*
    2230   if (CmtSystem::cd (value))
    2231     {
    2232       rvalue = CmtSystem::pwd ();
    2233     }
    2234   else
    2235   */
    2236   if (!CmtSystem::realpath_ (value, rvalue))
    2237     {
    2238       CmtSystem::compress_path (rvalue);
     2225  static cmt_vmap <cmt_string, cmt_string> realpaths;
     2226
     2227  cmt_string rvalue;
     2228  const cmt_string * prvalue;
     2229
     2230  if (!(prvalue = realpaths.find (value)))
     2231    {
     2232      if (!CmtSystem::realpath_ (value, rvalue))
     2233        {
     2234          rvalue = value;
     2235          CmtSystem::compress_path (rvalue);
     2236        }
     2237      prvalue = &rvalue;
     2238      realpaths.add (value, rvalue);
     2239      //      cerr << "realpaths.add: " << value << " , " << rvalue << endl;
    22392240    }
    22402241
     
    22472248    {
    22482249      const cmt_string& item = items[i];
    2249       cmt_string ritem = item;
    2250       /*
    2251       if (CmtSystem::cd (item))
     2250      cmt_string ritem;
     2251      const cmt_string * pritem;
     2252
     2253      if (!(pritem = realpaths.find (item)))
    22522254        {
    2253           ritem = CmtSystem::pwd ();
     2255          if (!CmtSystem::realpath_ (item, ritem))
     2256            {
     2257              ritem = item;
     2258              CmtSystem::compress_path (ritem);
     2259            }
     2260          pritem = &ritem;
     2261          realpaths.add (item, ritem);
     2262          //  cerr << "realpaths.add: " << item << " , " << ritem << endl;
    22542263        }
    2255       else
    2256       */
    2257       if (!CmtSystem::realpath_ (item, ritem))
    2258         {
    2259           CmtSystem::compress_path (ritem);
    2260         }
    2261 
    2262       if (ritem == rvalue)
     2264      if (*pritem == *prvalue)
    22632265        {
    22642266          found = true;
     
    22672269    }
    22682270
    2269   //  CmtSystem::cd (here);
    22702271  return (found);
    22712272}
  • CMT/HEAD/source/cmt_use.cxx

    r607 r608  
    18531853  manager   = "";
    18541854  real_path = "";
     1855  m_realpath = "";
    18551856
    18561857  prefix    = "";
     
    19301931
    19311932  real_path = "";
     1933  m_realpath = "";
    19321934
    19331935  if (new_path != "")
     
    19471949
    19481950      CmtSystem::compress_path (real_path);
     1951      if (!CmtSystem::realpath_ (real_path, m_realpath))
     1952        {
     1953          CmtError::set (CmtError::file_access_error, "Cannot compute real path `" +
     1954                         real_path + "'");
     1955          CmtError::print ();
     1956          return;
     1957        }
    19491958    }
    19501959 
     
    35593568  offset = "";
    35603569
    3561   cmtpath = Project::find_in_cmt_paths (real_path);
    3562   Project* p = Project::find_by_cmtpath (cmtpath);
     3570  cmtpath = m_realpath.size ()
     3571    ? Project::find_in_cmt_paths (m_realpath, true)
     3572    : Project::find_in_cmt_paths (real_path)
     3573    ;
     3574  const Project* p = Project::find_by_cmtpath (cmtpath);
    35633575
    35643576  //  if (cmtpath != "")
     
    35743586      //      offset.replace (cmtpath, empty_string);
    35753587      //cerr << "realpath_: get_cmtpath_and_offset" << endl;
    3576       if (!CmtSystem::realpath_ (real_path, offset))
     3588      if (0 != m_realpath.size ())
     3589        offset = m_realpath;
     3590      else if (!CmtSystem::realpath_ (real_path, offset))
    35773591        {
    35783592          CmtError::set (CmtError::file_access_error, "Cannot compute real path `" +
     
    36053619bool Use::get_strategy (const cmt_string& name) const
    36063620{
    3607   const Project* p = Project::find_by_cmtpath (Project::find_in_cmt_paths (real_path));
     3621  const Project* p =
     3622    Project::find_by_cmtpath (m_realpath.size ()
     3623                              ? Project::find_in_cmt_paths (m_realpath, true)
     3624                              : Project::find_in_cmt_paths (real_path)
     3625                              );
     3626  //  const Project* p = Project::find_by_cmtpath (Project::find_in_cmt_paths (real_path));
    36083627
    36093628  bool strategy;
  • CMT/HEAD/source/cmt_use.h

    r588 r608  
    110110  void get_cmtpath_and_offset (cmt_string& cmtpath, cmt_string& offset) const;
    111111  bool get_strategy (const cmt_string& name) const;
     112  inline const cmt_string& get_realpath () const { return m_realpath; }
    112113
    113114  void fill_includes_macro (cmt_string& buffer) const;
     
    246247
    247248  cmt_regexp m_head_version;
     249  cmt_string m_realpath; /* canonicalized absolute real_path */
    248250
    249251  friend class UseProjectAction;
Note: See TracChangeset for help on using the changeset viewer.