|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r58764 - in branches/release/tools/bcp: . doc doc/html test
From: john_at_[hidden]
Date: 2010-01-06 08:08:50
Author: johnmaddock
Date: 2010-01-06 08:08:49 EST (Wed, 06 Jan 2010)
New Revision: 58764
URL: http://svn.boost.org/trac/boost/changeset/58764
Log:
Merge updates from Trunk
Added:
branches/release/tools/bcp/add_dependent_lib.cpp
- copied unchanged from r58763, /trunk/tools/bcp/add_dependent_lib.cpp
branches/release/tools/bcp/doc/
- copied from r58763, /trunk/tools/bcp/doc/
branches/release/tools/bcp/doc/Jamfile.v2
- copied unchanged from r58763, /trunk/tools/bcp/doc/Jamfile.v2
branches/release/tools/bcp/doc/bcp.qbk
- copied unchanged from r58763, /trunk/tools/bcp/doc/bcp.qbk
branches/release/tools/bcp/doc/html/
- copied from r58763, /trunk/tools/bcp/doc/html/
branches/release/tools/bcp/doc/html/index.html
- copied unchanged from r58763, /trunk/tools/bcp/doc/html/index.html
branches/release/tools/bcp/test/
- copied from r58763, /trunk/tools/bcp/test/
branches/release/tools/bcp/test/Jamfile.v2
- copied unchanged from r58763, /trunk/tools/bcp/test/Jamfile.v2
Removed:
branches/release/tools/bcp/bcp.html
Properties modified:
branches/release/tools/bcp/ (props changed)
Text files modified:
branches/release/tools/bcp/Jamfile.v2 | 3
branches/release/tools/bcp/add_path.cpp | 205 ++++++++++++++++++++++++++++++---------
branches/release/tools/bcp/bcp.hpp | 3
branches/release/tools/bcp/bcp_imp.cpp | 49 +++++++++
branches/release/tools/bcp/bcp_imp.hpp | 45 +++++---
branches/release/tools/bcp/copy_path.cpp | 142 +++++++++++++++++++++++++++
branches/release/tools/bcp/file_types.cpp | 21 +++
branches/release/tools/bcp/index.html | 4
branches/release/tools/bcp/main.cpp | 33 ++++-
branches/release/tools/bcp/output_licence_info.cpp | 2
10 files changed, 420 insertions(+), 87 deletions(-)
Modified: branches/release/tools/bcp/Jamfile.v2
==============================================================================
--- branches/release/tools/bcp/Jamfile.v2 (original)
+++ branches/release/tools/bcp/Jamfile.v2 2010-01-06 08:08:49 EST (Wed, 06 Jan 2010)
@@ -4,14 +4,13 @@
exe bcp
:
- add_path.cpp bcp_imp.cpp copy_path.cpp file_types.cpp
+ add_dependent_lib.cpp add_path.cpp bcp_imp.cpp copy_path.cpp file_types.cpp
fileview.cpp main.cpp path_operations.cpp scan_cvs_path.cpp
licence_info.cpp scan_licence.cpp output_licence_info.cpp
/boost/filesystem//boost_filesystem
/boost/regex//boost_regex
/boost/test//boost_prg_exec_monitor
:
- <define>BOOST_REGEX_NO_LIB=1
:
release
;
Modified: branches/release/tools/bcp/add_path.cpp
==============================================================================
--- branches/release/tools/bcp/add_path.cpp (original)
+++ branches/release/tools/bcp/add_path.cpp 2010-01-06 08:08:49 EST (Wed, 06 Jan 2010)
@@ -9,7 +9,7 @@
* void bcp_implementation::add_path(const fs::path& p)
* void bcp_implementation::add_directory(const fs::path& p)
* void bcp_implementation::add_file(const fs::path& p)
- * void bcp_implementation::add_dependent_lib(const std::string& libname)
+ * void bcp_implementation::add_dependent_lib(const std::string& libname, const fs::path& p, const fileview& view)
*/
#include "bcp_imp.hpp"
@@ -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))
@@ -34,6 +34,7 @@
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;
}
}
@@ -71,8 +72,10 @@
if(m_boost_path.string().size())
s.erase(0, m_boost_path.string().size() + 1);
if(!m_dependencies.count(fs::path(s)))
+ {
m_dependencies[fs::path(s)] = p; // set up dependency tree
- add_path(fs::path(s));
+ add_path(fs::path(s));
+ }
++i;
}
}
@@ -100,6 +103,37 @@
{
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:
//
@@ -126,6 +160,14 @@
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)
@@ -136,8 +178,10 @@
// rather than a URL:
fs::path dep(p.branch_path() / s);
if(!m_dependencies.count(dep))
+ {
m_dependencies[dep] = p; // set up dependency tree
- add_path(dep);
+ add_path(dep);
+ }
}
++i;
}
@@ -178,6 +222,18 @@
std::pair<fs::path, fs::path>("boost/mpl/map/aux_/include_preprocessed.hpp", "boost/mpl/map/aux_/preprocessed"),
std::pair<fs::path, fs::path>("boost/mpl/list/aux_/include_preprocessed.hpp", "boost/mpl/list/aux_/preprocessed"),
std::pair<fs::path, fs::path>("libs/graph/src/python/visitor.hpp", "libs/graph/src/python"),
+ std::pair<fs::path, fs::path>("boost/test/detail/config.hpp", "libs/test/src"),
+ std::pair<fs::path, fs::path>("boost/test/detail/config.hpp", "libs/test/build"),
+ std::pair<fs::path, fs::path>("boost/typeof.hpp", "boost/typeof/incr_registration_group.hpp"),
+ std::pair<fs::path, fs::path>("boost/function_types/detail/pp_loop.hpp", "boost/function_types/detail/pp_cc_loop"),
+ std::pair<fs::path, fs::path>("boost/function_types/components.hpp", "boost/function_types/detail/components_impl"),
+ std::pair<fs::path, fs::path>("boost/function_types/detail/pp_loop.hpp", "boost/function_types/detail"),
+ std::pair<fs::path, fs::path>("boost/math/tools/rational.hpp", "boost/math/tools/detail"),
+ std::pair<fs::path, fs::path>("boost/proto/repeat.hpp", "boost/proto/detail/local.hpp"),
+ std::pair<fs::path, fs::path>("boost/signals/signal_template.hpp", "boost/function"),
+ std::pair<fs::path, fs::path>("boost/preprocessor/slot/counter.hpp", "boost/preprocessor/slot/detail/counter.hpp"),
+ std::pair<fs::path, fs::path>("boost/graph/distributed/detail/tag_allocator.hpp", "libs/graph_parallel"),
+ std::pair<fs::path, fs::path>("boost/graph/distributed/mpi_process_group.hpp", "libs/graph_parallel"),
};
for(unsigned int n = 0; n < (sizeof(specials)/sizeof(specials[0])); ++n)
@@ -185,33 +241,15 @@
if(0 == compare_paths(specials[n].first, p))
{
if(!m_dependencies.count(specials[n].second))
+ {
m_dependencies[specials[n].second] = p; // set up dependency tree
- add_path(specials[n].second);
+ add_path(specials[n].second);
+ }
}
}
}
-void bcp_implementation::add_dependent_lib(const std::string& libname, const fs::path& p)
-{
- //
- // if the boost library libname has source associated with it
- // then add the source to our list:
- //
- if(fs::exists(m_boost_path / "libs" / libname / "src"))
- {
- if(!m_dependencies.count(fs::path("libs") / libname / "src"))
- m_dependencies[fs::path("libs") / libname / "src"] = p; // set up dependency tree
- add_path(fs::path("libs") / libname / "src");
- if(fs::exists(m_boost_path / "libs" / libname / "build"))
- {
- if(!m_dependencies.count(fs::path("libs") / libname / "build"))
- m_dependencies[fs::path("libs") / libname / "build"] = p; // set up dependency tree
- add_path(fs::path("libs") / libname / "build");
- }
- }
-}
-
void bcp_implementation::add_file_dependencies(const fs::path& p, bool scanfile)
{
static const boost::regex e(
@@ -263,14 +301,18 @@
if(fs::exists(test_file) && !fs::is_directory(test_file) && (p.branch_path().string() != "boost"))
{
if(!m_dependencies.count(p.branch_path() / include_file))
+ {
m_dependencies[p.branch_path() / include_file] = p;
- add_path(p.branch_path() / include_file);
+ add_path(p.branch_path() / include_file);
+ }
}
else if(fs::exists(m_boost_path / include_file))
{
if(!m_dependencies.count(include_file))
+ {
m_dependencies[include_file] = p;
- add_path(include_file);
+ add_path(include_file);
+ }
}
++i;
}
@@ -278,7 +320,7 @@
// 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)
{
@@ -302,14 +344,18 @@
if(fs::exists(test_file) && !fs::is_directory(test_file) && (p.branch_path().string() != "boost"))
{
if(!m_dependencies.count(p.branch_path() / include_file))
+ {
m_dependencies[p.branch_path() / include_file] = p;
- add_path(p.branch_path() / include_file);
+ add_path(p.branch_path() / include_file);
+ }
}
else if(fs::exists(m_boost_path / include_file))
{
if(!m_dependencies.count(include_file))
+ {
m_dependencies[include_file] = p;
- add_path(include_file);
+ add_path(include_file);
+ }
}
else
{
@@ -325,6 +371,8 @@
// we know about and are correctly handled as special cases:
//
static const std::string known_macros[] = {
+ "AUX778076_INCLUDE_STRING",
+ "BOOST_PP_STRINGIZE(boost/mpl/aux_/preprocessed/AUX778076_PREPROCESSED_HEADER)",
"BOOST_USER_CONFIG",
"BOOST_COMPILER_CONFIG",
"BOOST_STDLIB_CONFIG",
@@ -367,16 +415,49 @@
"BOOST_PP_STRINGIZE(boost/mpl/vector/AUX778076_VECTOR_C_HEADER)",
"BOOST_REGEX_USER_CONFIG",
"BGL_PYTHON_EVENTS_HEADER",
- };
+ "B1",
+ "B2",
+ "BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()",
+ "BOOST_SLIST_HEADER",
+ "BOOST_HASH_SET_HEADER",
+ "BOOST_HASH_MAP_HEADER",
+ "BOOST_INTRUSIVE_INVARIANT_ASSERT_INCLUDE",
+ "BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT_INCLUDE",
+ "BOOST_INTRUSIVE_SAFE_HOOK_DESTRUCTOR_ASSERT_INCLUDE",
+ "BOOST_FT_loop",
+ "BOOST_FT_AL_PREPROCESSED",
+ "BOOST_FT_AL_INCLUDE_FILE",
+ "__FILE__",
+ "BOOST_FT_cc_file",
+ "BOOST_FT_variate_file",
+ "BOOST_USER_CONFIG",
+ "BOOST_HEADER()",
+ "BOOST_TR1_STD_HEADER(utility)",
+ "BOOST_TR1_STD_HEADER(BOOST_TR1_PATH(tuple))",
+ "BOOST_TR1_STD_HEADER(BOOST_TR1_PATH(random))",
+ "BOOST_TR1_STD_HEADER(BOOST_TR1_PATH(array))",
+ "BOOST_TR1_HEADER(cmath)",
+ "BOOST_TR1_STD_HEADER(BOOST_TR1_PATH(complex))",
+ "BOOST_TR1_STD_HEADER(BOOST_TR1_PATH(functional))",
+ "BOOST_TR1_STD_HEADER(BOOST_TR1_PATH(memory))",
+ "BOOST_TR1_STD_HEADER(BOOST_TR1_PATH(regex))",
+ "BOOST_TR1_STD_HEADER(BOOST_TR1_PATH(type_traits))",
+ "BOOST_TR1_STD_HEADER(BOOST_TR1_PATH(unordered_map))",
+ "BOOST_TR1_STD_HEADER(BOOST_TR1_PATH(unordered_set))",
+ "BOOST_TR1_STD_HEADER(BOOST_TR1_PATH(utility))",
+ "BOOST_PROTO_LOCAL_ITERATE()",
+ "BOOST_SIGNAL_FUNCTION_N_HEADER",
+ "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)
{
const std::string* known_macros_end = known_macros + sizeof(known_macros)/sizeof(known_macros[0]);
if(known_macros_end == std::find(known_macros, known_macros_end, i->str()))
{
- std::cerr << "CAUTION: don't know how to trace depenencies through macro: " << *i << " in file: " << p.string() << std::endl;
+ std::cerr << "CAUTION: don't know how to trace depenencies through macro: \"" << *i << "\" in file: " << p.string() << std::endl;
}
++i;
}
@@ -389,27 +470,49 @@
boost::cmatch what;
if(boost::regex_search(view.begin(), view.end(), what, m))
{
- add_dependent_lib("test", p);
+ add_dependent_lib("test", p, view);
}
- //
- // grab the name of the library to which the header belongs,
- // and if that library has source then add the source to our
- // list:
- //
- // this regex catches boost/libname.hpp or boost/libname/whatever:
- //
- static const boost::regex lib1("boost/([^\\./]+)(?!detail).*");
- boost::smatch swhat;
- if(boost::regex_match(p.string(), swhat, lib1))
+ if(!scanfile)
{
- add_dependent_lib(swhat.str(1), p);
+ //
+ // grab the name of the library to which the header belongs,
+ // and if that library has source then add the source to our
+ // list:
+ //
+ // this regex catches boost/libname.hpp or boost/libname/whatever:
+ //
+ static const boost::regex lib1("boost/([^\\./]+)(?!detail).*");
+ boost::smatch swhat;
+ if(boost::regex_match(p.string(), swhat, lib1))
+ {
+ add_dependent_lib(swhat.str(1), p, view);
+ }
+ //
+ // and this one catches boost/x/y/whatever (for example numeric/ublas):
+ //
+ static const boost::regex lib2("boost/([^/]+/[^/]+)/(?!detail).*");
+ if(boost::regex_match(p.string(), swhat, lib2))
+ {
+ add_dependent_lib(swhat.str(1), p, view);
+ }
}
- //
- // and this one catches boost/x/y/whatever (for example numeric/ublas):
- //
- static const boost::regex lib2("boost/([^/]+/[^/]+)/(?!detail).*");
- if(boost::regex_match(p.string(), swhat, lib2))
+ if(m_list_namespaces)
{
- add_dependent_lib(swhat.str(1), p);
+ //
+ // scan for top level namespaces and add to our list:
+ //
+ static const boost::regex namespace_scanner(
+ "^(?<!\\\\\\n)[[:blank:]]*+namespace\\s++(\\w++)\\s++(\\{[^{}]*(?:(?2)[^{}]*)*\\})"
+ );
+ i = boost::regex_token_iterator<const char*>(view.begin(), view.end(), namespace_scanner, 1);
+ while(i != j)
+ {
+ if(m_top_namespaces.count(*i) == 0)
+ {
+ //std::cout << *i << " (Found in " << p << ")" << std::endl;
+ m_top_namespaces[*i] = p;
+ }
+ ++i;
+ }
}
}
Modified: branches/release/tools/bcp/bcp.hpp
==============================================================================
--- branches/release/tools/bcp/bcp.hpp (original)
+++ branches/release/tools/bcp/bcp.hpp 2010-01-06 08:08:49 EST (Wed, 06 Jan 2010)
@@ -29,6 +29,9 @@
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 void set_namespace_list(bool) = 0;
virtual int run() = 0;
Deleted: branches/release/tools/bcp/bcp.html
==============================================================================
--- branches/release/tools/bcp/bcp.html 2010-01-06 08:08:49 EST (Wed, 06 Jan 2010)
+++ (empty file)
@@ -1,193 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
-<html>
- <head>
- <title>bcp</title>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <link rel="stylesheet" type="text/css" href="../../doc/html/boostbook.css">
- </head>
- <body>
- <P>
- <TABLE id="Table1" cellSpacing="1" cellPadding="1" width="100%" border="0">
- <TR>
- <td valign="top" width="300">
- <h3></h3>
- </td>
- <TD width="353">
- <H1 align="center">The bcp utility</H1>
- </TD>
- <td width="50">
- <h3><a href="../../index.htm"><img alt="Boost.Regex Index" src="../../doc/html/images/up.png"
- border="0"></a></h3>
- </td>
- </TR>
- </TABLE>
- </P>
- <HR>
- <p></p>
- <P>The bcp utility is a tool for extracting subsets of Boost, it's useful for
- Boost authors who want to distribute their library separately from Boost, and
- for Boost users who want to distribute a subset of Boost with their
- application.</P>
- <P>bcp can also report on which parts of Boost your code is dependent on, and what
- licences are used by those dependencies.</P>
- <H2>Examples:</H2>
- <PRE>bcp scoped_ptr /foo</PRE>
- <P>Copies boost/scoped_ptr.hpp and dependencies to /foo.</P>
- <PRE>bcp boost/regex.hpp /foo</PRE>
- <P>Copies boost/regex.hpp and all dependencies including the regex source code (in
- libs/regex/src) and build files (in libs/regex/build) to /foo. Does not
- copy the regex documentation, test, or example code.</P>
- <PRE>bcp regex /foo</PRE>
- <P>Copies the full regex lib (in libs/regex) including dependencies (such as the
- boost.test source required by the regex test programs) to /foo.</P>
- <PRE>bcp regex config build /foo</PRE>
- <P>Copies the full regex lib (in libs/regex) plus the config lib (libs/config) and
- the build system (tools/build) to /foo including all the dependencies.</P>
- <PRE>bcp --scan --boost=/boost foo.cpp bar.cpp boost</PRE>
- <P>Scans the [non-boost] files foo.cpp and bar.cpp for boost dependencies and
- copies those dependencies to the sub-directory boost.</P>
- <PRE>bcp --report regex.hpp boost-regex-report.html</PRE>
- <P>Creates a HTML report called <EM>boost-regex-report.html</EM> for the boost
- module <EM>regex.hpp</EM>. The report contains license information,
- author details, and file dependencies.</P>
- <H2>Syntax:</H2>
- <PRE>bcp --list [options] module-list</PRE>
- <P>Outputs a list of all the files in module-list including dependencies.</P>
- <PRE>bcp [options] module-list output-path</PRE>
- <P>Copies all the files found in module-list to output-path</P>
- <PRE>bcp --report [options] module-list html-file</PRE>
- <P>Outputs a html report file containing:</P>
- <UL>
- <LI>
- All the licenses in effect, plus the files using each license, and
- the copyright holders using each license.
- <LI>
- Any files with no recognizable license (please report these to the boost
- mailing lists).
- <LI>
- Any files with no recognizable copyright holders (please report these to the
- boost mailing lists).
- <LI>
- All the copyright holders and the files on which they hold copyright.
- <LI>
- File dependency information - indicates the reason for the inclusion of any
- particular file in the dependencies found.</LI></UL>
- <H3>Options:</H3>
- <PRE>--boost=path</PRE>
- <P>Sets the location of the boost tree to <EM>path. </EM> If this option is
- not provided then the current path is assumed to be the root directory of the
- Boost tree.</P>
- <PRE>--scan</PRE>
- <P>Treats the module list as a list of (probably non-boost) files to scan for
- boost dependencies, the files listed in the module list are not copied (or
- listed), only the boost files upon which they depend.</P>
- <PRE>--svn</PRE>
- <P>Only copy files under svn version control.</P>
- <PRE>--unix-lines</PRE>
- <P>Make sure that all copied files use Unix style line endings.</P>
- <H4>module-list: </H4>
- <P>When the --scan option is not used then a list of boost files or library
- names to copy, this can be:</P>
- <OL>
- <LI>
- The name of a tool: for example "build" will find "tools/build".
- <LI>
- The name of a library: for example "regex".
- <LI>
- The title of a header: for example "scoped_ptr" will find
- "boost/scoped_ptr.hpp".
- <LI>
- The name of a header: for example "scoped_ptr.hpp" will find
- "boost/scoped_ptr.hpp".
- <LI>
- The name of a file: for example "boost/regex.hpp".</LI></OL>
- <P>When the --scan option is used, then a list of (probably non-boost) files to
- scan for boost dependencies, the files in the module list are not therefore
- copied/listed.</P>
- <H4>output-path:
- </H4>
- <P>The path to which files will be copied (this path must exist).</P>
- <H2>Dependencies</H2>
- <P>File dependencies are found as follows:</P>
- <UL>
- <LI>
- C++ source files are scanned for #includes, all #includes present in the boost
- source tree will then be scanned for their dependencies and so on.</LI>
- <LI>
- C++ source files are associated with the name of a library, if that library has
- source code (and possibly build data), then include that source in the
- dependencies.</LI>
- <LI>
- C++ source files are checked for dependencies on Boost.test (for example to see
- if they use cpp_main as an entry point).</LI>
- <LI>
- HTML files are scanned for immediate dependencies (images and style sheets, but
- not links).</LI></UL>
- <P>It should be noted that in practice bcp can produce a rather "fat" list of
- dependencies, reasons for this include:</P>
- <UL>
- <LI>
- It searches for library names first, so using "regex" as a name will give you
- everything in the libs/regex directory and everything that depends on.
- This can be a long list as all the regex test and example programs will get
- scanned for their dependencies. If you want a more minimal list, then try
- using the names of the headers you are actually including, or use the --scan
- option to scan your source code.</LI>
- <LI>
- If you include the header of a library with separate source, then you get that
- libraries source and all it's dependencies. This is deliberate and in
- general those extra dependencies are needed.</LI>
- <LI>
- When you include a header, bcp doesn't know what compiler you're using, so it
- follows all possible preprocessor paths. If you're distributing a subset of
- Boost with you're application then that is what you want to have happen in
- general.</LI></UL>
- <P>The last point above can result in a substantial increase in the number of
- headers found compared to most peoples expectations. For example bcp
- finds 274 header dependencies for boost/shared_ptr.hpp: by running bcp in
- report mode we can see why all these headers have been found as dependencies:</P>
- <UL>
- <LI>
- All of the Config library headers get included (52 headers, would be
- about 6 for one compiler only).</LI>
- <LI>
- A lot of MPL and type traits code that includes workarounds for broken
- compilers that you may or may not need. Tracing back through the code
- shows that most of these aren't needed unless the user has
- defined BOOST_SP_USE_QUICK_ALLOCATOR, however bcp isn't aware of whether
- that preprocessor path will be taken or not, so the headers get included just
- in case. This adds about 48 headers (type traits), plus another 49 from
- MPL.</LI>
- <LI>
- The Preprocessor library gets used heavily by MPL: this adds another 96
- headers.</LI>
- <LI>
- The Shared Pointer library contains a lot of platform specific code, split up
- into around 22 headers: normally your compiler would need only a couple of
- these files.</LI></UL>
- <P>As you can see the number of dependencies found are much larger than those used
- by any single compiler, however if you want to distribute a subset of Boost
- that's usable in any configuration, by any compiler, on any platform then
- that's exactly what you need. If you want to figure out which Boost
- headers are being used by your <EM>specific </EM>compiler then the best way to
- find out is to prepocess the code and scan the output for boost header
- includes. You should be aware that the result will be very platform and
- compiler specific, and may not contain all the headers needed if you so much as
- change a compiler switch (for example turn on threading support).</P>
- <P>
- <P>
- <HR>
- <P></P>
- <P></P>
- <p>Last revised $Date$</p>
- <P><I>© Copyright John Maddock 2003-7</I></P>
- <P align="left"><I>Distributed under the Boost Software License, Version 1.0.
- (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
- </I></P>
- </body>
-</html>
-
-
-
-
-
Modified: branches/release/tools/bcp/bcp_imp.cpp
==============================================================================
--- branches/release/tools/bcp/bcp_imp.cpp (original)
+++ branches/release/tools/bcp/bcp_imp.cpp 2010-01-06 08:08:49 EST (Wed, 06 Jan 2010)
@@ -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), m_list_namespaces(false)
{
}
@@ -100,6 +102,22 @@
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;
+}
+
+void bcp_implementation::set_namespace_list(bool b)
+{
+ m_list_namespaces = b;
+ m_list_mode = b;
+}
+
fs::path get_short_path(const fs::path& p)
{
// truncate path no more than "x/y":
@@ -152,7 +170,7 @@
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]));
@@ -221,6 +239,33 @@
//
// now perform output:
//
+ if(m_list_namespaces)
+ {
+ // List the namespaces, in two lists, headers and source files
+ // first, then everything else afterwards:
+ //
+ boost::regex important_file("boost/.*|libs/[^/]*/(?:[^/]*/)?/src/.*");
+ std::map<std::string, fs::path>::const_iterator i, j;
+ i = m_top_namespaces.begin();
+ j = m_top_namespaces.end();
+ std::cout << "\n\nThe top level namespaces found for header and source files were:\n";
+ while(i != j)
+ {
+ if(regex_match(i->second.string(), important_file))
+ std::cout << i->first << " (from " << i->second << ")" << std::endl;
+ ++i;
+ }
+
+ i = m_top_namespaces.begin();
+ std::cout << "\n\nThe top level namespaces found for all other source files were:\n";
+ while(i != j)
+ {
+ if(!regex_match(i->second.string(), important_file))
+ std::cout << i->first << " (from " << i->second << ")" << std::endl;
+ ++i;
+ }
+ return 0;
+ }
std::set<fs::path, path_less>::iterator m, n;
std::set<fs::path, path_less> short_paths;
m = m_copy_paths.begin();
Modified: branches/release/tools/bcp/bcp_imp.hpp
==============================================================================
--- branches/release/tools/bcp/bcp_imp.hpp (original)
+++ branches/release/tools/bcp/bcp_imp.hpp 2010-01-06 08:08:49 EST (Wed, 06 Jan 2010)
@@ -44,6 +44,9 @@
public:
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:
@@ -60,10 +63,14 @@
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);
+ void set_namespace_list(bool);
virtual int run();
-private:
+
// internal helper functions:
+ bool is_binary_file(const fs::path& p);
void scan_cvs_path(const fs::path& p);
void scan_svn_path(const fs::path& p);
void add_path(const fs::path& p);
@@ -71,10 +78,7 @@
void add_file(const fs::path& p);
void copy_path(const fs::path& p);
void add_file_dependencies(const fs::path& p, bool scanfile);
- bool is_source_file(const fs::path& p);
- bool is_html_file(const fs::path& p);
- bool is_binary_file(const fs::path& p);
- void add_dependent_lib(const std::string& libname, const fs::path& p);
+ void add_dependent_lib(const std::string& libname, const fs::path& p, const fileview& view);
void create_path(const fs::path& p);
// license code:
void scan_license(const fs::path& p, const fileview& v);
@@ -90,18 +94,25 @@
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.
+ bool m_list_namespaces; // list all the top level namespaces found.
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
+ std::map<std::string, fs::path> m_top_namespaces; // List of top level namespace names
};
+
Modified: branches/release/tools/bcp/copy_path.cpp
==============================================================================
--- branches/release/tools/bcp/copy_path.cpp (original)
+++ branches/release/tools/bcp/copy_path.cpp 2010-01-06 08:08:49 EST (Wed, 06 Jan 2010)
@@ -11,12 +11,36 @@
*/
#include "bcp_imp.hpp"
+#include "fileview.hpp"
#include <boost/filesystem/operations.hpp>
+#include <boost/regex.hpp>
#include <fstream>
#include <iterator>
#include <algorithm>
#include <iostream>
+struct get_new_library_name
+{
+ get_new_library_name(const std::string& n) : m_new_name(n) {}
+ template <class I>
+ std::string operator()(const boost::match_results<I>& what)
+ {
+ std::string s = what[0];
+ std::string::size_type n = s.find("boost");
+ if(n == std::string::npos)
+ {
+ s.insert(0, m_new_name);
+ }
+ else
+ {
+ s.replace(n, 5, m_new_name);
+ }
+ return s;
+ }
+private:
+ std::string m_new_name;
+};
+
void bcp_implementation::copy_path(const fs::path& p)
{
assert(!fs::is_directory(m_boost_path / p));
@@ -34,7 +58,123 @@
//
// do text based copy if requested:
//
- if(m_unix_lines && !is_binary_file(p))
+ if(m_namespace_name.size() && m_lib_names.size() && is_jam_file(p))
+ {
+ static std::vector<char> v1, v2;
+ v1.clear();
+ v2.clear();
+ std::ifstream is((m_boost_path / p).native_file_string().c_str());
+ std::copy(std::istreambuf_iterator<char>(is), std::istreambuf_iterator<char>(), std::back_inserter(v1));
+
+ static boost::regex libname_matcher;
+ if(libname_matcher.empty())
+ {
+ std::string re = "\\<";
+ re += *m_lib_names.begin();
+ for(std::set<std::string>::const_iterator i = ++m_lib_names.begin(); i != m_lib_names.end(); ++i)
+ {
+ re += "|" + *i;
+ }
+ re += "\\>";
+ libname_matcher.assign(re);
+ }
+
+ regex_replace(std::back_inserter(v2), v1.begin(), v1.end(), libname_matcher, get_new_library_name(m_namespace_name));
+ std::swap(v1, v2);
+ v2.clear();
+
+ std::ofstream os;
+ if(m_unix_lines)
+ os.open((m_dest_path / p).native_file_string().c_str(), std::ios_base::binary | std::ios_base::out);
+ else
+ os.open((m_dest_path / p).native_file_string().c_str(), std::ios_base::out);
+ os.write(&*v1.begin(), v1.size());
+ os.close();
+ }
+ else if(m_namespace_name.size() && is_source_file(p))
+ {
+ //
+ // v1 hold the current content, v2 is temp buffer.
+ // Each time we do a search and replace the new content
+ // ends up in v2: we then swap v1 and v2, and clear v2.
+ //
+ static std::vector<char> v1, v2;
+ v1.clear();
+ v2.clear();
+ std::ifstream is((m_boost_path / p).native_file_string().c_str());
+ std::copy(std::istreambuf_iterator<char>(is), std::istreambuf_iterator<char>(), std::back_inserter(v1));
+
+ static const boost::regex namespace_matcher(
+ "(?|"
+ "(namespace\\s+)boost(_\\w+)?"
+ "|"
+ "(namespace\\s+)(adstl|phoenix|rapidxml)\\>"
+ "|"
+ "()boost((?:_\\w+)?\\s*(?:::|,|\\)))"
+ "|"
+ "()((?:adstl|phoenix|rapidxml)\\s*(?:::|,|\\)))"
+ "|"
+ "(namespace\\s+\\w+\\s*=\\s*(?:::\\s*)?)boost(_\\w+)?"
+ "|"
+ "(namespace\\s+\\w+\\s*=\\s*(?:::\\s*)?)(adstl|phoenix|rapidxml)\\>"
+ "|"
+ "(^\\s*#\\s*define[^\\n]+)boost((?:_\\w+)?\\s*)$"
+ "|"
+ "(^\\s*#\\s*define[^\\n]+)((?:adstl|phoenix|rapidxml)\\s*)$"
+ ")"
+ );
+
+ regex_replace(std::back_inserter(v2), v1.begin(), v1.end(), namespace_matcher, "$1" + m_namespace_name + "$2");
+ std::swap(v1, v2);
+ v2.clear();
+
+ if(m_namespace_alias)
+ {
+ static const boost::regex namespace_alias(
+ /*
+ "namespace\\s+" + m_namespace_name +
+ "\\s*"
+ "("
+ "\\{"
+ "(?:"
+ "(?>[^\\{\\}/]+)"
+ "(?>"
+ "(?:"
+ "(?1)"
+ "|//[^\\n]+$"
+ "|/[^/]"
+ "|(?:^\\s*#[^\\n]*"
+ "(?:(?<=\\\\)\\n[^\\n]*)*)"
+ ")"
+ "[^\\{\\}]+"
+ ")*"
+ ")*"
+ "\\}"
+ ")"
+ */
+ /*
+ "(namespace\\s+" + m_namespace_name +
+ "\\s*\\{.*"
+ "\\})([^\\{\\};]*)\\z"
+ */
+ "namespace\\s+" + m_namespace_name +
+ "\\s*\\{"
+ );
+ regex_replace(std::back_inserter(v2), v1.begin(), v1.end(), namespace_alias,
+ "namespace " + m_namespace_name + "{} namespace boost = " + m_namespace_name + "; namespace " + m_namespace_name + "{");
+ std::swap(v1, v2);
+ v2.clear();
+ }
+
+ std::ofstream os;
+ if(m_unix_lines)
+ os.open((m_dest_path / p).native_file_string().c_str(), std::ios_base::binary | std::ios_base::out);
+ else
+ os.open((m_dest_path / p).native_file_string().c_str(), std::ios_base::out);
+ os.write(&*v1.begin(), v1.size());
+ os.close();
+ }
+ else if(m_unix_lines && !is_binary_file(p))
{
std::ifstream is((m_boost_path / p).native_file_string().c_str());
std::istreambuf_iterator<char> isi(is);
Modified: branches/release/tools/bcp/file_types.cpp
==============================================================================
--- branches/release/tools/bcp/file_types.cpp (original)
+++ branches/release/tools/bcp/file_types.cpp 2010-01-06 08:08:49 EST (Wed, 06 Jan 2010)
@@ -19,11 +19,11 @@
static const boost::regex e(
".*\\."
"(?:"
- "c|cxx|h|hxx|inc|.?pp|yy?"
+ "c|cxx|h|hxx|inc|inl|.?pp|yy?"
")",
boost::regex::perl | boost::regex::icase
);
- return boost::regex_match(p.string(), e);
+ return boost::regex_match(p.filename(), e);
}
bool bcp_implementation::is_html_file(const fs::path& p)
@@ -34,7 +34,7 @@
"html?|css"
")"
);
- return boost::regex_match(p.string(), e);
+ return boost::regex_match(p.filename(), e);
}
bool bcp_implementation::is_binary_file(const fs::path& p)
@@ -55,3 +55,18 @@
return !boost::regex_match(p.leaf(), e);
}
+
+bool bcp_implementation::is_jam_file(const fs::path& p)
+{
+ static const boost::regex e(
+ ".*\\."
+ "(?:"
+ "jam|v2"
+ ")"
+ "|"
+ "(Jamfile|Jamroot)\\.?",
+ boost::regex::perl | boost::regex::icase
+ );
+ return boost::regex_match(p.filename(), e);
+}
+
Modified: branches/release/tools/bcp/index.html
==============================================================================
--- branches/release/tools/bcp/index.html (original)
+++ branches/release/tools/bcp/index.html 2010-01-06 08:08:49 EST (Wed, 06 Jan 2010)
@@ -1,10 +1,10 @@
<html>
<head>
- <meta http-equiv="refresh" content="0; URL=bcp.html">
+ <meta http-equiv="refresh" content="0; URL=doc/html/index.html">
</head>
<body>
<p>
- Automatic redirection failed, please go to bcp.html.
+ Automatic redirection failed, please go to doc/html/index.html.
</p>
<p>Copyright John Maddock 2007</p>
<p>Distributed under the Boost Software License, Version 1.0. (See accompanying file <a href="../../LICENSE_1_0.txt">
Modified: branches/release/tools/bcp/main.cpp
==============================================================================
--- branches/release/tools/bcp/main.cpp (original)
+++ branches/release/tools/bcp/main.cpp 2010-01-06 08:08:49 EST (Wed, 06 Jan 2010)
@@ -34,15 +34,17 @@
" bcp [options] module-list output-path\n"
"\n"
"Options:\n"
- " --boost=path sets the location of the boost tree to path\n"
- " --scan treat the module list as a list of (possibly non-boost)\n"
- " files to scan for boost dependencies\n"
- " --cvs only copy files under cvs version control\n"
- " --unix-lines make sure that all copied files use Unix style line endings\n"
+ " --boost=path sets the location of the boost tree to path\n"
+ " --scan treat the module list as a list of (possibly non-boost)\n"
+ " files to scan for boost dependencies\n"
+ " --svn only copy files under cvs version control\n"
+ " --unix-lines make sure that all copied files use Unix style line endings\n"
+ " --namespace=name rename the boost namespace to name (also changes library names).\n"
+ " --namespace-alias Makes namespace boost an alias of the namespace set with --namespace.\n"
"\n"
- "module-list: a list of boost files or library names to copy\n"
- "html-file: the name of a html file to which the report will be written\n"
- "output-path: the path to which files will be copied\n";
+ "module-list: a list of boost files or library names to copy\n"
+ "html-file: the name of a html file to which the report will be written\n"
+ "output-path: the path to which files will be copied\n";
}
bool filesystem_name_check( const std::string & name )
@@ -64,6 +66,7 @@
//
if(argc < 2)
{
+ std::cout << "Error: insufficient arguments, don't know what to do." << std::endl;
show_usage();
return 0;
}
@@ -134,8 +137,22 @@
{
papp->set_boost_path(argv[i] + 8);
}
+ else if(0 == std::strncmp("--namespace=", argv[i], 12))
+ {
+ papp->set_namespace(argv[i] + 12);
+ }
+ else if(0 == std::strncmp("--namespace-alias", argv[i], 17))
+ {
+ papp->set_namespace_alias(true);
+ }
+ else if(0 == std::strncmp("--list-namespaces", argv[i], 17))
+ {
+ list_mode = true;
+ papp->set_namespace_list(true);
+ }
else if(argv[i][0] == '-')
{
+ std::cout << "Error: Unknown argument " << argv[i] << std::endl;
show_usage();
return 1;
}
Modified: branches/release/tools/bcp/output_licence_info.cpp
==============================================================================
--- branches/release/tools/bcp/output_licence_info.cpp (original)
+++ branches/release/tools/bcp/output_licence_info.cpp 2010-01-06 08:08:49 EST (Wed, 06 Jan 2010)
@@ -139,7 +139,7 @@
// version):
//
fileview version_file(m_boost_path / "boost/version.hpp");
- boost::regex version_regex(
+ static const boost::regex version_regex(
"^[[:blank:]]*#[[:blank:]]*define[[:blank:]]+BOOST_VERSION[[:blank:]]+(\\d+)");
boost::cmatch what;
if(boost::regex_search(version_file.begin(), version_file.end(), what, version_regex))
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk