⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 compiler_status.cpp

📁 Boost provides free peer-reviewed portable C++ source libraries. We emphasize libraries that work
💻 CPP
📖 第 1 页 / 共 3 页
字号:
    if ( compile_time ) target += "<br> Compile time:";    if ( run_time ) target += "<br> Run time:";    target += "</td>";    target += "<td>" + test_type + "</td>";    bool no_warn_save = no_warn;    //if ( test_type.find( "fail" ) != string::npos ) no_warn = true;    // for each compiler, generate <td>...</td> html    bool anything_to_report = false;    int compiler = 0;    for ( std::vector<string>::const_iterator itr=toolsets.begin();      itr != toolsets.end(); ++itr, ++compiler )    {      anything_to_report |= do_cell( compiler, lib_name, test_dir, test_type, test_name, *itr, target,        always_show_run_output );    }    target += "</tr>";    if ( ignore_pass && !anything_to_report ) target.erase( row_start_pos );    no_warn = no_warn_save;  }//  do_rows_for_sub_tree  ----------------------------------------------------//  void do_rows_for_sub_tree(    const fs::path & bin_dir, std::vector<string> & results )  {    for ( fs::directory_iterator itr( bin_dir ); itr != end_itr; ++itr )    {      if ( fs::is_directory( *itr )        && itr->string().find( ".test" ) == (itr->string().size()-5) )      {        results.push_back( std::string() );         do_row( *itr,                itr->leaf().substr( 0, itr->leaf().size()-5 ),                results[results.size()-1] );      }    }  }//  do_table_body  -----------------------------------------------------------//  void do_table_body( const fs::path & bin_dir )  {    // rows are held in a vector so they can be sorted, if desired.    std::vector<string> results;    // do primary bin directory    do_rows_for_sub_tree( bin_dir, results );    // do subinclude bin directories    jamfile.clear();    jamfile.seekg(0);    string line;    while( std::getline( jamfile, line ) )    {      bool v2(false);      string::size_type pos( line.find( "subinclude" ) );      if ( pos == string::npos ) {        pos = line.find( "build-project" );        v2 = true;      }      if ( pos != string::npos        && line.find( '#' ) > pos )      {        if (v2)          pos = line.find_first_not_of( " \t./", pos+13 );        else          pos = line.find_first_not_of( " \t./", pos+10 );              if ( pos == string::npos ) continue;        string subinclude_bin_dir(          line.substr( pos, line.find_first_of( " \t", pos )-pos ) );        fs::path bin_path = find_bin_path(subinclude_bin_dir);        if (!bin_path.empty())          do_rows_for_sub_tree( bin_path, results );      }    }    std::sort( results.begin(), results.end() );    for ( std::vector<string>::iterator v(results.begin());      v != results.end(); ++v )      { report << *v << "\n"; }  }//  do_table  ----------------------------------------------------------------//  void do_table()  {    // Find test result locations, trying:    // - Boost.Build V1 location with ALL_LOCATE_TARGET    // - Boost.Build V2 location with top-lelve "build-dir"     // - Boost.Build V1 location without ALL_LOCATE_TARGET    string relative( fs::initial_path().string() );    relative.erase( 0, boost_root.string().size()+1 );        fs::path bin_path = find_bin_path(relative);    report << "<table border=\"1\" cellspacing=\"0\" cellpadding=\"5\">\n";    // generate the column headings    report << "<tr><td>Library</td><td>Test Name</td>\n"      "<td><a href=\"compiler_status.html#test-type\">Test Type</a></td>\n";    fs::directory_iterator itr( bin_path );    while ( itr != end_itr       && ((itr->string().find( ".test" ) != (itr->string().size()-5))      || !fs::is_directory( *itr )))      ++itr; // bypass chaff    if ( itr != end_itr )    {      fs::directory_iterator compiler_itr( *itr );      if ( specific_compiler.empty() )        std::clog << "Using " << itr->string() << " to determine compilers\n";      for (; compiler_itr != end_itr; ++compiler_itr )      {        if ( fs::is_directory( *compiler_itr )  // check just to be sure          && compiler_itr->leaf() != "test" ) // avoid strange directory (Jamfile bug?)        {          if ( specific_compiler.size() != 0            && specific_compiler != compiler_itr->leaf() ) continue;          toolsets.push_back( compiler_itr->leaf() );          string desc( compiler_desc( compiler_itr->leaf() ) );          string vers( version_desc( compiler_itr->leaf() ) );          report << "<td>"               << (desc.size() ? desc : compiler_itr->leaf())               << (vers.size() ? (string( "<br>" ) + vers ) : string( "" ))               << "</td>\n";          error_count.push_back( 0 );        }      }    }    report << "</tr>\n";    // now the rest of the table body    do_table_body( bin_path );    // error total row    report << "<tr> <td> &nbsp;</td><td>Number of Failures</td><td> &nbsp;</td>\n";    // for each compiler, generate <td>...</td> html    int compiler = 0;    for ( std::vector<string>::const_iterator itr=toolsets.begin();      itr != toolsets.end(); ++itr, ++compiler )    {      report << "<td align=\"center\">" << error_count[compiler] << "</td>\n";    }    report << "</tr>\n</table>\n";  }} // unnamed namespace//  main  --------------------------------------------------------------------//#define BOOST_NO_CPP_MAIN_SUCCESS_MESSAGE#include <boost/test/included/prg_exec_monitor.hpp>int cpp_main( int argc, char * argv[] ) // note name!{  fs::path comment_path;  while ( argc > 1 && *argv[1] == '-' )  {    if ( argc > 2 && std::strcmp( argv[1], "--compiler" ) == 0 )      { specific_compiler = argv[2]; --argc; ++argv; }    else if ( argc > 2 && std::strcmp( argv[1], "--locate-root" ) == 0 )      { locate_root = fs::path( argv[2], fs::native ); --argc; ++argv; }    else if ( argc > 2 && std::strcmp( argv[1], "--comment" ) == 0 )      { comment_path = fs::path( argv[2], fs::native ); --argc; ++argv; }    else if ( argc > 2 && std::strcmp( argv[1], "--notes" ) == 0 )      { notes_path = fs::path( argv[2], fs::native ); --argc; ++argv; }    else if ( argc > 2 && std::strcmp( argv[1], "--notes-map" ) == 0 )      { notes_map_path = fs::path( argv[2], fs::native ); --argc; ++argv; }    else if ( std::strcmp( argv[1], "--ignore-pass" ) == 0 ) ignore_pass = true;    else if ( std::strcmp( argv[1], "--no-warn" ) == 0 ) no_warn = true;    else if ( std::strcmp( argv[1], "--v1" ) == 0 ) boost_build_v2 = false;    else if ( std::strcmp( argv[1], "--v2" ) == 0 ) boost_build_v2 = true;    else if ( argc > 2 && std::strcmp( argv[1], "--jamfile" ) == 0)      { jamfile_path = fs::path( argv[2], fs::native ); --argc; ++argv; }    else if ( std::strcmp( argv[1], "--compile-time" ) == 0 ) compile_time = true;    else if ( std::strcmp( argv[1], "--run-time" ) == 0 ) run_time = true;    else { std::cerr << "Unknown option: " << argv[1] << "\n"; argc = 1; }    --argc;    ++argv;  }  if ( argc != 3 && argc != 4 )  {    std::cerr <<      "Usage: compiler_status [options...] boost-root status-file [links-file]\n"      "  boost-root is the path to the boost tree root directory.\n"      "  status-file and links-file are paths to the output files.\n"      "Must be run from directory containing Jamfile\n"      "  options: --compiler name     Run for named compiler only\n"      "           --ignore-pass       Do not report tests which pass all compilers\n"      "           --no-warn           Warnings not reported if test passes\n"      "           --locate-root path  Path to ALL_LOCATE_TARGET for bjam;\n"      "                               default boost-root.\n"      "           --comment path      Path to file containing HTML\n"      "                               to be copied into status-file.\n"      "           --notes path        Path to file containing HTML\n"      "                               to be copied into status-file.\n"      "           --notes-map path    Path to file of toolset/test,n lines, where\n"      "                               n is number of note bookmark in --notes file.\n"      "           --jamfile path      Path to Jamfile. By default \"Jamfile\".\n"      "           --v1                Assume Boost.Build version 1.\n"      "           --v2                Assume Boost.Build version 2. (default)\n"      "           --ignore-pass       Ignore passing tests.\n"      "           --no-warn           Do not report warnings.\n"      "           --compile-time      Show compile time.\n"      "           --run-time          Show run time.\n"      "Example: compiler_status --compiler gcc /boost-root cs.html cs-links.html\n"      "Note: Only the leaf of the links-file path and --notes file string are\n"      "used in status-file HTML links. Thus for browsing, status-file,\n"      "links-file, and --notes file must all be in the same directory.\n"      ;    return 1;  }  boost_root = fs::path( argv[1], fs::native );  if ( locate_root.empty() ) locate_root = boost_root;    if (jamfile_path.empty())    if (boost_build_v2)      jamfile_path = "Jamfile.v2";    else      jamfile_path = "Jamfile";  jamfile_path = fs::complete( jamfile_path, fs::initial_path() );  jamfile.open( jamfile_path );  if ( !jamfile )  {    std::cerr << "Could not open Jamfile: " << jamfile_path.native_file_string() << std::endl;    return 1;  }  report.open( fs::path( argv[2], fs::native ) );  if ( !report )  {    std::cerr << "Could not open report output file: " << argv[2] << std::endl;    return 1;  }  if ( argc == 4 )  {    fs::path links_path( argv[3], fs::native );    links_name = links_path.leaf();    links_file.open( links_path );    if ( !links_file )    {      std::cerr << "Could not open links output file: " << argv[3] << std::endl;      return 1;    }  }  else no_links = true;  build_notes_bookmarks();  char run_date[128];  std::time_t tod;  std::time( &tod );  std::strftime( run_date, sizeof(run_date),    "%X UTC, %A %d %B %Y", std::gmtime( &tod ) );  std::string rev = revision( boost_root );  report << "<html>\n"          "<head>\n"          "<title>Boost Test Results</title>\n"          "</head>\n"          "<body bgcolor=\"#ffffff\" text=\"#000000\">\n"          "<table border=\"0\">\n"          "<tr>\n"          "<td><img border=\"0\" src=\"http://www.boost.org/boost.png\" width=\"277\" "          "height=\"86\"></td>\n"          "<td>\n"          "<h1>Boost Test Results - " + platform_desc() + "</h1>\n"          "<b>Run</b> "       << run_date;  if ( !rev.empty() ) report << ", <b>Revision</b> " << rev;  report << "\n";    if ( compile_time )    report << "<p>Times reported are elapsed wall clock time in seconds.</p>\n";  if ( !comment_path.empty() )  {    fs::ifstream comment_file( comment_path );    if ( !comment_file )    {      std::cerr << "Could not open \"--comment\" input file: " << comment_path.string() << std::endl;      return 1;    }    char c;    while ( comment_file.get( c ) ) { report.put( c ); }  }  report << "</td>\n</table>\n<br>\n";  if ( !no_links )  {    links_file      << "<html>\n"         "<head>\n"         "<title>Boost Test Details</title>\n"         "</head>\n"         "<body bgcolor=\"#ffffff\" text=\"#000000\">\n"         "<table border=\"0\">\n"         "<tr>\n"         "<td><img border=\"0\" src=\"http://www.boost.org/boost.png\" width=\"277\" "         "height=\"86\"></td>\n"         "<td>\n"         "<h1>Boost Test Details - " + platform_desc() + "</h1>\n"         "<b>Run Date:</b> "      << run_date;    if ( !rev.empty() ) links_file << ", <b>Revision</b> " << rev;    links_file << "\n</td>\n</table>\n<br>\n";  }  do_table();  if ( load_notes_html() ) report << notes_html << "\n";  report << "</body>\n"          "</html>\n"          ;  if ( !no_links )  {    links_file      << "</body>\n"         "</html>\n"         ;  }  return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -