|
Boost-Commit : |
From: steven_at_[hidden]
Date: 2008-06-10 10:02:39
Author: steven_watanabe
Date: 2008-06-10 10:02:39 EDT (Tue, 10 Jun 2008)
New Revision: 46293
URL: http://svn.boost.org/trac/boost/changeset/46293
Log:
pipe the compiler's output through a filter to prevent it from getting too large
Text files modified:
sandbox/tools/profile_templates/src/Jamfile.v2 | 3 ++-
sandbox/tools/profile_templates/src/postprocess.cpp | 10 ++++++++--
sandbox/tools/profile_templates/template-profile.jam | 36 +++++++++++++++++++++++++++++++++---
sandbox/tools/profile_templates/test/test.cpp | 1 +
4 files changed, 44 insertions(+), 6 deletions(-)
Modified: sandbox/tools/profile_templates/src/Jamfile.v2
==============================================================================
--- sandbox/tools/profile_templates/src/Jamfile.v2 (original)
+++ sandbox/tools/profile_templates/src/Jamfile.v2 2008-06-10 10:02:39 EDT (Tue, 10 Jun 2008)
@@ -10,4 +10,5 @@
project src : :
requirements <include>$(BOOST_ROOT) <link>static ;
-exe postprocess : postprocess.cpp $(BOOST_ROOT)/libs/regex/build//boost_regex ;
+exe postprocess : postprocess.cpp $(BOOST_ROOT)/libs/regex/build//boost_regex : <variant>release ;
+exe filter : filter.cpp $(BOOST_ROOT)/libs/regex/build//boost_regex : <variant>release ;
Modified: sandbox/tools/profile_templates/src/postprocess.cpp
==============================================================================
--- sandbox/tools/profile_templates/src/postprocess.cpp (original)
+++ sandbox/tools/profile_templates/src/postprocess.cpp 2008-06-10 10:02:39 EDT (Tue, 10 Jun 2008)
@@ -5,6 +5,7 @@
#include <exception>
#include <iterator>
#include <algorithm>
+#include <iomanip>
#ifdef _MSC_VER
@@ -22,11 +23,12 @@
struct print {
int* cummulative;
+ int width;
typedef void result_type;
template<class T>
void operator()(const T& t) {
*cummulative += t.second;
- std::cout << t.first << ' ' << t.second << " " << *cummulative << std::endl;
+ std::cout << std::setw(width) << t.first << std::setw(10) << t.second << std::setw(10) << *cummulative << std::endl;
}
};
@@ -41,9 +43,11 @@
std::map<std::string, int> messages;
std::string line;
int total_matches = 0;
+ std::ptrdiff_t max_match_length = 0;
while(std::getline(std::cin, line)) {
boost::smatch match;
if(boost::regex_match(line, match, warning_message)) {
+ max_match_length = (std::max)(max_match_length, match[1].length());
++messages[match[1]];
++total_matches;
}
@@ -52,6 +56,8 @@
std::sort(copy.begin(), copy.end(), compare());
std::cout << "Total instantiations: " << total_matches << std::endl;
int cummulative = 0;
- print p = { &cummulative };
+ std::cout << std::setw(max_match_length) << "Location" << std::setw(10) << "count" << std::setw(10) << "cum." << std::endl;
+ std::cout << std::setfill('-') << std::setw(max_match_length + 20) << '-' << std::setfill(' ') << std::endl;
+ print p = { &cummulative, max_match_length };
std::for_each(copy.begin(), copy.end(), p);
}
Modified: sandbox/tools/profile_templates/template-profile.jam
==============================================================================
--- sandbox/tools/profile_templates/template-profile.jam (original)
+++ sandbox/tools/profile_templates/template-profile.jam 2008-06-10 10:02:39 EDT (Tue, 10 Jun 2008)
@@ -27,9 +27,10 @@
generators.register-standard template-profile.preprocess : CPP : INSTRUMENTED_TEMPLATE_PREPROCESSED_CPP ;
feature.feature <template-profile-toolset> : msvc gcc : free ;
+feature.feature <template-profile-filter> : : path incidental ;
toolset.flags template-profile.preprocess PREPROCESS-ACTION <template-profile-toolset>msvc : cl /E ;
-toolset.flags template-profile.preprocess PREPROCESS-ACTION <template-profile-toolset>gcc : g++ -E ;
+toolset.flags template-profile.preprocess PREPROCESS-ACTION <template-profile-toolset>gcc : g++-4.3.0 -E ;
toolset.flags template-profile.preprocess INCLUDE-COMMAND <template-profile-toolset>msvc : /I ;
toolset.flags template-profile.preprocess INCLUDE-COMMAND <template-profile-toolset>gcc : -I ;
toolset.flags template-profile.preprocess INCLUDES <include> ;
@@ -41,6 +42,9 @@
class warn-generator : generator {
import template-profile ;
+ import targets ;
+ import path ;
+ import modules ;
rule __init__ ( ) {
generator.__init__ template-profile.build-generic : INSTRUMENTED_TEMPLATE_PREPROCESSED_CPP : RAW_TEMPLATE_PROFILE ;
@@ -59,7 +63,32 @@
errors.error unrecognized toolset $(toolset) ;
}
local self-dir = [ modules.peek template-profile : module-location ] ;
- local new-properties = [ $(properties).add-raw <template-profile-toolset>$(toolset) <include>$(self-dir) ] ;
+
+ current_path = [ modules.peek template-profile : module-location ] ;
+ local filter-main-target = [ targets.resolve-reference [ path.join $(current_path) src ] : $(project) ] ;
+ filter-main-target = [ $(filter-main-target[1]).main-target filter ] ;
+ local filter-binary-dependencies = [ $(filter-main-target).generate [ $(properties).propagated ] ] ;
+ filter-binary-dependencies = $(filter-binary-dependencies[2-]) ;
+ local filter-binary = ;
+
+ for local target in $(filter-binary-dependencies) {
+ if [ $(target).type ] = EXE {
+ filter-binary =
+ [ path.native
+ [ path.join
+ [ $(target).path ]
+ [ $(target).name ]
+ ]
+ ] ;
+ }
+ }
+
+ if ! $(filter-binary) {
+ errors.error Could not find filter binary ;
+ }
+
+ local new-properties = [ $(properties).add-raw <template-profile-toolset>$(toolset) <dependency>$(filter-binary-dependencies) <template-profile-filter>$(filter-binary) <include>$(self-dir) ] ;
+
return [ generator.run $(project) $(name) : $(new-properties) : $(sources) : $(multiple) ] ;
}
}
@@ -73,9 +102,10 @@
toolset.flags template-profile.build-generic INCLUDE-COMMAND <template-profile-toolset>gcc : -I ;
toolset.flags template-profile.build-generic INCLUDES <include> ;
+toolset.flags template-profile.build-generic FILTER <template-profile-filter> ;
actions build-generic {
- $(INVOCATION-COMMAND) "$(INCLUDE-COMMAND)$(INCLUDES)" "$(>)" >"$(<)" 2>&1
+ $(INVOCATION-COMMAND) "$(INCLUDE-COMMAND)$(INCLUDES)" "$(>)" 2>&1 | "$(FILTER)" >"$(<)"
}
class final-profile-generator : generator {
Modified: sandbox/tools/profile_templates/test/test.cpp
==============================================================================
--- sandbox/tools/profile_templates/test/test.cpp (original)
+++ sandbox/tools/profile_templates/test/test.cpp 2008-06-10 10:02:39 EDT (Tue, 10 Jun 2008)
@@ -2,4 +2,5 @@
int main() {
X<int> x;
+ X<char> x;
}
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk