Skip to content

Commit

Permalink
Add namespace renaming option.
Browse files Browse the repository at this point in the history
Reworked docs in quickbook format.

[SVN r58543]
  • Loading branch information
jzmaddock committed Dec 28, 2009
1 parent 2299ea9 commit efe5cf1
Show file tree
Hide file tree
Showing 14 changed files with 831 additions and 225 deletions.
6 changes: 6 additions & 0 deletions add_dependent_lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,12 @@ void bcp_implementation::add_dependent_lib(const std::string& libname, const fs:
{
m_dependencies[fs::path("libs") / libname / "build"] = p; // set up dependency tree
add_path(fs::path("libs") / libname / "build");
//m_dependencies[fs::path("boost-build.jam")] = p;
//add_path(fs::path("boost-build.jam"));
m_dependencies[fs::path("Jamroot")] = p;
add_path(fs::path("Jamroot"));
//m_dependencies[fs::path("tools/build")] = p;
//add_path(fs::path("tools/build"));
}
}
}
Expand Down
46 changes: 43 additions & 3 deletions add_path.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
void bcp_implementation::add_path(const fs::path& p)
{
fs::path normalized_path = p;
normalized_path.normalize();
normalized_path.normalize();
if(fs::exists(m_boost_path / normalized_path))
{
if(fs::is_directory(m_boost_path / normalized_path))
Expand All @@ -34,6 +34,7 @@ void bcp_implementation::add_path(const fs::path& p)
else
{
std::cerr << "CAUTION: dependent file " << p.string() << " does not exist." << std::endl;
std::cerr << " Found while scanning file " << m_dependencies[p].string() << std::endl;
}
}

Expand Down Expand Up @@ -102,6 +103,37 @@ void bcp_implementation::add_file(const fs::path& p)
{
add_file_dependencies(p, false);
}
if(is_jam_file(p) && m_namespace_name.size() && ((std::distance(p.begin(), p.end()) < 3) || (*p.begin() != "tools") || (*++p.begin() != "build")))
{
//
// We're doing a rename of namespaces and library names
// so scan for names of libraries:
//
static const boost::regex e(
"\\<lib\\s+(boost\\w+)\\s+[:;]"
);

fileview view(m_boost_path / p);
boost::regex_token_iterator<const char*> i(view.begin(), view.end(), e, 1);
boost::regex_token_iterator<const char*> j;
while(i != j)
{
m_lib_names.insert(*i);
++i;
}
static const std::pair<fs::path, std::string> specials_library_names[] = {
std::pair<fs::path, std::string>("libs/python/build/Jamfile.v2", "boost_python"),
std::pair<fs::path, std::string>("libs/python/build/Jamfile.v2", "boost_python3"),
};

for(unsigned int n = 0; n < (sizeof(specials_library_names)/sizeof(specials_library_names[0])); ++n)
{
if(0 == compare_paths(specials_library_names[n].first, p))
{
m_lib_names.insert(specials_library_names[n].second);
}
}
}
//
// if this is a html file, scan for dependencies:
//
Expand All @@ -128,6 +160,14 @@ void bcp_implementation::add_file(const fs::path& p)
s.erase(s.size() - 1);
}
//
// Remove any target suffix:
//
std::string::size_type n = s.find('#');
if(n != std::string::npos)
{
s.erase(n);
}
//
// if the name starts with ./ remove it
// or we'll get an error:
if(s.compare(0, 2, "./") == 0)
Expand Down Expand Up @@ -280,7 +320,7 @@ void bcp_implementation::add_file_dependencies(const fs::path& p, bool scanfile)
// Now we need to scan for Boost.Preprocessor includes that
// are included via preprocessor iteration:
//
boost::regex ppfiles("^[[:blank:]]*#[[:blank:]]*define[[:blank:]]+(?:BOOST_PP_FILENAME|BOOST_PP_ITERATION_PARAMS|BOOST_PP_INDIRECT_SELF)[^\\n]+?[\"<]([^\">]+)[\">]");
static const boost::regex ppfiles("^[[:blank:]]*#[[:blank:]]*define[[:blank:]]+(?:BOOST_PP_FILENAME|BOOST_PP_ITERATION_PARAMS|BOOST_PP_INDIRECT_SELF)[^\\n]+?[\"<]([^\">]+)[\">]");
i = boost::regex_token_iterator<const char*>(view.begin(), view.end(), ppfiles, 1);
while(i != j)
{
Expand Down Expand Up @@ -410,7 +450,7 @@ void bcp_implementation::add_file_dependencies(const fs::path& p, bool scanfile)
"BOOST_PP_UPDATE_COUNTER()",
};

