// along with config_test.cpp and a Jamfile.
//
+#define _CRT_SECURE_NO_WARNINGS
+
#include <boost/regex.hpp>
#include <boost/filesystem/path.hpp>
#include <boost/filesystem/operations.hpp>
fs::path config_path;
std::string copyright(
-"// Copyright John Maddock 2002-4.\n"
+"// Copyright John Maddock 2002-21.\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"
ofs << build_config_jamfile.str() << std::endl;
}
+std::map<std::string, std::set<std::string>> std_version_macros;
+
+
+void categorize_macro(const std::string& name)
+{
+ boost::regex cxxNN("BOOST_NO_CXX(\\d\\d).+");
+ boost::regex cxx03("BOOST_NO_.+");
+ boost::smatch what;
+ if (regex_match(name, what, cxxNN))
+ {
+ std_version_macros[what[1]].insert(name);
+ }
+ else if (regex_match(name, what, cxx03))
+ {
+ std_version_macros["03"].insert(name);
+ }
+}
+
void process_ipp_file(const fs::path& file, bool positive_test)
{
std::cout << "Info: Scanning file: " << file.string() << std::endl;
{
macro_name = macro_match[1];
macro_list.insert(macro_name);
+ categorize_macro(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())
feature_list.insert(feature_name);
}
+void fixup_cxxNN()
+{
+ std_version_macros.erase("98");
+ std_version_macros["03"].erase("BOOST_NO_MS_INT64_NUMERIC_LIMITS");
+ std_version_macros["03"].erase("BOOST_NO_SWPRINTF");
+ std_version_macros["03"].erase("BOOST_NO_CXX03");
+ std_version_macros["03"].erase("BOOST_NO_CXX11");
+ std_version_macros["03"].erase("BOOST_NO_CXX14");
+ std_version_macros["03"].erase("BOOST_NO_CXX17");
+ //
+ // These are removed from later standard versions so we don't check them here:
+ //
+ std_version_macros["03"].erase("BOOST_NO_AUTO_PTR");
+ std_version_macros["11"].erase("BOOST_NO_CXX11_ATOMIC_SMART_PTR");
+ std_version_macros["11"].erase("BOOST_NO_CXX11_HDR_CODECVT");
+}
+
+void write_cxxNN_asserts()
+{
+ std::string previous_filename;
+ for (auto std = std_version_macros.begin(); std != std_version_macros.end(); ++std)
+ {
+ std::string filename = "assert_cxx";
+ filename += std->first;
+ filename += ".hpp";
+ fs::ofstream ofs(config_path / ".." / "include" / "boost" / "config" / filename);
+ 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";
+ if (previous_filename.size())
+ ofs << "#include <boost/config/" << previous_filename << ">\n\n";
+ else
+ ofs << "\n";
+
+ for (auto macro = std->second.begin(); macro != std->second.end(); ++macro)
+ {
+ ofs << "#ifdef " << *macro << "\n# error \"Your compiler appears not to be fully C++" << std->first << " compliant. Detected via defect macro " << *macro << ".\"\n#endif\n";
+ }
+
+ previous_filename = filename;
+ }
+}
+
+void write_cxxNN_composite()
+{
+ fs::ofstream ofs(config_path / ".." / "include" / "boost" / "config" / "detail" / "cxx_composite.hpp");
+ 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;
+
+ std::string previous_macro;
+ for (auto std = std_version_macros.begin(); std != std_version_macros.end(); ++std)
+ {
+ std::string macro = "BOOST_NO_CXX";
+ macro += std->first;
+
+ bool done_first = false;
+ ofs << "#if ";
+
+ if (previous_macro.size())
+ {
+ ofs << "defined(" << previous_macro << ")";
+ done_first = true;
+ }
+
+ for (auto macro = std->second.begin(); macro != std->second.end(); ++macro)
+ {
+ if (done_first)
+ ofs << "\\\n || ";
+ ofs << "defined(" << *macro << ")";
+ done_first = true;
+ }
+ ofs << "\n# define " << macro << "\n#endif\n\n";
+
+ previous_macro = macro;
+ }
+}
+
void write_std_check(std::string macroname, int min_value, std::string header, int std_version, bool primary = true)
{
std::string test_name(macroname);
{
process_ipp_file(pos->first, pos->second);
}
+ fixup_cxxNN();
+ write_cxxNN_asserts();
+ write_cxxNN_composite();
write_config_test();
write_jamfile_v2();
write_config_info();