Ignore:
Timestamp:
Jan 13, 2014, 4:09:37 PM (10 years ago)
Author:
rybkin
Message:

merge -r 646:663 HEAD

Location:
CMT/v1r25-branch
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • CMT/v1r25-branch

  • CMT/v1r25-branch/source/cmt_use.cxx

    r610 r664  
    33// arnault@lal.in2p3.fr
    44// Modified by garonne@lal.in2p3.fr
     5// Modified by Grigory Rybkin
    56// See the complete license in cmt_license.txt "http://www.cecill.info".
    67//-----------------------------------------------------------
     
    18261827  m_located = false;
    18271828  m_package = 0;
     1829  m_project = 0;
    18281830  m_index = -1;
    18291831
     
    18481850      m_package = 0;
    18491851    }
     1852  m_project = 0;
    18501853
    18511854  version   = "";
     
    19231926
    19241927//----------------------------------------------------------
    1925 void Use::change_path (const cmt_string& new_path)
     1928void Use::change_path (const cmt_string& new_path, const Project* project)
    19261929{
    19271930  //
     
    19291932  // where this package/version has been found.
    19301933  //
     1934  if (Cmt::get_debug ())
     1935    {
     1936      cout << "|Use::change_path> path: " << new_path
     1937           << " project: " << (project ? project->get_cmtpath () : "0")
     1938           << " use: " << get_info () << endl;
     1939    }
    19311940
    19321941  real_path = "";
    19331942  m_realpath = "";
    19341943
    1935   if (new_path != "")
     1944  m_project = 0;
     1945
     1946  if (new_path.size () != 0)
     1947    //  if (new_path != "")
    19361948    {
    19371949      if ((path.size () > 0) &&
     
    19511963      if (!CmtSystem::realpath_ (real_path, m_realpath))
    19521964        {
    1953           CmtError::set (CmtError::file_access_error, "Cannot compute real path `" +
    1954                          real_path + "'");
     1965          CmtError::set (CmtError::file_access_error,
     1966                         "Cannot compute real path `" + real_path + "': " +
     1967                         get_info ());
    19551968          CmtError::print ();
    19561969          return;
     
    19581971    }
    19591972 
     1973  if (project)
     1974    m_project = project;
     1975
    19601976  m_located = true;
     1977
     1978  if (Cmt::get_debug ())
     1979    {
     1980      cout << "<Use::change_path| real_path: " << real_path
     1981           << " m_project: " << (m_project ? m_project->get_cmtpath () : "0")
     1982           << " use: " << get_info () << endl;
     1983    }
    19611984}
    19621985
     
    23472370          }
    23482371       
    2349         m_use->change_path (path);
     2372        m_use->change_path (path, &project);
    23502373
    23512374        m_found = true;
     
    23552378    else if (m_use->alternate_versions.size () > 0)
    23562379      {
    2357         if (m_use->select_alternate ())
     2380        if (m_use->select_alternate (&project))
    23582381          {
    23592382            if (Cmt::get_debug ())
     
    24482471              cout << "move_to2> " << expanded_path << endl;
    24492472            }
    2450 
    24512473          change_path (here);
    2452 
    24532474          return (true);
    24542475        }
     
    24612482                  cout << "move_to5> " << real_path << endl;
    24622483                }
    2463              
    24642484              return (true);
    24652485            }
    24662486        }
     2487
     2488      if (!CmtSystem::cd (here))
     2489        {
     2490          CmtError::set (CmtError::file_access_error, here);
     2491        }
    24672492      return (false);
    24682493//     }
     
    24822507
    24832508//----------------------------------------------------------
    2484 bool Use::select_alternate ()
     2509bool Use::select_alternate (const Project* project)
    24852510{
    24862511  int i;
     
    25672592                }
    25682593
    2569               change_path (alternate_paths[selected_index]);
     2594              change_path (alternate_paths[selected_index], project);
    25702595              return (true);
    25712596            }
     
    35683593  offset = "";
    35693594
    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);
    3575 
     3595  const Project* p (0);
     3596  if (m_project)
     3597    {
     3598      p = m_project;
     3599      cmtpath = p->get_cmtpath ();
     3600    }
     3601  else
     3602    {
     3603      cmtpath = m_realpath.size ()
     3604        ? Project::find_in_cmt_paths (m_realpath, true)
     3605        : Project::find_in_cmt_paths (real_path)
     3606        ;
     3607      p = Project::find_by_cmtpath (cmtpath);
     3608  //  const Project* p = Project::find_by_cmtpath (cmtpath);
     3609    }
    35763610  //  if (cmtpath != "")
    35773611  if (p != 0)
     
    35903624      else if (!CmtSystem::realpath_ (real_path, offset))
    35913625        {
    3592           CmtError::set (CmtError::file_access_error, "Cannot compute real path `" +
    3593                          real_path + "'");
     3626          CmtError::set (CmtError::file_access_error,
     3627                         "Cannot compute real path `" + real_path + "': " +
     3628                         get_info ());
    35943629          CmtError::print ();
    35953630          return;
     
    36193654bool Use::get_strategy (const cmt_string& name) const
    36203655{
    3621   const Project* p =
     3656  const Project* p = get_project ();
     3657    /*
    36223658    Project::find_by_cmtpath (m_realpath.size ()
    36233659                              ? Project::find_in_cmt_paths (m_realpath, true)
    36243660                              : Project::find_in_cmt_paths (real_path)
    36253661                              );
    3626   //  const Project* p = Project::find_by_cmtpath (Project::find_in_cmt_paths (real_path));
     3662    */
    36273663
    36283664  bool strategy;
     
    37053741  buffer += "\n";
    37063742
    3707   if (located ())
     3743  if (m_located)
     3744    //  if (located ())
    37083745    {
    37093746      buffer += "macro ";
     
    37253762          buffer += package_name;
    37263763        }
    3727       //      if (style != no_version_style)
    37283764      if (structuring_style == with_version_directory)
    37293765        {
     
    37333769      buffer += "\"";
    37343770      buffer += "\n";
     3771    }
     3772
     3773  if (action_setup == Cmt::get_action () &&
     3774      Requirements == Cmt::get_print_mode ())
     3775    {
     3776      //cerr << "|Use::fill_standard_macros> Checking for " << prefix << "CONFIG" << endl;
     3777      if (!discarded &&
     3778          get_package_name () != "cmt_standalone" &&
     3779          get_strategy ("SetupConfig"))
     3780        {
     3781          buffer += "macro ";
     3782          buffer += prefix;
     3783          buffer += "CONFIG";
     3784          buffer += " \"";
     3785          buffer += CmtSystem::get_cmt_config ();
     3786          buffer += "\"";
     3787          buffer += "\n";
     3788        }
    37353789    }
    37363790
     
    37643818  buffer += "\n";
    37653819 
    3766   Project* p = Project::find_by_cmtpath (cmtpath);
     3820  const Project* p = m_project
     3821    ? m_project
     3822    : Project::find_by_cmtpath (cmtpath)
     3823    ;
     3824  /*
     3825  const Project* p (m_project);
     3826  if (!p)
     3827    p = Project::find_by_cmtpath (cmtpath);
     3828  */
    37673829
    37683830  buffer += "macro ";
     
    45204582  static const cmt_string null = "";
    45214583
     4584  return m_package ? m_package->get_name () : null ;
     4585  /*
    45224586  Package* p = m_package;
    45234587  if (p == 0) return (null);
    45244588
    45254589  return (p->get_name ());
     4590  */
    45264591}
    45274592
     
    48294894
    48304895  return (is_in_path);
    4831 }
    4832 
    4833 //----------------------------------------------------------
    4834 bool Use::located () const
    4835 {
    4836   return (m_located);
    48374896}
    48384897
     
    57365795
    57375796//----------------------------------------------------------
    5738 Project* Use::get_project ()
     5797const Project* Use::get_project () const
    57395798{   
     5799  if (m_project)
     5800    return m_project;
     5801
     5802  return Project::find_by_cmtpath (m_realpath.size ()
     5803                                   ? Project::find_in_cmt_paths (m_realpath, true)
     5804                                   : Project::find_in_cmt_paths (real_path)
     5805                                   );
     5806  /*
     5807  cmt_string cmtpath = m_realpath.size ()
     5808    ? Project::find_in_cmt_paths (m_realpath, true)
     5809    : Project::find_in_cmt_paths (real_path)
     5810    ;
     5811  return Project::find_by_cmtpath (cmtpath);
     5812  */
     5813  /*
    57405814  Project* p;
    57415815  cmt_string cmtpath = "";
     
    57445818  p = Project::find_by_cmtpath (cmtpath);
    57455819  return p;   
     5820  */
    57465821}
    57475822
Note: See TracChangeset for help on using the changeset viewer.