boost::regex indirect_includes("^[[:blank:]]*#[[:blank:]]*include[[:blank:]]+([^\"<][^\n]*?)[[:blank:]]*$");
static const boost::regex indirect_includes("^[[:blank:]]*#[[:blank:]]*include[[:blank:]]+([^\"<][^\n]*?)[[:blank:]]*$");
i = boost::regex_token_iterator<const char*>(view.begin(), view.end(), indirect_includes, 1);
while(i != j)
{
Expand Down
2 changes: 2 additions & 0 deletions bcp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ class bcp_application
virtual void set_boost_path(const char* p) = 0;
virtual void set_destination(const char* p) = 0;
virtual void add_module(const char* p) = 0;
virtual void set_namespace(const char* name) = 0;
virtual void set_namespace_alias(bool) = 0;

virtual int run() = 0;

Expand Down
193 changes: 0 additions & 193 deletions bcp.html

This file was deleted.

16 changes: 14 additions & 2 deletions bcp_imp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
#include <string>

bcp_implementation::bcp_implementation()
: m_list_mode(false), m_list_summary_mode(false), m_license_mode(false), m_cvs_mode(false), m_svn_mode(false), m_unix_lines(false), m_scan_mode(false), m_bsl_convert_mode(false), m_bsl_summary_mode(false)
: m_list_mode(false), m_list_summary_mode(false), m_license_mode(false), m_cvs_mode(false),
m_svn_mode(false), m_unix_lines(false), m_scan_mode(false), m_bsl_convert_mode(false),
m_bsl_summary_mode(false), m_namespace_alias(false)
{
}

Expand Down Expand Up @@ -100,6 +102,16 @@ void bcp_implementation::add_module(const char* p)
m_module_list.push_back(p);
}

void bcp_implementation::set_namespace(const char* name)
{
m_namespace_name = name;
}

void bcp_implementation::set_namespace_alias(bool b)
{
m_namespace_alias = b;
}

fs::path get_short_path(const fs::path& p)
{
// truncate path no more than "x/y":
Expand Down Expand Up @@ -152,7 +164,7 @@ int bcp_implementation::run()
fs::ifstream in(blanket_permission);
std::string line;
while (std::getline(in, line)) {
boost::regex e("([^(]+)\\(");
static const boost::regex e("([^(]+)\\(");
boost::smatch result;
if (boost::regex_search(line, result, e))
m_bsl_authors.insert(format_authors_name(result[1]));
Expand Down
31 changes: 19 additions & 12 deletions bcp_imp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class bcp_implementation
~bcp_implementation();
static bool is_source_file(const fs::path& p);
static bool is_html_file(const fs::path& p);
static bool is_jam_file(const fs::path& p);
private:
//
// the following are the overridden virtuals from the base class:
Expand All @@ -62,6 +63,8 @@ class bcp_implementation
void set_boost_path(const char* p);
void set_destination(const char* p);
void add_module(const char* p);
void set_namespace(const char* name);
void set_namespace_alias(bool);

virtual int run();

Expand Down Expand Up @@ -90,18 +93,22 @@ class bcp_implementation
bool m_scan_mode; // scan non-boost files.
bool m_bsl_convert_mode; // try to convert to the BSL
bool m_bsl_summary_mode; // summarise BSL issues only
bool m_namespace_alias; // make "boost" a namespace alias when doing a namespace rename.
fs::path m_boost_path; // the path to the boost root
fs::path m_dest_path; // the path to copy to
std::map<fs::path, bool, path_less> m_cvs_paths; // valid files under cvs control
std::set<fs::path, path_less> m_copy_paths; // list of files to copy
std::map<int, license_data> m_license_data; // licenses in use
std::set<fs::path, path_less> m_unknown_licenses; // files with no known license
std::set<fs::path, path_less> m_unknown_authors; // files with no known copyright/author
std::set<fs::path, path_less> m_can_migrate_to_bsl; // files that can migrate to the BSL
std::set<fs::path, path_less> m_cannot_migrate_to_bsl; // files that cannot migrate to the BSL
std::set<std::string> m_bsl_authors; // authors giving blanket permission to use the BSL
std::set<std::string> m_authors_for_bsl_migration; // authors we need for BSL migration
std::map<fs::path, std::pair<std::string, std::string>, path_less> m_converted_to_bsl;
std::map<std::string, std::set<fs::path, path_less> > m_author_data; // all the authors
std::map<fs::path, fs::path, path_less> m_dependencies; // dependency information
std::map<fs::path, bool, path_less> m_cvs_paths; // valid files under cvs control
std::set<fs::path, path_less> m_copy_paths; // list of files to copy
std::map<int, license_data> m_license_data; // licenses in use
std::set<fs::path, path_less> m_unknown_licenses; // files with no known license
std::set<fs::path, path_less> m_unknown_authors; // files with no known copyright/author
std::set<fs::path, path_less> m_can_migrate_to_bsl; // files that can migrate to the BSL
std::set<fs::path, path_less> m_cannot_migrate_to_bsl; // files that cannot migrate to the BSL
std::set<std::string> m_bsl_authors; // authors giving blanket permission to use the BSL
std::set<std::string> m_authors_for_bsl_migration; // authors we need for BSL migration
std::map<fs::path, std::pair<std::string, std::string>, path_less>
m_converted_to_bsl;
std::map<std::string, std::set<fs::path, path_less> > m_author_data; // all the authors
std::map<fs::path, fs::path, path_less> m_dependencies; // dependency information
std::string m_namespace_name; // namespace rename.
std::set<std::string> m_lib_names; // List of library binary names
};
Loading

0 comments on commit efe5cf1

Please sign in to comment.