void process_ipp_file(const fs::path& file, bool positive_test) { std::cout << "Info: Scanning file: " << file.string() << std::endl; // our variables: std::string file_text; std::string macro_name; std::string namespace_name; fs::path positive_file; fs::path negative_file; // load the file into memory so we can scan it: fs::ifstream ifs(file); std::copy(std::istreambuf_iterator<char>(ifs), std::istreambuf_iterator<char>(), std::back_inserter(file_text)); ifs.close(); // scan for the macro name: boost::regex macro_regex("//\\s*MACRO\\s*:\\s*(\\w+)"); boost::smatch macro_match; if(boost::regex_search(file_text, macro_match, macro_regex)) { macro_name = macro_match[1]; macro_list.insert(macro_name); namespace_name = boost::regex_replace(file_text, macro_regex, "\\L$1", boost::format_first_only | boost::format_no_copy); } if(macro_name.empty()) { std::cout << "Error: no macro definition found in " << file.string(); } else { std::cout << "Info: Macroname: " << macro_name << std::endl; } // get the output filesnames: boost::regex file_regex("boost_([^.]+)\\.ipp"); positive_file = file.branch_path() / boost::regex_replace(file.leaf().string(), file_regex, "$1_pass.cpp"); negative_file = file.branch_path() / boost::regex_replace(file.leaf().string(), file_regex, "$1_fail.cpp"); write_test_file(positive_file, macro_name, namespace_name, file.leaf().string(), positive_test, true); write_test_file(negative_file, macro_name, namespace_name, file.leaf().string(), positive_test, false); // always create config_test data, // positive and negative tests go to separate streams, because for some // reason some compilers choke unless we put them in a particular order... std::ostream* pout = positive_test ? &config_test1a : &config_test1; *pout << "#if"; if(!positive_test) *pout << "n"; *pout << "def " << macro_name << "\n#include \"" << file.leaf().string() << "\"\n#else\nnamespace " << namespace_name << " = empty_boost;\n#endif\n"; config_test2 << " if(0 != " << namespace_name << "::test())\n" " {\n" " std::cerr << \"Failed test for " << macro_name << " at: \" << __FILE__ << \":\" << __LINE__ << std::endl;\n" " ++error_count;\n" " }\n"; // always generate the jamfile data: jamfile << "test-suite \"" << macro_name << "\" : \n" "[ run " << positive_file.leaf().string() << " <template>config_options ]\n" "[ compile-fail " << negative_file.leaf().string() << " <template>config_options ] ;\n"; jamfile_v2 << "test-suite \"" << macro_name << "\" : \n" "[ run ../" << positive_file.leaf().string() << " ]\n" "[ compile-fail ../" << negative_file.leaf().string() << " ] ;\n"; // Generate data for the Build-checks test file: build_config_test << "#ifdef TEST_" << macro_name << std::endl; build_config_test << "# include \"../test/" << file.leaf().string() << "\"\n"; build_config_test << "namespace test = " << namespace_name << ";\n#endif\n"; // Generate data for the build-checks Jamfile: static const boost::regex feature_regex("boost_(?:no|has)_(.*)"); std::string feature_name = boost::regex_replace(namespace_name, feature_regex, "\\1"); build_config_jamfile << "run-simple test_case.cpp : : : <define>TEST_" << macro_name << " : " << feature_name << " ;\n"; build_config_jamfile << "alias " << feature_name << " : " << feature_name << ".output ;\n"; build_config_jamfile << "explicit " << feature_name << " ;\n"; }
Filter::Filter( const std::string& str ) : m_str( str ) { { // option boost::smatch m; const char* e = "(?x)" "(^[\t]+)" "<Filter .+? >" ; if ( boost::regex_search( m_str, m, Utility::create_regex(e) ) ) { m_options = Utility::extract_options_from_string( m.str() ); m_indent = m.str(1); //Utility::output_options( std::cout, m_options ); } } // next level tabs size_t tabs = m_indent.size() + 1; { std::stringstream filter_regex_strm; filter_regex_strm << "(?x)" << "^[\t]{" << tabs << "} <Filter .+? >" << ".+?" << "^[\t]{" << tabs << "} </Filter>" ; boost::regex filter_regex( filter_regex_strm.str() ); boost::sregex_iterator it( m_str.begin(), m_str.end(), filter_regex ); boost::sregex_iterator end; for ( ; it != end; ++it ) { //std::cout << it->str() << std::endl; FilterPtr filter( new Filter(it->str()) ); m_filters.push_back( filter ); } } { std::stringstream file_regex_strm; file_regex_strm << "(?x)" << "^[\t]{" << tabs << "} <File \\b .+? >" << ".+?" << "^[\t]{" << tabs << "} </File>" ; boost::regex file_regex( file_regex_strm.str() ); boost::sregex_iterator it( m_str.begin(), m_str.end(), file_regex ); boost::sregex_iterator end; for ( ; it != end; ++it ) { //std::cout << it->str() << std::endl; FilePtr file( new File(it->str()) ); m_files.push_back( file ); } } }