mirror of
https://github.com/boostorg/config.git
synced 2026-04-28 18:13:33 +02:00
Revert "Revert "Add new build-time configuration feature.""
This reverts commit 4cf1376ec2.
Update tests to not use the run rule, but run the programs by other means instead.
This commit is contained in:
@@ -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,47 @@ 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"
|
||||
"actions simple_run_action\n"
|
||||
"{\n"
|
||||
" $(>) > $(<)\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"rule run-simple ( sources + : args * : input-files * : requirements * : target-name )\n"
|
||||
"{\n"
|
||||
" obj $(target-name)_obj : $(sources) : $(requirements) ;\n"
|
||||
" explicit $(target-name)_obj ;\n"
|
||||
" exe $(target-name)_exe : $(target-name)_obj : $(requirements) ;\n"
|
||||
" explicit $(target-name)_exe ;\n"
|
||||
" #testing.capture-output $(target-name)_output : $(target-name) : $(requirements) <name>$(target-name) ;\n"
|
||||
" make $(target-name).output : $(target-name)_exe : @simple_run_action ;\n"
|
||||
" explicit $(target-name).output ;\n"
|
||||
"}\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 +293,17 @@ 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-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";
|
||||
}
|
||||
|
||||
int cpp_main(int argc, char* argv[])
|
||||
@@ -285,6 +339,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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user