Ticket #1995: pjl_cs080606.patch

File pjl_cs080606.patch, 13.3 KB (added by Nicola Musatti, 14 years ago)
  • compiler_status.cpp

     
    2121
    2222#include "boost/config.hpp"
    2323#include "boost/filesystem/operations.hpp"
     24#include "boost/filesystem/convenience.hpp"
    2425#include "boost/filesystem/fstream.hpp"
    2526#include "detail/tiny_xml.hpp"
    2627namespace fs = boost::filesystem;
     
    9091  std::vector<int> error_count;
    9192
    9293  // prefix for library and test hyperlink prefix
    93   string cvs_root ( "http://boost.cvs.sourceforge.net/" );
    94   string url_prefix_dir_view( cvs_root + "boost/boost" );
    95   string url_prefix_checkout_view( cvs_root + "*checkout*/boost/boost" );
    96   string url_suffix_text_view( "?view=markup&rev=HEAD" );
     94  string svn_root ( "http://svn.boost.org/trac/boost/browser/trunk/" );
     95  string url_prefix_dir_view( svn_root );
     96  string url_prefix_checkout_view( svn_root );
     97  string url_suffix_text_view( "" );
    9798
    9899//  get revision number (as a string) if boost_root is svn working copy  -----//
    99100
     
    349350  fs::path bin_path;
    350351  if (boost_build_v2)
    351352  {
    352     bin_path = locate_root / "bin.v2" / relative;
     353    if ( relative == "status" )
     354      bin_path = locate_root / "bin.v2" / "libs";
     355    else
     356    {
     357      bin_path = locate_root / "bin.v2" / relative;
     358      if (!fs::exists(bin_path))
     359        bin_path = locate_root / "bin" / relative;
     360    }
    353361    if (!fs::exists(bin_path))
    354362    {
    355363      std::cerr << "warning: could not find build results for '"
     
    732740    }
    733741  }
    734742
     743//  find_compilers  ------------------------------------------------------------//
     744
     745  void find_compilers(const fs::path & bin_dir)
     746  {
     747    fs::directory_iterator compiler_itr( bin_dir );
     748    if ( specific_compiler.empty() )
     749      std::clog << "Using " << bin_dir.string() << " to determine compilers\n";
     750    for (; compiler_itr != end_itr; ++compiler_itr )
     751    {
     752      if ( fs::is_directory( *compiler_itr )  // check just to be sure
     753        && compiler_itr->leaf() != "test" ) // avoid strange directory (Jamfile bug?)
     754      {
     755        if ( specific_compiler.size() != 0
     756          && specific_compiler != compiler_itr->leaf() ) continue;
     757        toolsets.push_back( compiler_itr->leaf() );
     758        string desc( compiler_desc( compiler_itr->leaf() ) );
     759        string vers( version_desc( compiler_itr->leaf() ) );
     760        report << "<td>"
     761             << (desc.size() ? desc : compiler_itr->leaf())
     762             << (vers.size() ? (string( "<br>" ) + vers ) : string( "" ))
     763             << "</td>\n";
     764        error_count.push_back( 0 );
     765      }
     766    }
     767  }
     768
    735769//  do_table_body  -----------------------------------------------------------//
    736770
    737771  void do_table_body( const fs::path & bin_dir )
     
    746780    jamfile.clear();
    747781    jamfile.seekg(0);
    748782    string line;
     783    bool run_tests = false;
     784
    749785    while( std::getline( jamfile, line ) )
    750786    {
    751787      bool v2(false);
    752       string::size_type pos( line.find( "subinclude" ) );
    753       if ( pos == string::npos ) {
    754         pos = line.find( "build-project" );
     788      string::size_type sub_pos( line.find( "subinclude" ) );
     789      if ( sub_pos == string::npos ) {
     790        sub_pos = line.find( "build-project" );
    755791        v2 = true;
    756792      }
    757       if ( pos != string::npos
    758         && line.find( '#' ) > pos )
     793      if ( sub_pos != string::npos
     794        && line.find( '#' ) > sub_pos )
    759795      {
    760796        if (v2)
    761           pos = line.find_first_not_of( " \t./", pos+13 );
     797          sub_pos = line.find_first_not_of( " \t./", sub_pos+13 );
    762798        else
    763           pos = line.find_first_not_of( " \t./", pos+10 );
     799          sub_pos = line.find_first_not_of( " \t./", sub_pos+10 );
    764800     
    765         if ( pos == string::npos ) continue;
     801        if ( sub_pos == string::npos ) continue;
    766802        string subinclude_bin_dir(
    767           line.substr( pos, line.find_first_of( " \t", pos )-pos ) );
     803          line.substr( sub_pos, line.find_first_of( " \t", sub_pos )-sub_pos ) );
    768804
    769805        fs::path bin_path = find_bin_path(subinclude_bin_dir);
    770806        if (!bin_path.empty())
    771807          do_rows_for_sub_tree( bin_path, results );
    772808      }
     809      if ( ! run_tests )
     810      {
     811        string::size_type run_pos = line.find("run-tests");
     812        if ( run_pos != string::npos && line.find_first_not_of(" \t") == run_pos )
     813          run_tests = true;
     814      }
     815      else
     816      {
     817        if ( line.find(";") != string::npos )
     818          run_tests = false;
     819        else
     820        {
     821          string::size_type pos = line.find_first_not_of( " \t" );
     822          if ( pos != string::npos && line[pos] != '#' )
     823          {
     824            string::size_type end_pos = line.find_first_of(" \t#", pos);
     825            string::iterator end = end_pos != string::npos ? line.begin() + end_pos : line.end();
     826            string run_tests_bin_dir(line.begin() + pos, end);
     827            fs::path bin_path = find_bin_path("libs/" + run_tests_bin_dir);
     828            if (!bin_path.empty())
     829              do_rows_for_sub_tree( bin_path, results );
     830          }
     831        }
     832      }
    773833    }
    774834
    775835
     
    789849    // - Boost.Build V2 location with top-lelve "build-dir"
    790850    // - Boost.Build V1 location without ALL_LOCATE_TARGET
    791851    string relative( fs::initial_path().string() );
    792     relative.erase( 0, boost_root.string().size()+1 );   
     852    if ( relative.find(boost_root.string()) != string::npos )
     853      relative.erase( 0, boost_root.string().size()+1 );
     854    else if ( relative.find(locate_root.string()) != string::npos )
     855      relative.erase( 0, locate_root.string().size()+1 );
    793856    fs::path bin_path = find_bin_path(relative);
    794857
    795858    report << "<table border=\"1\" cellspacing=\"0\" cellpadding=\"5\">\n";
     
    799862    report << "<tr><td>Library</td><td>Test Name</td>\n"
    800863      "<td><a href=\"compiler_status.html#test-type\">Test Type</a></td>\n";
    801864
    802     fs::directory_iterator itr( bin_path );
    803     while ( itr != end_itr
    804       && ((itr->string().find( ".test" ) != (itr->string().size()-5))
    805       || !fs::is_directory( *itr )))
    806       ++itr; // bypass chaff
    807     if ( itr != end_itr )
     865    if ( relative == "status" )
    808866    {
    809       fs::directory_iterator compiler_itr( *itr );
    810       if ( specific_compiler.empty() )
    811         std::clog << "Using " << itr->string() << " to determine compilers\n";
    812       for (; compiler_itr != end_itr; ++compiler_itr )
     867      fs::recursive_directory_iterator ritr( bin_path );
     868      fs::recursive_directory_iterator end_ritr;
     869      while ( ritr != end_ritr
     870        && ((ritr->string().find( ".test" ) != (ritr->string().size()-5))
     871        || !fs::is_directory( *ritr )))
     872        ++ritr; // bypass chaff
     873      if ( ritr != end_ritr )
    813874      {
    814         if ( fs::is_directory( *compiler_itr )  // check just to be sure
    815           && compiler_itr->leaf() != "test" ) // avoid strange directory (Jamfile bug?)
    816         {
    817           if ( specific_compiler.size() != 0
    818             && specific_compiler != compiler_itr->leaf() ) continue;
    819           toolsets.push_back( compiler_itr->leaf() );
    820           string desc( compiler_desc( compiler_itr->leaf() ) );
    821           string vers( version_desc( compiler_itr->leaf() ) );
    822           report << "<td>"
    823                << (desc.size() ? desc : compiler_itr->leaf())
    824                << (vers.size() ? (string( "<br>" ) + vers ) : string( "" ))
    825                << "</td>\n";
    826           error_count.push_back( 0 );
    827         }
     875        find_compilers( *ritr );
    828876      }
    829877    }
     878    else
     879    {
     880      fs::directory_iterator itr( bin_path );
     881      while ( itr != end_itr
     882        && ((itr->string().find( ".test" ) != (itr->string().size()-5))
     883        || !fs::is_directory( *itr )))
     884        ++itr; // bypass chaff
     885      if ( itr != end_itr )
     886      {
     887        find_compilers( *itr );
     888      }
     889    }
    830890
    831891    report << "</tr>\n";
    832892
  • process_jam_log.cpp

     
    155155    temp.erase( temp.find_last_of( "/" ) ); // remove leaf
    156156    temp = split( trim_left( temp ) ).back();
    157157    if ( temp[0] == '.' ) temp.erase( 0, temp.find_first_not_of( "./" ) );
    158     else temp.erase( 0, locate_root.string().size()+1 );
     158    else if ( temp[0] == '/' ) temp.erase( 0, locate_root.string().size()+1 );
    159159    if ( echo )
    160160        std::cout << "\ttarget_directory( \"" << s << "\") -> \"" << temp << "\"" << std::endl;
    161161    return temp;
     
    555555  std::ios::sync_with_stdio(false);
    556556
    557557  fs::initial_path();
     558  std::istream* input = 0;
    558559
    559560  if ( argc <= 1 )
    560     std::cout << "Usage: bjam [bjam-args] | process_jam_log [--echo] [--create-directories] [--v1|v2] [locate-root]\n"
    561                  "locate-root         - the same as the bjam ALL_LOCATE_TARGET\n"
    562                  "                      parameter, if any. Default is boost-root.\n"
    563                  "create-directories  - if the directory for xml file doesn't exists - creates it.\n"
    564                  "                      usually used for processing logfile on different machine\n"
    565                  "v2                  - bjam version 2 used (default).\n"
    566                  "v1                  - bjam version 1 used.\n"
    567                  ;
     561    std::cout <<  "process_jam_log [--echo] [--create-directories] [--v1|--v2]\n"
     562                  "                [--boost-root boost_root] [--locate-root locate_root]\n"
     563                  "                [--input-file input_file]\n"
     564                  "--echo               - verbose diagnostic output.\n"
     565                  "--create-directories - if the directory for xml file doesn't exists - creates it.\n"
     566                  "                       usually used for processing logfile on different machine\n"
     567                  "--v2                 - bjam version 2 used (default).\n"
     568                  "--v1                 - bjam version 1 used.\n"
     569                  "--boost-root         - the root of the boost installation being used. If not defined\n"
     570                  "                       assume to run from within it and discover it euristically.\n"
     571                  "--locate-root        - the same as the bjam ALL_LOCATE_TARGET\n"
     572                  "                       parameter, if any. Default is boost-root.\n"
     573                  "--input-file         - the output of a bjam --dump-tests run. Default is std input.\n"
     574                  ;
    568575
    569   set_boost_root();
    570 
    571   boost_root.normalize();
    572  
    573   if ( argc > 1 && std::strcmp( argv[1], "--echo" ) == 0 )
     576  while ( argc > 1 )
    574577  {
    575     echo = true;
    576     --argc; ++argv;
    577   }
    578 
    579 
    580   if (argc > 1 && std::strcmp( argv[1], "--create-directories" ) == 0 )
    581   {
    582       create_dirs = true;
     578    if ( std::strcmp( argv[1], "--echo" ) == 0 )
     579    {
     580      echo = true;
    583581      --argc; ++argv;
    584   }
    585 
    586   if ( argc > 1 && std::strcmp( argv[1], "--v2" ) == 0 )
    587   {
    588     boost_build_v2 = true;
    589     --argc; ++argv;
    590   }
    591 
    592   if ( argc > 1 && std::strcmp( argv[1], "--v1" ) == 0 )
    593   {
    594     boost_build_v2 = false;
    595     --argc; ++argv;
    596   }
    597 
    598   if (argc > 1)
    599   {
     582    }
     583    else if ( std::strcmp( argv[1], "--create-directories" ) == 0 )
     584    {
     585        create_dirs = true;
     586        --argc; ++argv;
     587    }
     588    else if ( std::strcmp( argv[1], "--v2" ) == 0 )
     589    {
     590      boost_build_v2 = true;
     591      --argc; ++argv;
     592    }
     593    else if ( std::strcmp( argv[1], "--v1" ) == 0 )
     594    {
     595      boost_build_v2 = false;
     596      --argc; ++argv;
     597    }
     598    else if ( std::strcmp( argv[1], "--boost-root" ) == 0 )
     599    {
     600      --argc; ++argv;
     601      if ( argc == 1 )
     602      {
     603        std::cout << "Abort: option --boost-root requires a directory argument\n";
     604        std::exit(1);
     605      }
     606      boost_root = fs::path( argv[1], fs::native );
     607      if ( !boost_root.is_complete() )
     608        boost_root = ( fs::initial_path() / boost_root ).normalize();
     609     
     610      --argc; ++argv;
     611    }
     612    else if ( std::strcmp( argv[1], "--locate-root" ) == 0 )
     613    {
     614      --argc; ++argv;
     615      if ( argc == 1 )
     616      {
     617        std::cout << "Abort: option --locate-root requires a directory argument\n";
     618        std::exit(1);
     619      }
    600620      locate_root = fs::path( argv[1], fs::native );
    601621      if ( !locate_root.is_complete() )
    602622        locate_root = ( fs::initial_path() / locate_root ).normalize();
    603623     
    604624      --argc; ++argv;
    605   }
    606   else
     625    }
     626    else if ( std::strcmp( argv[1], "--input-file" ) == 0 )
     627    {
     628      --argc; ++argv;
     629      if ( argc == 1 )
     630      {
     631        std::cout << "Abort: option --input-file requires a filename argument\n";
     632        std::exit(1);
     633      }
     634      input = new std::ifstream(argv[1]);
     635      --argc; ++argv;
     636    }
     637  }
     638
     639  if ( boost_root.empty() )
    607640  {
    608       locate_root = boost_root;
     641    set_boost_root();
     642    boost_root.normalize();
    609643  }
     644  if ( locate_root.empty() )
     645  {
     646    locate_root = boost_root;
     647  }
     648  if ( input == 0 )
     649  {
     650    input = &std::cin;
     651  }
    610652
    611653  std::cout << "boost_root: " << boost_root.string() << '\n'
    612654            << "locate_root: " << locate_root.string() << '\n';
     
    617659  string content;
    618660  bool capture_lines = false;
    619661
    620   std::istream* input;
    621   if (argc > 1)
    622   {
    623       input = new std::ifstream(argv[1]);
    624   }
    625   else
    626   {
    627       input = &std::cin;
    628   }
    629 
    630662  // This loop looks at lines for certain signatures, and accordingly:
    631663  //   * Calls start_message() to start capturing lines. (start_message() will
    632664  //     automatically call stop_message() if needed.)