Changeset 662 for CMT


Ignore:
Timestamp:
Jan 6, 2014, 3:40:25 PM (10 years ago)
Author:
rybkin
Message:

See C.L. 521

Location:
CMT/HEAD
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • CMT/HEAD/ChangeLog

    r661 r662  
     12014-01-06    <rybkin@lal.in2p3.fr> 521
     2
     3        * source/cmt_tag.h: In class Tag, introduce static function apply_tag to
     4        return map of tags and uses in which apply_tag statement appears for tag
     5        * source/cmt_tag.cxx: In class Tag, in function action_apply update map of
     6        tags and uses returned by function apply_tag, in function check_tag_used
     7        return true if tag appears in apply_tag statement, in function
     8        show_definition print uses in which apply_tag statement appears for tag
     9        * source/cmt_map.h: In templated class cmt_vnode, remove const modifiers
     10        for function find to allow for cmt_vnode value to be modified, in templated
     11        class cmt_vmap, in function find remove const modifier for return value
     12        to allow for cmt_vmap values to be modified
     13        * source/cmt_parser.cxx: Implement helper function parse_cmt_flags to parse
     14        -with(out)_cmt, -with(out)_projects, -(no)_strip_path flags from
     15        requirements file, in class Cmt, modify function configure_current_package
     16        to return location of requirements file if found, in function configure
     17        make use of function parse_cmt_flags, do not read user requirements file(s)
     18        for action_none
     19        * source/cmt_symbol.cxx: In class PathBuilder, introduce static function
     20        get_path_builder to return unique class instance, make assignment operator
     21        and copy constructor private to forbid copying, make other constructors
     22        private, in class Symbol functions create and set_strip_path make use of
     23        function get_path_builder
     24        * source/cmt.h: In class Cmt, modify function configure_current_package
     25        signature
     26        * mgr/requirements: Associate CMTv1 tag with with HEAD
     27       
    1282013-12-13    <rybkin@lal.in2p3.fr> 520
    229
  • CMT/HEAD/mgr/requirements

    r656 r662  
    88tag CMTr0  CMTr25
    99
     10tag CMTv0  CMTv1
    1011#
    1112#  Automatic detection of some system features.
  • CMT/HEAD/source/cmt.h

    r659 r662  
    106106  static void configure_current_cmtpath ();
    107107  static void configure_current_dir ();
    108   static void configure_current_package ();
     108  static cmt_string configure_current_package ();
     109  //  static void configure_current_package ();
    109110  //  static void configure_current_structuring_style ();
    110111  static void configure_current_structuring_style (const ArgParser& ap);
  • CMT/HEAD/source/cmt_map.h

    r11 r662  
    276276   *   Return 0 if not found
    277277   */
    278   const T* find (const K& key) const
     278  T* find (const K& key)
     279    //  const T* find (const K& key) const
    279280  {
    280281    if (key < m_key)
     
    504505   *   Returns 0 if not found
    505506   */
    506   const T* find (const K& key) const
     507  T* find (const K& key) const
     508    //  const T* find (const K& key) const
    507509  {
    508510    if (m_top != 0)
  • CMT/HEAD/source/cmt_parser.cxx

    r660 r662  
    557557
    558558//----------------------------------------------------------
     559namespace {
     560
     561bool parse_cmt_flags (const cmt_string& file_name, CmtContext& cmt)
     562{
     563  cmt_string Flags (Cmt::get_cmt_flags (file_name));
     564  if (CmtError::get_last_error_code () == CmtError::file_access_error)
     565    return false;
     566  if (Flags.size () == 0)
     567    return true;
     568
     569  cmt_string CmtFlags (Cmt::get_cmt_flags ());
     570  if (CmtFlags.size () != 0)
     571    Flags += " " + CmtFlags;
     572
     573  CmtSystem::cmt_string_vector flags;
     574  CmtSystem::split (Flags, " \t", flags);
     575  for (int i = 0; i < flags.size (); i++)
     576    {
     577      if (flags[i] == "-without_cmt" &&
     578          cmt.m_use_cmt)
     579        cmt.m_use_cmt = false;
     580      else if (flags[i] == "-with_cmt" &&
     581               !cmt.m_use_cmt)
     582        cmt.m_use_cmt = true;
     583      else if (flags[i] == "-without_projects" &&
     584               cmt.m_use_projects)
     585        cmt.m_use_projects = false;
     586      else if (flags[i] == "-with_projects" &&
     587               !cmt.m_use_projects)
     588        cmt.m_use_projects = true;
     589      else if (flags[i] == "-no_strip_path" &&
     590               cmt.m_strip_path)
     591        {
     592          cmt.m_strip_path = false;
     593          Symbol::set_strip_path (false);
     594        }
     595      else if (flags[i] == "-strip_path" &&
     596               !cmt.m_strip_path)
     597        {
     598          cmt.m_strip_path = true;
     599          Symbol::set_strip_path (true);
     600        }
     601    }
     602
     603  return true;
     604}
     605
     606}
     607
     608//----------------------------------------------------------
    559609//void Cmt::configure ()
    560610void Cmt::configure (const ArgParser& ap)
     
    587637  configure_site_tag (0);
    588638
     639  cmt_string requirements;
     640
    589641  if (Me.m_current_package.size () != 0 &&
    590642      Me.m_current_package != "cmt_standalone")
    591     { // we have a package name (not "cmt_standalone")
     643    {
     644      // we have a package name (not "cmt_standalone")
    592645      Use& use = Use::current();
    593646      use.set (Me.m_current_package,
     
    609662            }
    610663        }
     664
     665      if (use.located ())
     666        {
     667          // parse additional options
     668          parse_cmt_flags ("requirements", m_cmt_context);
     669        }
    611670    }
    612671  else
     
    617676          CmtError::set (CmtError::path_not_found, Me.m_current_path);
    618677          return;
     678        }
     679
     680      configure_current_dir ();
     681      configure_current_structuring_style (ap);
     682      cmt_string current_package_saved (Me.m_current_package);
     683      requirements = configure_current_package ();
     684      Me.m_current_package = current_package_saved;
     685      if (requirements.size () != 0)
     686        {
     687          // parse additional options
     688          parse_cmt_flags (requirements, m_cmt_context);
    619689        }
    620690    }
     
    679749  configure_current_structuring_style (ap);
    680750
     751//   if (requirements.size () == 0)
     752//     {
    681753  log << "configure_current_package" << log_endl;
    682754  configure_current_package ();
     755//     }
    683756
    684757  Use& use = Use::current();
     
    866939void Cmt::configure_current_dir ()
    867940{
     941  if (Me.m_current_dir.size () != 0) return;
     942
    868943  cmt_string file_name;
    869944
     
    9271002
    9281003//----------------------------------------------------------
    929 void Cmt::configure_current_package ()
     1004cmt_string Cmt::configure_current_package ()
     1005//void Cmt::configure_current_package ()
    9301006{
    9311007  /*
     
    9411017      build_prefix (Me.m_current_package, Me.m_current_prefix);
    9421018      build_config (Me.m_current_prefix, Me.m_current_config);
    943       return;
     1019
     1020      cmt_string req;
     1021      use.get_full_path (req);
     1022      switch (use.style)
     1023        {
     1024        case cmt_style:
     1025          req += CmtSystem::file_separator ();
     1026          req += "cmt";
     1027          break;
     1028        case mgr_style:
     1029          req += CmtSystem::file_separator ();
     1030          req += "mgr";
     1031          break;
     1032        default:
     1033          break;
     1034        }
     1035      req += CmtSystem::file_separator ();
     1036      req += "requirements";
     1037      return req;
    9441038    }
    9451039
     
    9561050  else
    9571051    {
    958       cmt_string req = "..";
     1052      req = "..";
     1053      //      cmt_string req = "..";
    9591054      req += CmtSystem::file_separator ();
    9601055      req += "mgr";
     
    9701065          // This package is probably a standalone one
    9711066          Me.m_current_style = none_style;
     1067          req = "requirements";
     1068          if (!CmtSystem::test_file (req))
     1069            {
     1070              req = "";
     1071            }
    9721072        }
    9731073    }
     
    12101310      build_config (Me.m_current_prefix, Me.m_current_config);
    12111311    }
     1312
     1313  return req;
    12121314}
    12131315
     
    69437045    default:
    69447046      configure (ap);
    6945       //restore_all_tags (0);
    69467047      break;
    69477048    }
     
    72757376  switch (Me.m_action)
    72767377    {
    7277     case action_none :
     7378      //case action_none :
    72787379    case action_awk :
    72797380    case action_broadcast :
  • CMT/HEAD/source/cmt_symbol.cxx

    r660 r662  
    5353  inline void set_strip_path (const bool& strip_path);
    5454
     55  static PathBuilder* get_path_builder ();
     56
     57private:
    5558  PathBuilder ();
    5659  PathBuilder (bool strip_path);
    57 
    58 private:
     60  PathBuilder (const PathBuilder& other);
     61  PathBuilder& operator = (const PathBuilder& other);
     62
    5963  bool m_strip_path;
    6064};
     
    754758{
    755759  static SetBuilder Set;
    756   static PathBuilder Path (Cmt::get_strip_path ());
     760  static PathBuilder* PathPtr (PathBuilder::get_path_builder ());
     761  //static PathBuilder Path (Cmt::get_strip_path ());
    757762  //static PathBuilder Path;
    758763  static MacroBuilder Macro;
     
    915920      break;
    916921    case SymbolPath:
    917       symbol.builder = &Path;
     922      symbol.builder = PathPtr;
     923      //symbol.builder = &Path;
    918924      break;
    919925    case SymbolAlias:
     
    12611267bool Symbol::set_strip_path (const bool& strip_path)
    12621268{
     1269  PathBuilder::get_path_builder ()->set_strip_path (strip_path);
     1270  return true;
     1271  /*
    12631272  // searching for a path symbol
    12641273  for (int number = 0; number < Symbol::symbol_number (); number++)
     
    12741283
    12751284  return false;
     1285  */
    12761286}
    12771287
     
    25952605}
    25962606*/
     2607//-------------------------------------------------------------
     2608PathBuilder* PathBuilder::get_path_builder ()
     2609{
     2610  static PathBuilder Path (Cmt::get_strip_path ());
     2611  return &Path;
     2612}
     2613
    25972614//-------------------------------------------------------------
    25982615PathBuilder::PathBuilder ()
  • CMT/HEAD/source/cmt_tag.cxx

    r653 r662  
    235235
    236236      tag->mark (use ? use->get_package_name () : "");
     237
     238      Use::UsePtrVector * puses;
     239      if (!(puses = apply_tag ().find (tag)))
     240        {
     241          Use::UsePtrVector uses;
     242          uses.push_back (use);
     243          apply_tag ().add (tag, uses);
     244        }
     245      else
     246        {
     247          bool have (false);
     248          for (int i = 0; i < puses->size (); i++)
     249            {
     250              if ((*puses)[i] == use)
     251                {
     252                  have = true;
     253                  break;
     254                }
     255            }
     256          if (!have)
     257            puses->push_back (use);
     258        }
     259
    237260    }
    238261}
     
    607630  if (tag->m_tag_refs.size () > 0) return (true);
    608631  if (tag->m_tag_excludes.size () > 0) return (true);
     632  if (apply_tag ().has (tag)) return (true);
    609633
    610634  return (false);
     635}
     636
     637/*----------------------------------------------------------*/
     638Tag::TagUses& Tag::apply_tag ()
     639{
     640  static TagUses tag_uses;
     641  return tag_uses;
    611642}
    612643
     
    827858          out << "]";
    828859        }
     860
     861      if (Use::UsePtrVector * puses = apply_tag ().find (this))
     862        {
     863          out << " applied [";
     864          for (int i = 0; i < puses->size (); i++)
     865            {
     866              if (i > 0) out << " ";
     867              Use * use = (*puses)[i];
     868              if (use)
     869                {
     870                  out << use->get_package_name ();
     871                }
     872              else
     873                {
     874                  out << "current";
     875                }
     876            }
     877          out << "]";
     878        }
     879
    829880      if (m_act_context.size () != 0 &&
    830881          (m_def_use != 0 &&
  • CMT/HEAD/source/cmt_tag.h

    r568 r662  
    2020  typedef cmt_vector<Tag*> TagPtrVector;
    2121
     22  typedef cmt_vmap<const Tag*, Use::UsePtrVector> TagUses;
     23
    2224  static void action (const CmtSystem::cmt_string_vector& words, Use* use);
    2325  static void action_apply (const CmtSystem::cmt_string_vector& words, Use* use);
     
    4042
    4143  static bool check_tag_used (const Tag* tag);
     44
     45  static TagUses& apply_tag ();
    4246
    4347public:
Note: See TracChangeset for help on using the changeset viewer.