Simplify build-time config checks.

These now simply reflect whatever config.hpp reports, and are therefore always in synch with the headers.
They are also now compile-time tests only, which means they function with cross compilers.
Fixes: https://svn.boost.org/trac/boost/ticket/12805.
This commit is contained in:
jzmaddock
2017-04-17 13:19:19 +01:00
parent 8acd1c464d
commit 79bd4b8acf
6 changed files with 826 additions and 625 deletions
+15 -12
View File
@@ -41,7 +41,7 @@ std::stringstream jamfile_v2;
std::stringstream build_config_test;
std::stringstream build_config_jamfile;
std::set<std::string> macro_list;
std::set<std::string> feature_list;
void write_config_info()
{
@@ -192,8 +192,9 @@ void write_build_tests()
time_t t = std::time(0);
ofs << "// This file was automatically generated on " << std::ctime(&t);
ofs << "// by libs/config/tools/generate.cpp\n" << copyright << std::endl;
ofs << "#include <boost/config.hpp>\n\n";
ofs << build_config_test.str() << std::endl;
ofs << "int main( int, char *[] )\n{\n" << " return test::test();\n}\n\n";
ofs << "int main( int, char *[] )\n{\n" << " return 0;\n}\n\n";
}
void write_build_check_jamfile()
@@ -209,13 +210,6 @@ void write_build_check_jamfile()
"# LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)\n\n"
"import modules ;\nimport path ; \n\n"
"\n"
"rule run-simple ( requirements * : target-name )\n"
"{\n"
" obj $(target-name)_obj : test_case.cpp : $(requirements) ;\n"
" explicit $(target-name)_obj ;\n"
" unit-test $(target-name) : $(target-name)_obj : $(requirements) ;\n"
" explicit $(target-name) ;\n"
"}\n\n"
;
ofs << build_config_jamfile.str() << std::endl;
}
@@ -288,13 +282,22 @@ void process_ipp_file(const fs::path& file, bool positive_test)
// 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";
if (positive_test)
{
build_config_test << "# ifndef " << macro_name << "\n# error \"Feature macro " << macro_name << " is not defined.\"\n# endif\n";
}
else
{
build_config_test << "# ifdef " << macro_name << "\n# error \"Defect macro " << macro_name << " is defined.\"\n# endif\n";
}
build_config_test << "#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 <define>TEST_" << macro_name << " : " << feature_name << " ;\n";
if(feature_list.find(feature_name) == feature_list.end())
build_config_jamfile << "obj " << feature_name << " : test_case.cpp : <define>TEST_" << macro_name << " ;\n";
feature_list.insert(feature_name);
}
int cpp_main(int argc, char* argv[])