Changeset 427


Ignore:
Timestamp:
Sep 1, 2007, 11:54:25 AM (17 years ago)
Author:
rybkin
Message:

See C.L. 333

Location:
CMT/HEAD
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • CMT/HEAD/ChangeLog

    r424 r427  
     12007-09-01    <rybkin@lal.in2p3.fr> 333
     2
     3        * source/cmt_deps_builder.h: idem
     4        * source/cmt_deps_builder.cxx: idem
     5        * source/cmt_generators.h: idem
     6        * source/cmt_generators.cxx: Implement a header file filter mechanism to replace
     7        header files matching a pattern with a stamp file when calculating files dependencies
     8
    192007-07-09    <rybkin@lal.in2p3.fr> 332
    210
  • CMT/HEAD/mgr/cmt_dependencies.make

    r424 r427  
    22cmt_awk_cxx_dependencies =  ../source/cmt_awk.cxx   ../source/cmt_std.h   ../source/cmt_string.h   ../source/cmt_regexp.h   ../source/cmt_awk.h   ../source/cmt_vector.h   ../source/cmt_system.h
    33cmt_branch_cxx_dependencies =  ../source/cmt_branch.cxx   ../source/cmt_std.h   ../source/cmt_string.h   ../source/cmt_vector.h   ../source/cmt_regexp.h   ../source/cmt_system.h   ../source/cmt.h   ../source/cmt_parser.h   ../source/cmt_branch.h   ../source/cmt_fragment.h   ../source/cmt_group.h   ../source/cmt_constituent.h   ../source/cmt_language.h   ../source/cmt_map.h   ../source/cmt_pattern.h   ../source/cmt_include.h   ../source/cmt_script.h   ../source/cmt_scope_section.h   ../source/cmt_use.h   ../source/cmt_tag.h   ../source/cmt_symbol.h   ../source/cmt_awk.h   ../source/cmt_project.h   ../source/cmt_cmtpath_pattern.h   ../source/cmt_database.h
    4 cmt_constituent_cxx_dependencies =  ../source/cmt_constituent.cxx   ../source/cmt_std.h   ../source/cmt_string.h   ../source/cmt_vector.h   ../source/cmt_regexp.h   ../source/cmt_system.h   ../source/cmt.h   ../source/cmt_parser.h   ../source/cmt_fragment.h   ../source/cmt_group.h   ../source/cmt_constituent.h   ../source/cmt_language.h   ../source/cmt_awk.h   ../source/cmt_deps_builder.h   ../source/cmt_generator.h   ../source/cmt_branch.h   ../source/cmt_map.h   ../source/cmt_pattern.h   ../source/cmt_include.h   ../source/cmt_script.h   ../source/cmt_scope_section.h   ../source/cmt_use.h   ../source/cmt_tag.h   ../source/cmt_symbol.h   ../source/cmt_project.h   ../source/cmt_cmtpath_pattern.h   ../source/cmt_database.h
    5 cmt_deps_builder_cxx_dependencies =  ../source/cmt_deps_builder.cxx   ../source/cmt_std.h   ../source/cmt_string.h   ../source/cmt_vector.h   ../source/cmt_parser.h   ../source/cmt_regexp.h   ../source/cmt_system.h   ../source/cmt.h   ../source/cmt_deps_builder.h   ../source/cmt_map.h   ../source/cmt_include.h   ../source/cmt_script.h   ../source/cmt_pattern.h   ../source/cmt_scope_section.h   ../source/cmt_use.h   ../source/cmt_tag.h   ../source/cmt_symbol.h   ../source/cmt_log.h
     4cmt_constituent_cxx_dependencies =  ../source/cmt_constituent.cxx   ../source/cmt_std.h   ../source/cmt_string.h   ../source/cmt_vector.h   ../source/cmt_regexp.h   ../source/cmt_system.h   ../source/cmt.h   ../source/cmt_parser.h   ../source/cmt_fragment.h   ../source/cmt_group.h   ../source/cmt_constituent.h   ../source/cmt_language.h   ../source/cmt_awk.h   ../source/cmt_map.h   ../source/cmt_include.h   ../source/cmt_script.h   ../source/cmt_pattern.h   ../source/cmt_scope_section.h   ../source/cmt_use.h   ../source/cmt_deps_builder.h   ../source/cmt_generator.h   ../source/cmt_branch.h   ../source/cmt_tag.h   ../source/cmt_symbol.h   ../source/cmt_project.h   ../source/cmt_cmtpath_pattern.h   ../source/cmt_database.h
     5cmt_deps_builder_cxx_dependencies =  ../source/cmt_deps_builder.cxx   ../source/cmt_std.h   ../source/cmt_string.h   ../source/cmt_vector.h   ../source/cmt_parser.h   ../source/cmt_regexp.h   ../source/cmt_system.h   ../source/cmt.h   ../source/cmt_map.h   ../source/cmt_include.h   ../source/cmt_script.h   ../source/cmt_pattern.h   ../source/cmt_scope_section.h   ../source/cmt_use.h   ../source/cmt_deps_builder.h   ../source/cmt_tag.h   ../source/cmt_symbol.h   ../source/cmt_log.h
    66cmt_fragment_cxx_dependencies =  ../source/cmt_fragment.cxx   ../source/cmt_std.h   ../source/cmt_string.h   ../source/cmt_vector.h   ../source/cmt_regexp.h   ../source/cmt_system.h   ../source/cmt.h   ../source/cmt_parser.h   ../source/cmt_fragment.h   ../source/cmt_map.h   ../source/cmt_include.h   ../source/cmt_script.h   ../source/cmt_pattern.h   ../source/cmt_scope_section.h   ../source/cmt_use.h   ../source/cmt_tag.h   ../source/cmt_symbol.h   ../source/cmt_branch.h   ../source/cmt_group.h   ../source/cmt_constituent.h   ../source/cmt_language.h   ../source/cmt_awk.h   ../source/cmt_project.h   ../source/cmt_cmtpath_pattern.h   ../source/cmt_database.h
    7 cmt_generator_cxx_dependencies =  ../source/cmt_generator.cxx   ../source/cmt_std.h   ../source/cmt_string.h   ../source/cmt_vector.h   ../source/cmt_regexp.h   ../source/cmt_system.h   ../source/cmt.h   ../source/cmt_parser.h   ../source/cmt_fragment.h   ../source/cmt_group.h   ../source/cmt_constituent.h   ../source/cmt_language.h   ../source/cmt_awk.h   ../source/cmt_deps_builder.h   ../source/cmt_generator.h   ../source/cmt_map.h   ../source/cmt_include.h   ../source/cmt_script.h   ../source/cmt_pattern.h   ../source/cmt_scope_section.h   ../source/cmt_use.h   ../source/cmt_tag.h   ../source/cmt_symbol.h   ../source/cmt_generators.h
     7cmt_generator_cxx_dependencies =  ../source/cmt_generator.cxx   ../source/cmt_std.h   ../source/cmt_string.h   ../source/cmt_vector.h   ../source/cmt_regexp.h   ../source/cmt_system.h   ../source/cmt.h   ../source/cmt_parser.h   ../source/cmt_fragment.h   ../source/cmt_group.h   ../source/cmt_constituent.h   ../source/cmt_language.h   ../source/cmt_awk.h   ../source/cmt_map.h   ../source/cmt_include.h   ../source/cmt_script.h   ../source/cmt_pattern.h   ../source/cmt_scope_section.h   ../source/cmt_use.h   ../source/cmt_deps_builder.h   ../source/cmt_generator.h   ../source/cmt_tag.h   ../source/cmt_symbol.h   ../source/cmt_generators.h
    88cmt_include_cxx_dependencies =  ../source/cmt_include.cxx   ../source/cmt_std.h   ../source/cmt_string.h   ../source/cmt_vector.h   ../source/cmt_regexp.h   ../source/cmt_system.h   ../source/cmt.h   ../source/cmt_parser.h   ../source/cmt_include.h   ../source/cmt_map.h   ../source/cmt_script.h   ../source/cmt_pattern.h   ../source/cmt_scope_section.h   ../source/cmt_use.h   ../source/cmt_tag.h   ../source/cmt_symbol.h   ../source/cmt_log.h
    99cmt_parser_cxx_dependencies =  ../source/cmt_parser.cxx   ../source/cmt_std.h   ../source/cmt_string.h   ../source/cmt_vector.h   ../source/cmt_regexp.h   ../source/cmt_system.h   ../source/cmt.h   ../source/cmt_parser.h   ../source/cmt_version.h   ../source/cmt_branch.h   ../source/cmt_fragment.h   ../source/cmt_group.h   ../source/cmt_constituent.h   ../source/cmt_language.h   ../source/cmt_map.h   ../source/cmt_pattern.h   ../source/cmt_include.h   ../source/cmt_script.h   ../source/cmt_scope_section.h   ../source/cmt_use.h   ../source/cmt_tag.h   ../source/cmt_symbol.h   ../source/cmt_awk.h   ../source/cmt_project.h   ../source/cmt_cmtpath_pattern.h   ../source/cmt_database.h   ../source/cmt_deps_builder.h   ../source/cmt_generator.h   ../source/cmt_error.h   ../source/cmt_cvs.h   ../source/cmt_lock.h   ../source/cmt_triggers.h   ../source/cmt_model.h   ../source/cmt_syntax.h   ../source/cmt_install_area.h   ../source/cmt_sequence.h   ../source/cmt_log.h   ../source/cmt_commands.h
     
    2929cmt_cmtpath_pattern_cxx_dependencies =  ../source/cmt_cmtpath_pattern.cxx   ../source/cmt_vector.h   ../source/cmt_std.h   ../source/cmt_string.h   ../source/cmt_regexp.h   ../source/cmt_system.h   ../source/cmt.h   ../source/cmt_parser.h   ../source/cmt_branch.h   ../source/cmt_fragment.h   ../source/cmt_group.h   ../source/cmt_constituent.h   ../source/cmt_language.h   ../source/cmt_map.h   ../source/cmt_pattern.h   ../source/cmt_include.h   ../source/cmt_script.h   ../source/cmt_scope_section.h   ../source/cmt_use.h   ../source/cmt_tag.h   ../source/cmt_symbol.h   ../source/cmt_awk.h   ../source/cmt_project.h   ../source/cmt_cmtpath_pattern.h   ../source/cmt_database.h   ../source/cmt_syntax.h
    3030cmt_sequence_cxx_dependencies =  ../source/cmt_sequence.cxx   ../source/cmt_std.h   ../source/cmt_string.h   ../source/cmt_regexp.h   ../source/cmt_awk.h   ../source/cmt_sequence.h   ../source/cmt_vector.h   ../source/cmt_system.h
    31 cmt_generators_cxx_dependencies =  ../source/cmt_generators.cxx   ../source/cmt_std.h   ../source/cmt_string.h   ../source/cmt_vector.h   ../source/cmt_regexp.h   ../source/cmt_system.h   ../source/cmt.h   ../source/cmt_parser.h   ../source/cmt_fragment.h   ../source/cmt_group.h   ../source/cmt_constituent.h   ../source/cmt_language.h   ../source/cmt_awk.h   ../source/cmt_deps_builder.h   ../source/cmt_generator.h   ../source/cmt_generators.h   ../source/cmt_map.h   ../source/cmt_include.h   ../source/cmt_script.h   ../source/cmt_pattern.h   ../source/cmt_scope_section.h   ../source/cmt_use.h   ../source/cmt_tag.h   ../source/cmt_symbol.h   ../source/cmt_log.h
     31cmt_generators_cxx_dependencies =  ../source/cmt_generators.cxx   ../source/cmt_std.h   ../source/cmt_string.h   ../source/cmt_vector.h   ../source/cmt_regexp.h   ../source/cmt_system.h   ../source/cmt.h   ../source/cmt_parser.h   ../source/cmt_fragment.h   ../source/cmt_group.h   ../source/cmt_constituent.h   ../source/cmt_language.h   ../source/cmt_awk.h   ../source/cmt_map.h   ../source/cmt_include.h   ../source/cmt_script.h   ../source/cmt_pattern.h   ../source/cmt_scope_section.h   ../source/cmt_use.h   ../source/cmt_deps_builder.h   ../source/cmt_generator.h   ../source/cmt_generators.h   ../source/cmt_tag.h   ../source/cmt_symbol.h   ../source/cmt_log.h
    3232cmt_scope_section_cxx_dependencies =  ../source/cmt_scope_section.cxx   ../source/cmt_std.h   ../source/cmt_string.h   ../source/cmt_vector.h   ../source/cmt_regexp.h   ../source/cmt_system.h   ../source/cmt.h   ../source/cmt_parser.h   ../source/cmt_scope_section.h
    3333cmt_log_cxx_dependencies =  ../source/cmt_log.cxx   ../source/cmt_std.h   ../source/cmt_string.h   ../source/cmt_log.h   ../source/cmt_vector.h   ../source/cmt_parser.h   ../source/cmt_regexp.h   ../source/cmt_system.h   ../source/cmt.h
  • CMT/HEAD/source/cmt_deps_builder.cxx

    r424 r427  
    3030
    3131//--------------------------------------------------
    32 static int build_deps (const cmt_string& name,
    33                        const cmt_string& dir_name,
    34                        int current_path_index,
    35                        const CmtSystem::cmt_string_vector& include_paths,
    36                        const CmtSystem::cmt_string_vector& substitutions,
    37                        CmtSystem::cmt_string_vector& all_deps,
    38                        CmtSystem::cmt_string_vector& deps);
    39 
     32static int locate (const cmt_string& name,
     33                   const cmt_string& dir_name,
     34                   const CmtSystem::cmt_string_vector& include_paths,
     35                   const CmtSystem::cmt_string_vector& substitutions,
     36                   cmt_string& full_name);
     37
     38//--------------------------------------------------
     39static void build_deps_text (char* text,
     40                             const cmt_string& dir_name,
     41                             int current_path_index,
     42                             const CmtSystem::cmt_string_vector& include_paths,
     43                             const CmtSystem::cmt_string_vector& substitutions,
     44                             const DepsBuilder::HeaderFilters& header_filters,
     45                             CmtSystem::cmt_string_vector& all_deps,
     46                             CmtSystem::cmt_string_vector& deps);
    4047
    4148//--------------------------------------------------
     
    4552                                const CmtSystem::cmt_string_vector& include_paths,
    4653                                const CmtSystem::cmt_string_vector& substitutions,
     54                                const DepsBuilder::HeaderFilters& header_filters,
    4755                                CmtSystem::cmt_string_vector& all_deps,
    4856                                CmtSystem::cmt_string_vector& deps)
     
    5058  Log;
    5159
    52   bool found = false;
    53 
    5460  for (int i = 0; i < all_deps.size (); i++)
    5561    {
     
    5864      log << "CMT> check old header file name=" << n << " against " << header_file << log_endl;
    5965
    60       if (n == header_file)
    61         {
    62           found = true;
    63           break;
    64         }
    65     }
    66  
    67   if (!found)
    68     {
    69       log << "CMT> parsing new header file name=" << header_file << log_endl;
    70 
    71       all_deps.push_back (header_file);
     66      if (n == header_file) return;
     67    }
     68
     69  all_deps.push_back (header_file);
     70
     71  cmt_string header_file_path;
     72  int path_index = locate (header_file,
     73                           dir_name,
     74                           include_paths,
     75                           substitutions,
     76                           header_file_path);
     77
     78  if (path_index < 0) return;
     79
     80  static int header_filters_size = header_filters.size ();
     81  if (header_filters_size > 0)
     82    {
     83      // check the filter macros from
     84      // find all macros named <package>_header_file_filter
     85      // for all those macros, get the regexp and check the matches against the header file name
     86      // if any match, select the stamp file instead of the header file
     87      // the stamp file might be either a conventional name
     88      //         <package>/cmt/cmt_all_headers.stamp
     89      // or given in a macro eg <package>_header_stamp_file_name
     90      //
     91      for (int i = header_filters_size - 1; i >= 0; i--)
     92        {
     93          cmt_string stamp_file;
     94          if (header_filters[i].use_stamp (header_file_path, stamp_file))
     95            {
     96              bool included = false;
     97              for (int i = deps.size () - 1; i >= 0; i--)
     98                {
     99                  if (deps[i] == stamp_file)
     100                    {
     101                      included = true;
     102                      break;
     103                    }
     104                }
     105              if (!included) deps.push_back (stamp_file);
     106              return;
     107            }
     108        }
     109    }
     110
     111  log << "CMT> parsing new header file name=" << header_file << log_endl;
     112
     113///////////////////////////////////////////////////////////////////////////////////////////////////////
     114  cmt_string text;
     115  text.read (header_file_path);
     116  char* ptr = &text[0];
     117  cmt_string new_dir;
     118  CmtSystem::dirname (header_file_path, new_dir);
     119
     120  if (path_index == 0 || path_index == 1)
     121    build_deps_text (ptr, new_dir,
     122                     current_path_index,
     123                     include_paths, substitutions,
     124                     header_filters,
     125                     all_deps, deps);
     126  else
     127    build_deps_text (ptr, new_dir,
     128                     path_index,
     129                     include_paths, substitutions,
     130                     header_filters,
     131                     all_deps, deps);
     132///////////////////////////////////////////////////////////////////////////////////////////////////////
    72133     
    73       int path_index = build_deps (header_file,
    74                                    dir_name,
    75                                    current_path_index,
    76                                    include_paths,
    77                                    substitutions,
    78                                    all_deps,
    79                                    deps);
    80      
    81       if (path_index >= 0)
    82         {
    83           cmt_string full_name;
    84          
    85           if (path_index == 1)
    86             {
    87               full_name = dir_name;
    88               full_name += CmtSystem::file_separator ();
    89              
    90               if (current_path_index >= 2)
    91                 {
    92                   full_name.replace (include_paths[current_path_index - 2],
    93                                      substitutions[current_path_index - 2]);
    94                 }
    95             }
    96           else if (path_index > 1)
    97             {
    98               full_name  = substitutions[path_index - 2];
    99               full_name += CmtSystem::file_separator ();
    100             }
    101          
    102           full_name += header_file;
    103          
    104           deps.push_back (full_name);
    105         }
    106     }
     134//path_index >= 0
     135
     136  cmt_string full_name;
     137
     138  if (path_index == 1)
     139    {
     140      full_name = dir_name;
     141      full_name += CmtSystem::file_separator ();
     142
     143      if (current_path_index >= 2)
     144        {
     145          full_name.replace (include_paths[current_path_index - 2],
     146                             substitutions[current_path_index - 2]);
     147        }
     148    }
     149  else if (path_index > 1)
     150    {
     151      full_name  = substitutions[path_index - 2];
     152      full_name += CmtSystem::file_separator ();
     153    }
     154
     155  full_name += header_file;
     156
     157  deps.push_back (full_name);
    107158}
    108159
     
    115166                              const CmtSystem::cmt_string_vector& include_paths,
    116167                              const CmtSystem::cmt_string_vector& substitutions,
     168                              const DepsBuilder::HeaderFilters& header_filters,
    117169                              CmtSystem::cmt_string_vector& all_deps,
    118170                              CmtSystem::cmt_string_vector& deps)
     
    229281                      include_paths,
    230282                      substitutions,
     283                      header_filters,
    231284                      all_deps,
    232285                      deps);
     
    470523                             const CmtSystem::cmt_string_vector& include_paths,
    471524                             const CmtSystem::cmt_string_vector& substitutions,
     525                             const DepsBuilder::HeaderFilters& header_filters,
    472526                             CmtSystem::cmt_string_vector& all_deps,
    473527                             CmtSystem::cmt_string_vector& deps)
     
    481535  log << "CMT> build_deps_text dir_name="
    482536      << dir_name << log_endl;
    483 
    484537
    485538  // erase of continuation character
     
    487540  max_pos = strlen (text);
    488541  char* current = text;
     542
    489543  char* last = text + max_pos;
    490544  while (current < last)
    491545    {
    492546   
    493       char* crnl = strstr (current, "\\\r\n");
    494       char* nl   = strstr (current, "\\\n");
     547      //  bscrnl -> BackSlash Carriage Return New Line
     548      //  bsnl -> BackSlash New Line
     549      char* bscrnl = strstr (current, "\\\r\n");
     550      char* bsnl   = strstr (current, "\\\n");
    495551     
    496       if ( (crnl==0) && (nl ==0)) break;
     552      if ( (bscrnl==0) && (bsnl ==0)) break;
    497553     
    498554      int length = 0;
    499555           
    500556      char * ptr = 0;
    501       if (nl==0)  //crnl > 0
     557      if (bsnl==0)  //bscrnl > 0
    502558        {
    503559          length = 3;
    504           ptr    = crnl;
     560          ptr    = bscrnl;
    505561        }     
    506       else if (crnl==0) //nl > 0
     562      else if (bscrnl==0) //bsnl > 0
    507563        {
    508564          length = 2;                       
    509           ptr    = nl;
     565          ptr    = bsnl;
    510566        }     
    511       else if (crnl < nl)
     567      else if (bscrnl < bsnl)
    512568        {
    513569          length = 3;
    514           ptr    = crnl;                 
     570          ptr    = bscrnl;                 
    515571        }
    516       else // (crnl > nl)
     572      else // (bscrnl > bsnl)
    517573        {
    518574          length = 2;                       
    519           ptr    = nl;         
     575          ptr    = bsnl;         
    520576        }
    521577      strcpy (ptr, ptr+length);
     
    538594      char* marker_pos = 0;
    539595
     596      //  crnl -> Carriage Return New Line
     597      //  nl -> New Line
    540598      char* crnl = strstr (current, "\r\n");
    541599      char* nl = strchr (current, '\n');
     
    598656                                     include_paths,
    599657                                     substitutions,
     658                                     header_filters,
    600659                                     all_deps,
    601660                                     deps);
     
    647706                       const CmtSystem::cmt_string_vector& include_paths,
    648707                       const CmtSystem::cmt_string_vector& substitutions,
     708                       const DepsBuilder::HeaderFilters& header_filters,
    649709                       CmtSystem::cmt_string_vector& all_deps,
    650710                       CmtSystem::cmt_string_vector& deps)
     
    652712  Log;
    653713
    654   int result = -1;
    655   cmt_string new_dir;
    656 
    657714  log << "CMT> build_deps name=" << name << " dir_name="
     715      << dir_name << log_endl;
     716
     717  cmt_string full_name;
     718  int path_index = locate (name,
     719                           dir_name,
     720                           include_paths,
     721                           substitutions,
     722                           full_name);
     723
     724  if (path_index >= 0)
     725    {
     726      cmt_string text;
     727      text.read (full_name);
     728      char* ptr = &text[0];
     729      cmt_string new_dir;
     730      CmtSystem::dirname (full_name, new_dir);
     731
     732      if (path_index == 0 || path_index == 1)
     733        build_deps_text (ptr, new_dir,
     734                         current_path_index,
     735                         include_paths, substitutions,
     736                         header_filters,
     737                         all_deps, deps);
     738      else
     739        build_deps_text (ptr, new_dir,
     740                         path_index,
     741                         include_paths, substitutions,
     742                         header_filters,
     743                         all_deps, deps);
     744    }
     745  if (path_index < 0)
     746    {
     747      log << "CMT> build_deps3" << log_endl;
     748    }
     749  return path_index;
     750}
     751
     752//--------------------------------------------------
     753static int locate (const cmt_string& name,
     754                   const cmt_string& dir_name,
     755                   const CmtSystem::cmt_string_vector& include_paths,
     756                   const CmtSystem::cmt_string_vector& substitutions,
     757                   cmt_string& full_name)
     758{
     759  Log;
     760
     761  log << "CMT> locate name=" << name << " dir_name="
    658762      << dir_name << log_endl;
    659763
     
    663767  if (CmtSystem::test_file (name))
    664768    {
    665       cmt_string text;
    666 
    667       text.read (name);
    668 
    669       char* ptr = &text[0];
    670       CmtSystem::dirname (name, new_dir);
    671 
    672       build_deps_text (ptr, new_dir, current_path_index,
    673                        include_paths, substitutions,
    674                        all_deps, deps);
     769      full_name = name;
    675770      return (0);
    676771    }
    677772
    678   cmt_string full_name;
    679 
    680   full_name = dir_name;
    681   full_name += CmtSystem::file_separator ();
    682   full_name += name;
     773  cmt_string p;
    683774
    684775  //
     
    686777  // upper level source file
    687778  //
    688   if (CmtSystem::test_file (full_name))
    689     {
    690       cmt_string text;
    691 
    692       text.read (full_name);
    693 
    694       char* ptr = &text[0];
    695       CmtSystem::dirname (full_name, new_dir);
    696 
    697       build_deps_text (ptr, new_dir, current_path_index,
    698                        include_paths, substitutions,
    699                        all_deps, deps);
     779  p = dir_name;
     780  p += CmtSystem::file_separator ();
     781  p += name;
     782  if (CmtSystem::test_file (p))
     783    {
     784      full_name = p;
    700785      return (1);
    701786    }
    702 
    703   int path_index = -1;
    704787
    705788  //
     
    707790  // the include_paths
    708791  //
    709   for (path_index = 0; path_index < include_paths.size (); path_index++)
    710     {
    711       full_name  = include_paths[path_index];
    712       full_name += CmtSystem::file_separator ();
    713       full_name += name;
    714 
    715       log << "CMT> build_deps2 full_name=" << full_name << log_endl;
    716 
    717       if (CmtSystem::test_file (full_name))
    718         {
    719           cmt_string text;
    720 
    721           text.read (full_name);
    722 
    723           char* ptr = &text[0];
    724           CmtSystem::dirname (full_name, new_dir);
    725 
    726           log << "CMT> build_deps3 new_dir=" << new_dir << log_endl;
    727 
    728           build_deps_text (ptr,
    729                            new_dir,
    730                            path_index + 2,
    731                            include_paths,
    732                            substitutions,
    733                            all_deps,
    734                            deps);
    735 
     792  for (int path_index = 0; path_index < include_paths.size (); path_index++)
     793    {
     794      p  = include_paths[path_index];
     795      p += CmtSystem::file_separator ();
     796      p += name;
     797
     798      log << "CMT> locate2 full_name=" << p << log_endl;
     799
     800      if (CmtSystem::test_file (p))
     801        {
     802          full_name = p;
    736803          return (path_index + 2);
    737804        }
    738805    }
    739806
    740   log << "CMT> build_deps3" << log_endl;
     807  log << "CMT> locate3" << log_endl;
    741808
    742809  return (-1);
     
    748815  m_include_paths.clear ();
    749816  m_substitutions.clear ();
     817  for (int i = m_header_filters.size () - 1; i >= 0; i--)
     818    {
     819      m_header_filters[i].clear ();
     820    }
     821  m_header_filters.clear ();
    750822}
    751823
     
    753825void DepsBuilder::add (const cmt_string& path, const cmt_string& substitution)
    754826{
     827  if (path.size () == 0)
     828    {
     829      return;
     830    }
    755831  if (path[path.size () - 1] == CmtSystem::file_separator ())
    756832    {
     
    849925  log << "Starting deps builder on " << file_name << log_endl;
    850926
    851 
    852927  m_deps.clear ();
    853928  m_all_deps.clear ();
     
    875950                  m_include_paths,
    876951                  m_substitutions,
     952                  m_header_filters,
    877953                  m_all_deps,
    878954                  m_deps);
     
    9641040}
    9651041
     1042//--------------------------------------------------------------------------
     1043void DepsBuilder::add_header_filter (const Use* use, const cmt_regexp* filter, const cmt_string& stamp)
     1044{
     1045  add_header_filter (HeaderFilter (use, filter, stamp));
     1046}
     1047
     1048//--------------------------------------------------------------------------
     1049void DepsBuilder::add_header_filter (const HeaderFilter& hf)
     1050{
     1051  m_header_filters.push_back (hf);
     1052}
  • CMT/HEAD/source/cmt_deps_builder.h

    r11 r427  
    1010#include "cmt.h"
    1111#include "cmt_system.h"
     12#include "cmt_use.h"
    1213
    1314class DepsBuilder
     
    1516public:
    1617
     18  class HeaderFilter
     19  {
     20  public:
     21
     22    HeaderFilter ()
     23      : m_use (0), m_filter (0) { }
     24
     25    HeaderFilter (const Use* use, const cmt_regexp* filter, const cmt_string& stamp)
     26      : m_use (use), m_filter (filter), m_stamp (stamp) { }
     27
     28    ~HeaderFilter ()
     29      { }
     30
     31    inline const Use* use () const
     32      { return m_use; }
     33
     34    inline bool use_stamp (const cmt_string& header, cmt_string& stamp) const
     35      { return m_filter->match (header) ? stamp = m_stamp, true : false ; }
     36
     37    void clear ()
     38      {
     39        m_use = 0;
     40        if (m_filter) delete m_filter;
     41        m_filter = 0;
     42        m_stamp = cmt_string ();
     43      }
     44
     45  private:
     46
     47    const Use* m_use;
     48    const cmt_regexp* m_filter;
     49    cmt_string m_stamp;
     50  };
     51
     52  typedef cmt_vector<HeaderFilter> HeaderFilters;
     53
    1754  void clear ();
    1855  void add (const cmt_string& path, const cmt_string& substitution);
    1956  void add_includes (const Use& use);
     57  void add_header_filter (const Use* use, const cmt_regexp* filter, const cmt_string& stamp);
     58  void add_header_filter (const HeaderFilter& hf);
    2059  CmtSystem::cmt_string_vector& run (const cmt_string& file_name);
     60
     61  DepsBuilder ()
     62    { }
    2163
    2264private:
    2365
     66  DepsBuilder (const DepsBuilder&)
     67    { }
     68
    2469  CmtSystem::cmt_string_vector m_include_paths;
    2570  CmtSystem::cmt_string_vector m_substitutions;
     71  HeaderFilters m_header_filters;
    2672
    2773  CmtSystem::cmt_string_vector m_deps;
  • CMT/HEAD/source/cmt_generators.cxx

    r400 r427  
    26192619};
    26202620
    2621 
    26222621void DependencyGenerator::build (const CmtSystem::cmt_string_vector& arguments)
    26232622{
    26242623  reset ();
    26252624  prepare_use_context ();
     2625
     2626  prepare_header_file_filters ();
    26262627
    26272628  m_stamps = true;
     
    28412842      fclose (f);
    28422843    }
     2844
     2845//  m_deps_builder.clear ();
    28432846}
    28442847
     
    29983001}
    29993002
     3003//--------------------------------------------------
     3004void DependencyGenerator::prepare_header_file_filters ()
     3005{
     3006  Use::UsePtrVector& uses = Use::get_ordered_uses ();
     3007  uses.push_back (&Use::current ());
     3008  for (int i = uses.size () - 1; i >= 0; i--)
     3009    {
     3010      Use* use = uses[i];
     3011      if (use->discarded) continue;
     3012      if (use->m_hidden) continue;
     3013      if (!use->located ()) continue;
     3014
     3015      cmt_string package_name = use->get_package_name ();
     3016      if (package_name == "CMT") continue;
     3017
     3018      Symbol* filter_macro = Symbol::find (package_name + "_header_file_filter");
     3019      if (filter_macro == 0) continue;
     3020
     3021      Symbol* stamp_macro = Symbol::find (package_name + "_header_file_stamp");
     3022      cmt_string stamp;
     3023      if (stamp_macro != 0)
     3024        {
     3025          stamp = stamp_macro->resolve_macro_value ();
     3026        }
     3027      else
     3028        {
     3029          use->get_full_path (stamp);
     3030          stamp += CmtSystem::file_separator ();
     3031          if (use->style == mgr_style) stamp += "mgr";
     3032          else stamp += "cmt";
     3033          stamp += CmtSystem::file_separator ();
     3034          stamp += "cmt_header_file.stamp";
     3035          //stamp += "cmt_all_headers.stamp";
     3036          //<package>/cmt/cmt_all_headers.stamp
     3037        }
     3038      if (!CmtSystem::test_file (stamp)) continue;
     3039
     3040      cmt_regexp* filter = new cmt_regexp (filter_macro->resolve_macro_value ());
     3041      assert (filter != 0);
     3042
     3043      m_deps_builder.add_header_filter (use, filter, stamp);
     3044    }
     3045}
  • CMT/HEAD/source/cmt_generators.h

    r197 r427  
    213213public:
    214214  void build (const CmtSystem::cmt_string_vector& arguments);
    215 
     215  void prepare_header_file_filters ();
     216 
    216217private:
    217218  void add_line_to_text (const cmt_string& line, cmt_string& text);
Note: See TracChangeset for help on using the changeset viewer.