Add new build-time configuration feature.

This commit is contained in:
jzmaddock
2014-06-05 18:55:12 +01:00
parent 23cf56a53f
commit dad7bc5b30
15 changed files with 1421 additions and 9 deletions
+38
View File
@@ -38,6 +38,8 @@ std::stringstream config_test1a;
std::stringstream config_test2;
std::stringstream jamfile;
std::stringstream jamfile_v2;
std::stringstream build_config_test;
std::stringstream build_config_jamfile;
std::set<std::string> macro_list;
@@ -184,6 +186,31 @@ void write_test_file(const fs::path& file,
}
}
void write_build_tests()
{
fs::ofstream ofs(config_path / ".." / "checks" / "test_case.cpp");
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 << build_config_test.str() << std::endl;
ofs << "int main( int, char *[] )\n{\n" << " return test::test();\n}\n\n";
}
void write_build_check_jamfile()
{
fs::ofstream ofs(config_path / ".." / "checks" / "Jamfile.v2");
time_t t = std::time(0);
ofs << "#\n# *** DO NOT EDIT THIS FILE BY HAND ***\n"
"# This file was automatically generated on " << std::ctime(&t);
ofs << "# by libs/config/tools/generate.cpp\n"
"# Copyright John Maddock.\n"
"# Use, modification and distribution are subject to the \n"
"# Boost Software License, Version 1.0. (See accompanying file \n"
"# LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)\n\n"
"import modules ;\nimport path ; \n\n";
ofs << build_config_jamfile.str() << std::endl;
}
void process_ipp_file(const fs::path& file, bool positive_test)
{
std::cout << "Info: Scanning file: " << file.string() << std::endl;
@@ -250,6 +277,15 @@ void process_ipp_file(const fs::path& file, bool positive_test)
"[ 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 test_case.cpp : : : <define>TEST_" << macro_name << " : " << feature_name << " ;\nexplicit " << feature_name << " ;\n";
}
int cpp_main(int argc, char* argv[])
@@ -285,6 +321,8 @@ int cpp_main(int argc, char* argv[])
write_config_test();
write_jamfile_v2();
write_config_info();
write_build_tests();
write_build_check_jamfile();
return 0;
}