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

📄 compiler_status.cpp

📁 Boost provides free peer-reviewed portable C++ source libraries. We emphasize libraries that work
💻 CPP
📖 第 1 页 / 共 3 页
字号:
//  Generate Compiler Status HTML from jam regression test output  -----------////  Copyright Beman Dawes 2002.  Distributed under the Boost//  Software License, Version 1.0. (See accompanying file//  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)//  See http://www.boost.org/tools/regression/ for documentation./*******************************************************************************    This program was designed to work unchanged on all platforms and    configurations.  All output which is platform or configuration dependent    is obtained from external sources such as the .xml file from    process_jam_log execution, the tools/build/xxx-tools.jam files, or the    output of the config_info tests.    Please avoid adding platform or configuration dependencies during    program maintenance.*******************************************************************************/#include "boost/config.hpp"#include "boost/filesystem/operations.hpp"#include "boost/filesystem/fstream.hpp"#include "detail/tiny_xml.hpp"namespace fs = boost::filesystem;namespace xml = boost::tiny_xml;#include <cstdlib>  // for abort, exit#include <cctype>   // for toupper#include <string>#include <vector>#include <set>#include <map>#include <algorithm>#include <iostream>#include <fstream>#include <ctime>#include <stdexcept>#include <cassert>using std::string;const string pass_msg( "Pass" );const string warn_msg( "<i>Warn</i>" );const string fail_msg( "<font color=\"#FF0000\"><i>Fail</i></font>" );const string note_msg( "<sup>*</sup>" );const string missing_residue_msg( "<i>Missing</i>" );const std::size_t max_compile_msg_size = 10000;namespace{  fs::path boost_root;  // boost-root complete path  fs::path locate_root; // locate-root (AKA ALL_LOCATE_TARGET) complete path  bool compile_time;  bool run_time;  bool ignore_pass;  bool no_warn;  bool no_links;  bool boost_build_v2 = true;  fs::path jamfile_path;  fs::directory_iterator end_itr;  // It's immportant for reliability that we find the same compilers for each  // test, and that they match the column header.  So save the names at the  // time column headings are generated.  std::vector<string> toolsets;  fs::ifstream jamfile;  fs::ofstream report;  fs::ofstream links_file;  string links_name;  fs::path notes_path;  string notes_html;  fs::path notes_map_path;  typedef std::multimap< string, string > notes_map; // key is test_name-toolset,                                                // value is note bookmark  notes_map notes;  string specific_compiler; // if running on one toolset only  const string empty_string;  std::vector<int> error_count;  // prefix for library and test hyperlink prefix  string cvs_root ( "http://boost.cvs.sourceforge.net/" );  string url_prefix_dir_view( cvs_root + "boost/boost" );  string url_prefix_checkout_view( cvs_root + "*checkout*/boost/boost" );  string url_suffix_text_view( "?view=markup&rev=HEAD" );//  get revision number (as a string) if boost_root is svn working copy  -----//  string revision( const fs::path & boost_root )  {    string rev;    fs::path entries( boost_root / ".svn" / "entries" );    fs::ifstream entries_file( entries );    if ( entries_file )    {      std::getline( entries_file, rev );      std::getline( entries_file, rev );      std::getline( entries_file, rev );      std::getline( entries_file, rev );  // revision number as a string    }    return rev;  }//  build notes_bookmarks from notes HTML  -----------------------------------//  void build_notes_bookmarks()  {    if ( notes_map_path.empty() ) return;    fs::ifstream notes_map_file( notes_map_path );    if ( !notes_map_file )    {      std::cerr << "Could not open --notes-map input file: " << notes_map_path.string() << std::endl;      std::exit( 1 );    }    string line;    while( std::getline( notes_map_file, line ) )    {      string::size_type pos = 0;      if ( (pos = line.find( ',', pos )) == string::npos ) continue;      string key(line.substr( 0, pos ) );      string bookmark( line.substr( pos+1 ) );//      std::cout << "inserting \"" << key << "\",\"" << bookmark << "\"\n";      notes.insert( notes_map::value_type( key, bookmark ) );    }  }//  load_notes_html  ---------------------------------------------------------//  bool load_notes_html()  {    if ( notes_path.empty() ) return false;    fs::ifstream notes_file( notes_path );    if ( !notes_file )    {      std::cerr << "Could not open --notes input file: " << notes_path.string() << std::endl;      std::exit( 1 );    }    string line;    bool in_body( false );    while( std::getline( notes_file, line ) )    {      if ( in_body && line.find( "</body>" ) != string::npos ) in_body = false;      if ( in_body ) notes_html += line;      else if ( line.find( "<body>" ) ) in_body = true;    }    return true;  }//  relative path between two paths  -----------------------------------------//  void relative_path( const fs::path & from, const fs::path & to,    fs::path & target )  {    if ( from.string().size() <= to.string().size() ) return;    target /= "..";    relative_path( from.branch_path(), to, target );    return;  }//  extract object library name from target directory string  ----------------//  string extract_object_library_name( const string & s )  {    string t( s );    string::size_type pos = t.find( "/build/" );    if ( pos != string::npos ) pos += 7;    else if ( (pos = t.find( "/test/" )) != string::npos ) pos += 6;    else return "";    return t.substr( pos, t.find( "/", pos ) - pos );  }//  find_file  ---------------------------------------------------------------////  given a directory to recursively search  bool find_file( const fs::path & dir_path, const string & name,    fs::path & path_found, const string & ignore_dir_named="" )  {    if ( !fs::exists( dir_path ) ) return false;    for ( fs::directory_iterator itr( dir_path ); itr != end_itr; ++itr )      if ( fs::is_directory( *itr )        && itr->leaf() != ignore_dir_named )      {        if ( find_file( *itr, name, path_found ) ) return true;      }      else if ( itr->leaf() == name )      {        path_found = *itr;        return true;      }    return false;  }//  platform_desc  -----------------------------------------------------------//  string platform_desc()  {    string result = BOOST_PLATFORM;    result[0] = std::toupper( result[0] );    return result;  }//  version_desc  ------------------------------------------------------------////  from locate-root/status/bin/config_info.test/xxx/.../config_info.output  string version_desc( const string & compiler_name )  {    string result;    fs::path dot_output_path;    if ( find_file( locate_root / "bin/boost/status/config_info.test"      / compiler_name, "config_info.output", dot_output_path )      || find_file( locate_root / "status/bin/config_info.test"      / compiler_name, "config_info.output", dot_output_path ) )    {      fs::ifstream file( dot_output_path );      if ( file )      {        if( std::getline( file, result ) )        {          string::size_type pos = result.find( "version " );          if ( pos != string::npos )          {            result.erase( 0, pos+8 );          }          else result.clear();        }      }    }    return result;  }//  compiler_desc  -----------------------------------------------------------////  from boost-root/tools/build/xxx-tools.jam  string compiler_desc( const string & compiler_name )  {    string result;    fs::path tools_path( boost_root / "tools/build/v1" / (compiler_name      + "-tools.jam") );    if ( !fs::exists( tools_path ) )      tools_path = boost_root / "tools/build" / (compiler_name + "-tools.jam");    fs::ifstream file( tools_path );    if ( file )    {      while( std::getline( file, result ) )      {        if ( result.substr( 0, 3 ) == "#//" )        {          result.erase( 0, 3 );          return result;        }      }      result.clear();    }    return result;  }//  target_directory  --------------------------------------------------------////  this amounts to a request to find a unique leaf directory  fs::path target_directory( const fs::path & root )  {    if ( !fs::exists( root ) ) return fs::path("no-such-path");    fs::path child;    for ( fs::directory_iterator itr( root ); itr != end_itr; ++itr )    {      if ( fs::is_directory( *itr ) )      {        // SunCC creates an internal subdirectory everywhere it writes        // object files.  This confuses the target_directory() algorithm.        // This patch ignores the SunCC internal directory. Jens Maurer        if ( (*itr).leaf() == "SunWS_cache" ) continue;        // SGI does something similar for template instantiations. Jens Maurer        if(  (*itr).leaf() == "ii_files" ) continue;         if ( child.empty() ) child = *itr;        else        {          std::cout << "Warning: only first of two target possibilities will be reported for: \n "            << root.string() << ": " << child.leaf()            << " and " << (*itr).leaf() << "\n";        }      }    }    if ( child.empty() ) return root; // this dir has no children    return target_directory( child );  }//  element_content  ---------------------------------------------------------//  const string & element_content(    const xml::element & root, const string & name )  {    static string empty_string;    xml::element_list::const_iterator itr;    for ( itr = root.elements.begin();          itr != root.elements.end() && (*itr)->name != name;          ++itr ) {}    return itr != root.elements.end() ? (*itr)->content : empty_string;  }//  find_element  ------------------------------------------------------------//  const xml::element empty_element;  const xml::element & find_element(    const xml::element & root, const string & name )  {    xml::element_list::const_iterator itr;    for ( itr = root.elements.begin();          itr != root.elements.end() && (*itr)->name != name;          ++itr ) {}    return itr != root.elements.end() ? *((*itr).get()) : empty_element;  }//  attribute_value  ----------------------------------------------------------//const string & attribute_value( const xml::element & element,                                const string & attribute_name ){  static const string empty_string;  xml::attribute_list::const_iterator atr;  for ( atr = element.attributes.begin();        atr != element.attributes.end() && atr->name != attribute_name;        ++atr ) {}  return atr == element.attributes.end() ? empty_string : atr->value;}//  find_bin_path  -----------------------------------------------------------//// Takes a relative path from boost root to a Jamfile.// Returns the directory where the build targets from// that Jamfile are located. If not found, emits a warning // and returns empty path.

⌨️ 快捷键说明

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