Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r73474 - sandbox/tools/profile_templates2
From: dsaritz_at_[hidden]
Date: 2011-08-01 09:46:59


Author: psiha
Date: 2011-08-01 09:46:57 EDT (Mon, 01 Aug 2011)
New Revision: 73474
URL: http://svn.boost.org/trac/boost/changeset/73474

Log:
Polished the CPP preprocesor and updated profiler.cmake to use it.
Minor other changes.
Text files modified:
   sandbox/tools/profile_templates2/preprocess.cpp | 6 ++----
   sandbox/tools/profile_templates2/profiler.cmake | 17 ++++++++++-------
   2 files changed, 12 insertions(+), 11 deletions(-)

Modified: sandbox/tools/profile_templates2/preprocess.cpp
==============================================================================
--- sandbox/tools/profile_templates2/preprocess.cpp (original)
+++ sandbox/tools/profile_templates2/preprocess.cpp 2011-08-01 09:46:57 EDT (Mon, 01 Aug 2011)
@@ -29,7 +29,6 @@
 #include <cassert>
 #include <iterator>
 #include <iostream>
-#include <fstream>
 //------------------------------------------------------------------------------
 
 namespace regex
@@ -170,8 +169,7 @@
         cregex const main_regex( (s1= ignored) | (s2=keep( class_header | function_header )) | (s3='{') | (s4='}') );
         match_results<char const *> search_results;
 
- std::ofstream output( "preprocessed.cpp" );
- output << "#include <template_profiler.hpp>\n" << std::endl;
+ std::cout << "#include <template_profiler.hpp>\n" << std::endl;
 
         // Implementation note:
         // The whole file has to be searched at once in order to handle class/
@@ -179,7 +177,7 @@
         // (01.08.2011.) (Domagoj Saric)
         regex_replace
         (
- std::ostream_iterator<char>( output ),
+ std::ostream_iterator<char>( std::cout ),
             input.begin(),
             input.end(),
             main_regex,

Modified: sandbox/tools/profile_templates2/profiler.cmake
==============================================================================
--- sandbox/tools/profile_templates2/profiler.cmake (original)
+++ sandbox/tools/profile_templates2/profiler.cmake 2011-08-01 09:46:57 EDT (Mon, 01 Aug 2011)
@@ -20,11 +20,13 @@
 set_property(TARGET template.profiler.filter PROPERTY RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/tools)
 
 INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
+ADD_EXECUTABLE(template.profiler.preprocess ${PROFILER_PATH}/preprocess.cpp)
+set_property(TARGET template.profiler.preprocess PROPERTY RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/tools)
 ADD_EXECUTABLE(template.profiler.postprocess ${PROFILER_PATH}/postprocess.cpp)
-if (NOT MSVC)
+set_property(TARGET template.profiler.postprocess PROPERTY RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/tools)
+if (NOT MSVC) # Use autolink for MSVC
     target_link_libraries(template.profiler.postprocess ${Boost_LIBRARIES})
 endif()
-set_property(TARGET template.profiler.postprocess PROPERTY RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/tools)
 
 ################################################################################
 # Make a function to compile foo and profile it
@@ -38,23 +40,24 @@
 
   get_directory_property( preprocessor_definitions COMPILE_DEFINITIONS )
   foreach(preprocessor_definition ${preprocessor_definitions})
- list(APPEND profiler_cxx_flags -D${preprocessor_definition})
+ set(profiler_cxx_flags "${profiler_cxx_flags} -D${preprocessor_definition}")
   endforeach()
 
   get_directory_property(INCLUDES INCLUDE_DIRECTORIES)
   foreach(INCLUDE ${INCLUDES})
- list(APPEND INCLUDE_DIRECTORIES -I"${INCLUDE}")
+ set(INCLUDE_DIRECTORIES "${INCLUDE_DIRECTORIES} -I\"${INCLUDE}\"" )
   endforeach()
-
+ message( "${CMAKE_CXX_COMPILER} ${profiler_cxx_flags} ${INCLUDE_DIRECTORIES} -E \"${CMAKE_CURRENT_SOURCE_DIR}/${src}\" > ${target}.compiler.preprocessed.cpp && \"${PROJECT_BINARY_DIR}/tools/${CMAKE_CFG_INTDIR}/template.profiler.preprocess\" ${target}.compiler.preprocessed.cpp > ${target}.preprocessed.cpp" )
   add_custom_command(OUTPUT ${target}.preprocessed.cpp
- COMMAND ${CMAKE_CXX_COMPILER} ${profiler_cxx_flags} ${INCLUDE_DIRECTORIES} -E ${CMAKE_CURRENT_SOURCE_DIR}/${src}
- | ${PERL_EXECUTABLE} ${PROFILER_PATH}/preprocess.pl > ${target}.preprocessed.cpp
+ COMMAND ${CMAKE_CXX_COMPILER} ${profiler_cxx_flags} ${INCLUDE_DIRECTORIES} -E "${CMAKE_CURRENT_SOURCE_DIR}/${src}" > ${target}.compiler.preprocessed.cpp
+ && \"${PROJECT_BINARY_DIR}/tools/${CMAKE_CFG_INTDIR}/template.profiler.preprocess\" ${target}.compiler.preprocessed.cpp > ${target}.preprocessed.cpp
                      DEPENDS ${src}
                    )
   add_custom_command(OUTPUT ${target}.template_profile
                      COMMAND ${CMAKE_CXX_COMPILER} ${profiler_cxx_flags} -I${PROFILER_PATH} ${INCLUDE_DIRECTORIES} -c -DPROFILE_TEMPLATES ${target}.preprocessed.cpp 2>&1
                            | \"${PROJECT_BINARY_DIR}/tools/${CMAKE_CFG_INTDIR}/template.profiler.filter\" ${ARGN} > ${target}.filtered && \"${PROJECT_BINARY_DIR}/tools/${CMAKE_CFG_INTDIR}/template.profiler.postprocess\" ${ARGN} ${target}.filtered > ${target}.template_profile
                      DEPENDS ${target}.preprocessed.cpp
+ template.profiler.preprocess
                              template.profiler.filter
                              template.profiler.postprocess
                     )


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