
Bjørn Roald wrote:
Eric Niebler wrote:
Bjørn Roald wrote: Sounds very interesting! Yes, there is interest. Please send the patches around again.
I have merged with the latest svn trunk. Are there any guidelines for producing a patch with svn?
Attached is a patch generated with plain 'svn diff' command in the trunk directory.
<snip> I've attached an updated patch for these changes against HEAD, for anybody else who is interested. (This patch adds the ability to move boost into a different top-level namespace, rename macros, etc.) -- Eric Niebler Boost Consulting www.boost-consulting.com Index: tools/bcp/file_types.cpp =================================================================== --- tools/bcp/file_types.cpp (revision 40295) +++ tools/bcp/file_types.cpp (working copy) @@ -9,6 +9,7 @@ * void bcp_implementation::is_source_file(const fs::path& p) * void bcp_implementation::is_html_file(const fs::path& p) * void bcp_implementation::is_binary_file(const fs::path& p) + * void bcp_implementation::is_bjam_file(const fs::path& p) */ #include "bcp_imp.hpp" @@ -19,8 +20,8 @@ static const boost::regex e( ".*\\." "(?:" - "c|cxx|h|hxx|inc|.?pp|yy?" - ")", + "c|cxx|h|hxx|inl|inc|.?pp|yy?" + ")", boost::regex::perl | boost::regex::icase ); return boost::regex_match(p.string(), e); @@ -50,8 +51,23 @@ "c|cxx|cpp|h|hxx|hpp|inc|html?|css|mak|in" ")" "|" - "(Jamfile|makefile|configure)", + "(Jamfile|Jamfile\\.v2|Jamrules|Jambase|makefile|configure)", boost::regex::perl | boost::regex::icase); return !boost::regex_match(p.leaf(), e); } + + +bool bcp_implementation::is_bjam_file(const fs::path& p) +{ + static const boost::regex e( + ".*\\." + "(?:" + "jam" + ")" + "|" + "(Jamfile|Jamfile\\.v2|Jamrules|Jambase)", + boost::regex::perl | boost::regex::icase); + return boost::regex_match(p.leaf(), e); + +} Index: tools/bcp/add_path.cpp =================================================================== --- tools/bcp/add_path.cpp (revision 40295) +++ tools/bcp/add_path.cpp (working copy) @@ -125,6 +125,11 @@ // or we'll get an error: if(s.compare(0, 2, "./") == 0) s.erase(0, 2); + // + // if the name contain .html# , remove the html bookmark + // or we'll get warnings of none existing files + if(s.find(".html#") != std::string::npos) + s.erase(s.find(".html#")+5); if(s.find(':') == std::string::npos) { // only concatonate if it's a relative path Index: tools/bcp/bcp_imp.cpp =================================================================== --- tools/bcp/bcp_imp.cpp (revision 40295) +++ tools/bcp/bcp_imp.cpp (working copy) @@ -18,7 +18,17 @@ #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_diff_only_mode(false) + , m_replace_namespace(false) + , m_scan_mode(false) + , m_bsl_convert_mode(false) + , m_bsl_summary_mode(false) { } @@ -76,6 +86,11 @@ m_unix_lines = true; } +void bcp_implementation::enable_diff_only_mode() +{ + m_diff_only_mode = true; +} + void bcp_implementation::set_boost_path(const char* p) { m_boost_path = fs::path(p, fs::native); Index: tools/bcp/bcp.hpp =================================================================== --- tools/bcp/bcp.hpp (revision 40295) +++ tools/bcp/bcp.hpp (working copy) @@ -22,11 +22,13 @@ virtual void enable_cvs_mode() = 0; virtual void enable_svn_mode() = 0; virtual void enable_unix_lines() = 0; + virtual void enable_diff_only_mode() = 0; virtual void enable_scan_mode() = 0; virtual void enable_license_mode() = 0; virtual void enable_bsl_convert_mode() = 0; virtual void enable_bsl_summary_mode() = 0; virtual void set_boost_path(const char* p) = 0; + virtual void set_replacement_namespace(const char* ns) = 0; virtual void set_destination(const char* p) = 0; virtual void add_module(const char* p) = 0; Index: tools/bcp/scan_cvs_path.cpp =================================================================== --- tools/bcp/scan_cvs_path.cpp (revision 40295) +++ tools/bcp/scan_cvs_path.cpp (working copy) @@ -59,7 +59,6 @@ ++i; m_cvs_paths[file] = binary; } - } } } Index: tools/bcp/Jamfile.v2 =================================================================== --- tools/bcp/Jamfile.v2 (revision 40295) +++ tools/bcp/Jamfile.v2 (working copy) @@ -7,6 +7,7 @@ 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 + replace_namespace.cpp /boost/filesystem//boost_filesystem /boost/regex//boost_regex /boost/test//boost_prg_exec_monitor Index: tools/bcp/bcp_imp.hpp =================================================================== --- tools/bcp/bcp_imp.hpp (revision 40295) +++ tools/bcp/bcp_imp.hpp (working copy) @@ -53,11 +53,13 @@ void enable_cvs_mode(); void enable_svn_mode(); void enable_unix_lines(); + void enable_diff_only_mode(); void enable_scan_mode(); void enable_license_mode(); void enable_bsl_convert_mode(); void enable_bsl_summary_mode(); void set_boost_path(const char* p); + void set_replacement_namespace(const char* ns); void set_destination(const char* p); void add_module(const char* p); @@ -70,10 +72,15 @@ void add_directory(const fs::path& p); void add_file(const fs::path& p); void copy_path(const fs::path& p); + void replace_namespace(const fs::path& p); + fs::path destination_path(const fs::path p, std::string seperator = "/"); 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); + bool is_bjam_file(const fs::path& p); + bool diff_only_copy( const std::string& new_file, + fs::path destination_path ); void add_dependent_lib(const std::string& libname, const fs::path& p); void create_path(const fs::path& p); // license code: @@ -87,6 +94,8 @@ bool m_cvs_mode; // check cvs for files bool m_svn_mode; // check svn for files bool m_unix_lines; // fix line endings + bool m_diff_only_mode; // diff only mode + bool m_replace_namespace; // replace the boost namespace 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 Index: tools/bcp/main.cpp =================================================================== --- tools/bcp/main.cpp (revision 40295) +++ tools/bcp/main.cpp (working copy) @@ -33,10 +33,13 @@ "\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" + " --namespace=ns set a namespace that will replace 'boost'\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" + " --diff-only only overwrite files when new file differs from\n" + " existing original. May save you rebuilds.\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" @@ -127,12 +130,21 @@ { papp->enable_unix_lines(); } + else if(0 == std::strcmp("--diff-only", argv[i])) + { + papp->enable_diff_only_mode(); + } else if(0 == std::strncmp("--boost=", argv[i], 8)) { papp->set_boost_path(argv[i] + 8); } + else if(0 == std::strncmp("--namespace=", argv[i], 12)) + { + papp->set_replacement_namespace(argv[i] + 12); + } else if(argv[i][0] == '-') { + std::cout << "wrong argument: " << argv[i] << std::endl; show_usage(); return 1; } Index: tools/bcp/copy_path.cpp =================================================================== --- tools/bcp/copy_path.cpp (revision 40295) +++ tools/bcp/copy_path.cpp (working copy) @@ -20,35 +20,50 @@ void bcp_implementation::copy_path(const fs::path& p) { assert(!fs::is_directory(m_boost_path / p)); - if(fs::exists(m_dest_path / p)) - { - std::cout << "Copying (and overwriting) file: " << p.string() << "\n"; - fs::remove(m_dest_path / p); - } - else - std::cout << "Copying file: " << p.string() << "\n"; + fs::path dest_p = destination_path( p ); + // // create the path to the new file if it doesn't already exist: // - create_path(p.branch_path()); + create_path(dest_p.branch_path()); // // do text based copy if requested: // - if(m_unix_lines && !is_binary_file(p)) + if(m_replace_namespace && (is_source_file(p) || is_bjam_file(p))) { - std::ifstream is((m_boost_path / p).native_file_string().c_str()); - std::istreambuf_iterator<char> isi(is); - std::istreambuf_iterator<char> end; - - std::ofstream os((m_dest_path / p).native_file_string().c_str(), std::ios_base::binary | std::ios_base::out); - std::ostreambuf_iterator<char> osi(os); - - std::copy(isi, end, osi); + replace_namespace(p); } else { - // binary copy: - fs::copy_file(m_boost_path / p, m_dest_path / p); + + if( fs::exists(m_dest_path / dest_p)) + { + // TODO: need some support for diff mode here, for now + // diff_mode is only supported within replace_namespace(p); + + std::cout << "Copying (and overwriting) file: " << p.string() << "\n"; + fs::remove(m_dest_path / dest_p ); + } + else + std::cout << "Copying file: " << p.string() << "\n"; + + 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); + std::istreambuf_iterator<char> end; + + std::ofstream os( ( m_dest_path / dest_p ).native_file_string().c_str(), + std::ios_base::binary | std::ios_base::out); + std::ostreambuf_iterator<char> osi(os); + + std::copy(isi, end, osi); + } + else + { + // binary copy: + fs::copy_file(m_boost_path / p, m_dest_path / dest_p); + } } }