|
View:
New views
4 Messages
—
Rating Filter:
Alert me
|
| < Prev | 1 - 2 | Next > |
|
|
Re: Using multiple versions of BoostPiyo wrote:
> Bjørn Roald wrote: > >> Piyo wrote: >> >>> I am open to any form of solution whether it be macro-based or bcp >>> >> If you intent to test the bcp approach, my code is a good way to start. >> > [snip] > >> > > Oh and my coworker also brought up this issue. Is that handled by bcp?? > > ------------------------------------------------------------------------ > Also, the issue of cpp guards needs to be raised also, like in > aligned_storage.hpp: > > #ifndef BOOST_ALIGNED_STORAGE_HPP > #define BOOST_ALIGNED_STORAGE_HPP > becomes: #ifndef BOOST_1_33_1_ALIGNED_STORAGE_HPP #define BOOST_1_33_1_ALIGNED_STORAGE_HPP or whatever other upercase string prefix is derived from your target namespace. So yes, it is handled. > You would want to be able to include multiple versions of boosts in the > same compilation unit. > > yes. -- Bjørn _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost |
|
|
Re: Using multiple versions of BoostJohn Maddock wrote:
> Bjørn Roald wrote: > >> Well -namespace=boost_1_34_0 actually does a bit more. It renames >> directories and include directives so stuff like >> >> #include <boost/filesystem/path.hpp> >> >> becomes >> >> #include <boost_1_34_0/filesystem/path.hpp> >> >> and should work. It also replaces all instances of BOOST_ prefix in >> preprocessor symbol definitions and references with BOOST_1_34_0_ and >> processes Jamfiles as well so my hope was that all should build, test, >> and work without touch up work. >> >> Also in the general case >> >> ../bin/boost/libs/filesystem/build/libboost_filesystem.a/gcc/debug/libboost_filesystem-gcc-d-1_33_1.a >> >> should become >> >> ../bin/boost_1_34_0/libs/filesystem/build/lib/boost_1_34_0_filesystem.a/gcc/debug/libboost_1_34_0_filesystem-gcc-d-1_33_1.a >> >> In this specific case the additional 1_34_0 substrings are just >> annoyance, so I guess we need to treat it as a special case when we >> have >> a version part of the new namespace. But as I said library path >> naming >> is not implemented yet. I guess this can be done by treating some >> configuration files for the build system. This may be outside the >> scope >> of the bcp tool. >> >> So.. given all this, are you still sure this is worth adding? >> > > Sure, why not. > > >> Also, is -namespace the best name for the command line option? >> > > Yep. > > >> I have working code and will happily merge with 1.34.0 version of bcp >> and provide you a patch. Then you can use what you like, fix what >> you >> like to fix, and dump what you don't like :-) >> > > OK :-) > > Cheers, John. > Ok, I will post a patch here within 2 or 3 days. -- Bjørn _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost |
|
|
Re: Using multiple versions of BoostBjørn Roald wrote:
> John Maddock wrote: > >> Bjørn Roald wrote: >> >> >>> I have working code and will happily merge with 1.34.0 version of bcp >>> and provide you a patch. Then you can use what you like, fix what >>> you >>> like to fix, and dump what you don't like :-) >>> >>> >> OK :-) >> >> Cheers, John. >> >> > > Ok, I will post a patch here within 2 or 3 days. > working well. I still want to test some more, and clean up the TODOs marked in the code. In addition I need to verify that I have not broken any features in bcp. I have only tested the new features I have added. But as of now, I hit the following problem while testing the new --namespace option: As I am testing against the regress tests in the 'status' directory of the target area after running with --cvs --namespace=ost. I am hitting a problem caused by bcp -cvs not copying all files in "libs/numeric/ublas/test/CVS/Entries" only these two files are copied: /concepts.cpp/1.2/Thu Feb 2 18:43:09 2006// /placement_new.cpp/1.8/Sun Jul 16 20:33:17 2006// ========= form of libs/numeric/ublas/test/CVS/Entries ========== ... /Jamfile/1.5/Thu Jun 8 20:40:17 2006/-ko/ /Jamfile.v2/1.7/Thu Jun 8 20:40:17 2006/-ko/ /README/1.2/Thu Jun 8 20:24:59 2006/-ko/ /concepts.cpp/1.2/Thu Feb 2 18:43:09 2006// /placement_new.cpp/1.8/Sun Jul 16 20:33:17 2006// /test1.cpp/1.1/Thu Jun 8 20:40:17 2006/-kk/ /test1.hpp/1.1/Thu Jun 8 20:40:17 2006/-kk/ /test11.cpp/1.2/Sun Jul 16 20:33:17 2006/-kk/ ... ======== from bcp/scan_cvs_tath.cpp ========= ... static const boost::regex file_expression("^(?:A\\s+)?/([^/\\n]+)/[^/\\n]*/[^/\\n]*/[^k/\\n]*(kb[^/\\n]*)?/[^/\\n]*"); ... Seems to me like the trouble is the "(kb[^/\\n]*)?" part of the regexp, which does not match "/-kk/" or "/-ko/" part of each entry. I am not familiar with the file format of the Entries file, so I wonder if this is intentional? As of the promised patch file; I am attaching a snapshot patch file of my merged bcp sources and one new source file. You can use these to see where I am heading. Any comments or suggestions are welcome. Remaining known issues: 1. Support custom file headers/footers to include in files treated with the --namespace option. Currently a hard coded text is used. 2. Fix logic so --unix-lines work in combination with --namespace and --diff-mode work when --namespace is not used 3. Special treatment, where necessary, of top level (BOOST_ROOT) jam files: project-root.jam, Jamfile.v2, boost-build.jam. In these files the general replace of the boost namespace is too general. 4. Exclusion of some source from treatment of the --namespace feature all together; e.g. too/jam/src. 5. most lines with ending braces of boost namespace in the boost sources seems to be marked with /* namespace boost */ or similar. Look into if this can be a simple way of locating them and support nested namespaces. 6. Verify that we have not broken standard bcp features. 7. Check validity of the change in add_path.cpp seems unrelated, but I could not find the code looking back a few versions in CVS. I guess I had added it to avoid annoying warnings from bcp and that it does the right thing? I will most likely not be able to work more on this before next weekend. -- Bjørn This file contains notes regarding enhansements to BOOST_ROOT/tools/bcp to support replacement of the boost namespace in sourcecode copied from the boost distrubution. ==================== HOWTO ====================== A new option: --namespace=ns set a namespace that will replace 'boost' is added to the bcp tool. This allow the user to specify a namespace to use as replacement for boost in exported source code. example use: > cd ~/src/boost > mkdir -p /tmp/testbcp/mylib > tools/bcp/run/bcp -cvs -namespace=mylib filesystem /tmp/testbcp/mylib later you can use > tools/bcp/run/bcp -cvs --namespace=spoost --diff-only filesystem /tmp/testbcp/mylib to only do the changes You can add boost-build.jam Jamfile Jamrules to the module-list on the bcp command line to get the top level build files needed to build the exported code. If you change the following 2 lines in the exported Jamfile [ glob-tree $(BOOST_ROOT)/boost/compatibility/cpp_c_headers : c* ] [ glob-tree $(BOOST_ROOT)/boost : *.hpp *.ipp *.h *.inc ] to [ glob-tree $(BOOST_ROOT)/mylib/compatibility/cpp_c_headers : c* ] [ glob-tree $(BOOST_ROOT)/mylib : *.hpp *.ipp *.h *.inc ] you can actually build the exported libraries with bjam. NOTE: see limitation regarding Boost.Build ================== TODO ========================= 1. Support replacing namespace boost with nested namespace, e.g. namespace boost ====> namespace mylib::boost or namespace boost ====> namespace mylib::stuff::platform 2. Better Boost.Build and Jamfile support in export =============== LIMITATIONS ====================== 1. Only replacement of boost namespace with single level namespace is suported. No replacement with nested namespace supported jet. 2. Boost.Build export not suported properly. Buildfiles are still configured for the "boost" name after export. E.g. libriaries built contain the string "boost" in their filenames. /* * * Copyright (c) 2005 Bjorn Roald * Use, modification and distribution is subject to the * Boost Software License, Version 1.0. (See accompanying file * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) * * This file implements the following: * void bcp_implementation::destination_path(const fs::path& p) * void bcp_implementation::copy_path_and_replace_namespace(const fs::path& p) */ #include "bcp_imp.hpp" #include <boost/filesystem/operations.hpp> #include <boost/algorithm/string.hpp> #include <boost/regex.hpp> #include <boost/tokenizer.hpp> #include <fstream> #include <sstream> #include <streambuf> #include <iterator> #include <algorithm> #include <set> #include <iostream> namespace { std::string expression_text; std::string format_string; std::string jamfile_expression_text; std::string jamfile_format_string; std::string header_text; std::string footer_text; std::string replacement_ns; std::string format_replacement_ns; std::string underscored_ns; std::string slashed_ns; std::string dashed_ns; boost::regex expression_cpp; boost::regex expression_jam; // some default data const char* header_text_default = "The following file was processed with $BOOST_ROOT/tools/bcp \n" "to change namespace and paths to include files. The intention \n" "of this processing is to allow non-boost library developers \n" "to use the boost libararies internally in their product without \n" "risking potential conflicts with the use of oter versions \n" "of boost together with their product."; const char* footer_text_default = " ***************** end of file ***************\n"; const int LL = 80; std::string make_comment(const fs::path& p, const std::string& comment) { // std::cout << "in make_comment()\n"; using std::string; string newline = "\n"; // TODO: need to handle configurable dos/unix/mac differences string block_prefix; string block_top_border; string block_bottom_border; string line_prefix; string block_postfix; string escape_this_string; string escaped_string; // c++ style static const boost::regex e_cpp( ".*\\." "(?:" "cxx|cpp|h|hxx|hpp|inc" ")", boost::regex::perl | boost::regex::icase); if ( boost::regex_match(p.leaf(), e_cpp) ) { block_top_border = "//" + std::string( LL-4, '-' ); line_prefix = "// "; block_bottom_border = block_top_border; } // shell style else { static const boost::regex e_shell( ".*\\." "(?:" "ch|in|jam|mk" ")|" "(makefile|Jamfile|Jamrules|configure)", boost::regex::perl | boost::regex::icase); if ( boost::regex_match(p.leaf(), e_shell) ) { block_top_border += "#" + std::string( LL-4, '=' ); line_prefix = "# "; block_bottom_border = block_top_border; } else { // c style static const boost::regex e_c( ".*\\." "(?:" "c|css" ")", boost::regex::perl | boost::regex::icase); if ( boost::regex_match(p.leaf(), e_c) ) { block_prefix = "/* "; line_prefix = " * "; block_postfix = " */"; block_top_border += "/" + std::string( LL-4, '*' ); block_bottom_border += " " + std::string( LL-4, '*' ) + '/'; escape_this_string = "\\*/"; escaped_string = ""; } } } // if we don't know how, we silently do not generate the comment if ( block_prefix == block_postfix && block_postfix == line_prefix && line_prefix.size() == 0 ) return string(); // fix any illegal internal character sequences string escaped_comment; if ( escape_this_string.size() > 0 ) escaped_comment = boost::regex_replace(comment, boost::regex(escape_this_string), escaped_string ); else escaped_comment = comment; string block; // generate single line comment if(escaped_comment.find('\n') == string::npos) { if ( block_prefix.size() == 0 ) block += line_prefix + escaped_comment; else block += block_prefix + escaped_comment + block_postfix; } else // generate multi line { block = block_top_border + newline + line_prefix; for ( unsigned int i = 0 ; i < escaped_comment.size() ; ++i ) { if ( escaped_comment[i] == '\n' ) block += newline + line_prefix; else block += escaped_comment[i]; } block += newline + block_bottom_border + newline; } // std::cout << "end make_comment()\n"; return block; } // list of directories to ignore, ie. leave files unchanged std::set<fs::path, path_less> leave_dirs; // list of files to ignore, ie. leave unchanged std::set<fs::path, path_less> leave_files; } bool bcp_implementation::diff_only_copy( const std::string& new_file, fs::path destination_path ) { bool diff_found = false; fs::path tmp_path = destination_path.string() + ".bcptmp"; { // write temp file scope fs::remove( tmp_path ); std::ofstream tmp_fs(tmp_path.native_file_string().c_str()); tmp_fs << new_file; // write to tmp destination file } // close file at end of scope if ( fs::exists( destination_path ) && fs::file_size( destination_path ) == fs::file_size( tmp_path ) ) { std::ifstream dest( destination_path.string().c_str() ); std::ifstream tmp( tmp_path.string().c_str() ); diff_found = !std::equal(std::istream_iterator<char>( tmp ), std::istream_iterator<char>(), std::istream_iterator<char>( dest ) ); } else diff_found = true; if ( diff_found ) // move tmp to destination { fs::remove( destination_path ); fs::rename( tmp_path, destination_path ); } else fs::remove( tmp_path ); return diff_found; } void bcp_implementation::set_replacement_namespace(const char* ns) { replacement_ns = ns; m_replace_namespace = true; // set default data, TODO: improve so header and footer can be configured header_text = header_text_default; footer_text = footer_text_default; boost::regex re("::"); underscored_ns = boost::regex_replace(replacement_ns, re, "_"); slashed_ns = boost::regex_replace(replacement_ns, re, "/"); dashed_ns = boost::regex_replace(replacement_ns, re, "-"); // escape hell follows, format string for replacing :: need to be "\:\:" // to avoid colons being interpetet as else in conditional format, // see http://www.boost.org/libs/regex/doc/format_boost_syntax.html format_replacement_ns = boost::regex_replace(replacement_ns, re, "\\\\:\\\\:"); std::string macrofied_ns( underscored_ns ); boost::to_upper( macrofied_ns ); std::cout << "replacement_ns = " << replacement_ns << std::endl << "format_replacement_ns = " << format_replacement_ns << std::endl << "underscored_ns = " << underscored_ns << std::endl << "slashed_ns = " << slashed_ns << std::endl << "dashed_ns = " << dashed_ns << std::endl << "macrofied_ns = " << macrofied_ns << std::endl; expression_text = // don't replace referances: index 1 "(www.boost.org)|" // replace namespace: index 2 "(boost)|" // macro defs: index 3 "(BOOST)" ; expression_cpp = boost::regex(expression_text); format_string = format_string + "(?1www.boost.org)" + "(?2" + format_replacement_ns + ")" + "(?3" + macrofied_ns + ")"; std::cout << "expression_text = " << expression_text << std::endl; std::cout << "format_string = " << format_string << std::endl; jamfile_expression_text = // don't replace referances: index 1 "(www.boost.org)|" // macro defs: index 2 "(BOOST)|" // paths to include dir: index 3 "(/boost/)" ; expression_jam = boost::regex(jamfile_expression_text); jamfile_format_string = jamfile_format_string + "(?1www.boost.org)" + "(?2" + macrofied_ns + ")" + "(?3/" + slashed_ns + "/)"; // leave_dirs.insert( "libs/wave/test/testwave/testfiles"); leave_files.insert( "libs/wave/test/testwave/testfiles/t_9_014.cpp" ); leave_files.insert( "libs/wave/test/testwave/testfiles/t_9_015.cpp" ); leave_files.insert( "libs/wave/test/testwave/testfiles/t_1_001.cpp" ); leave_files.insert( "libs/wave/test/testwave/testfiles/t_1_002.cpp" ); leave_files.insert( "libs/wave/test/testwave/testfiles/t_1_003.cpp" ); leave_files.insert( "libs/wave/test/testwave/testfiles/t_1_004.cpp" ); } fs::path bcp_implementation::destination_path(fs::path p, std::string seperator) { // std::cout << "in destination_path\n"; using std::string; if ( ! m_replace_namespace ) return p; fs::path result; // check for directory named "boost" in in path by // by checking elements in path and rebuilding // the path with replacement for ( fs::path::iterator el = p.begin(); el != p.end(); ++el ) { string element; if ( *el == "boost" ) // directory named boost { element = slashed_ns; } else if ( el->find( "boost" ) != string::npos && *el != "boost-build.jam" && *el != "boost-base.jam" ) { // string "boost" is part of a directory/file name // need to determine how to replace it, use underscore for now element = boost::regex_replace( *el, boost::regex( "boost" ), underscored_ns ); } else { element = *el; } result /= element; } return result; } // intended to be called from inside copy_path() method void bcp_implementation::replace_namespace(const fs::path& p) { // std::cout << "in replace_namespace\n"; assert(m_replace_namespace && !is_binary_file(p)); fs::path dest_p = destination_path( p ); try { // std::cout << "Processing file " // << ( m_boost_path / p).native_file_string().c_str() // << std::endl; std::ifstream fs(( m_boost_path / p).native_file_string().c_str()); std::string in; in.reserve(fs.rdbuf()->in_avail()); char c; while(fs.get(c)) { if(in.capacity() == in.size()) in.reserve(in.capacity() * 3); in.append(1, c); } bool leave_it_unchanged = leave_dirs.find( p.branch_path() ) != leave_dirs.end() || leave_files.find( p ) != leave_files.end(); std::stringstream os; if ( ! leave_it_unchanged ) { std::string file_hdr = header_text; file_hdr += "\nnamespace 'boost' has been replaced with namespace '" + replacement_ns + "'.\n" + "original file: BOOST_PATH/" + p.string(); os << make_comment( p, file_hdr ); std::ostream_iterator<char, char> out(os); if ( is_bjam_file( p ) ) { boost::regex_replace(out, in.begin(), in.end(), expression_jam, jamfile_format_string, boost::match_default | boost::format_all); } else { boost::regex_replace(out, in.begin(), in.end(), expression_cpp, format_string, boost::match_default | boost::format_all); } os << std::endl << make_comment( p, footer_text ) << std::endl; } else { os << in; } fs::path dest = m_dest_path / dest_p; // diff against existing destination file // then write only if there is a difference, purpose // of this is to avoid excessive rebuilds when maintaining // boost code and testing in a bcp generated source tree if ( m_diff_only_mode ) { if ( diff_only_copy( os.str(), dest ) ) { std::cout << "Writing diff:\t" << dest.string() << std::endl; // fs::remove( dest ); // std::ofstream ofs(dest.native_file_string().c_str()); // ofs << os.str(); // write to destination file } else { std::cout << "Identical:\t" << dest.string() << std::endl; } } else { std::cout << "Writing: \t" << dest.string() << std::endl; fs::remove( dest ); std::ofstream ofs(dest.native_file_string().c_str()); ofs << os.str(); // write to destination file } } catch(std::exception& e) { std::cout << "error: replace_namespace: " << e.what() << "\n"; exit(1); } catch(...) { std::cout << "error: replace_namespace : unexpected exception \n"; exit(1); } } ? bjornr_notes.txt ? replace_namespace.cpp Index: Jamfile =================================================================== RCS file: /cvsroot/boost/boost/tools/bcp/Jamfile,v retrieving revision 1.3 diff -d -u -r1.3 Jamfile --- Jamfile 16 Jul 2006 11:31:52 -0000 1.3 +++ Jamfile 20 May 2007 14:01:50 -0000 @@ -5,7 +5,8 @@ subproject tools/bcp ; exe bcp - : add_path.cpp bcp_imp.cpp copy_path.cpp file_types.cpp + : add_path.cpp bcp_imp.cpp copy_path.cpp + replace_namespace.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 <lib>../../libs/filesystem/build/boost_filesystem Index: Jamfile.v2 =================================================================== RCS file: /cvsroot/boost/boost/tools/bcp/Jamfile.v2,v retrieving revision 1.4 diff -d -u -r1.4 Jamfile.v2 --- Jamfile.v2 16 Jul 2006 11:31:52 -0000 1.4 +++ Jamfile.v2 20 May 2007 14:01:50 -0000 @@ -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: add_path.cpp =================================================================== RCS file: /cvsroot/boost/boost/tools/bcp/add_path.cpp,v retrieving revision 1.12 diff -d -u -r1.12 add_path.cpp --- add_path.cpp 19 Feb 2006 16:19:02 -0000 1.12 +++ add_path.cpp 20 May 2007 14:01:50 -0000 @@ -123,6 +123,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: bcp.hpp =================================================================== RCS file: /cvsroot/boost/boost/tools/bcp/bcp.hpp,v retrieving revision 1.7 diff -d -u -r1.7 bcp.hpp --- bcp.hpp 10 Feb 2006 17:11:25 -0000 1.7 +++ bcp.hpp 20 May 2007 14:01:50 -0000 @@ -21,11 +21,13 @@ virtual void enable_summary_list_mode() = 0; virtual void enable_cvs_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: bcp_imp.cpp =================================================================== RCS file: /cvsroot/boost/boost/tools/bcp/bcp_imp.cpp,v retrieving revision 1.13 diff -d -u -r1.13 bcp_imp.cpp --- bcp_imp.cpp 10 Feb 2006 17:11:25 -0000 1.13 +++ bcp_imp.cpp 20 May 2007 14:01:51 -0000 @@ -71,6 +71,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: bcp_imp.hpp =================================================================== RCS file: /cvsroot/boost/boost/tools/bcp/bcp_imp.hpp,v retrieving revision 1.8 diff -d -u -r1.8 bcp_imp.hpp --- bcp_imp.hpp 10 Feb 2006 17:11:25 -0000 1.8 +++ bcp_imp.hpp 20 May 2007 14:01:51 -0000 @@ -52,11 +52,13 @@ void enable_summary_list_mode(); void enable_cvs_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); @@ -68,10 +70,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: @@ -84,6 +91,8 @@ bool m_license_mode; // generate license information for files listed bool m_cvs_mode; // check cvs 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: copy_path.cpp =================================================================== RCS file: /cvsroot/boost/boost/tools/bcp/copy_path.cpp,v retrieving revision 1.4 diff -d -u -r1.4 copy_path.cpp --- copy_path.cpp 30 Nov 2003 13:02:14 -0000 1.4 +++ copy_path.cpp 20 May 2007 14:01:51 -0000 @@ -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); + } } } Index: file_types.cpp =================================================================== RCS file: /cvsroot/boost/boost/tools/bcp/file_types.cpp,v retrieving revision 1.6 diff -d -u -r1.6 file_types.cpp --- file_types.cpp 3 Nov 2005 12:12:37 -0000 1.6 +++ file_types.cpp 20 May 2007 14:01:51 -0000 @@ -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); @@ -45,13 +46,27 @@ if(pos != m_cvs_paths.end()) return pos->second; } static const boost::regex e( - ".*\\." + "(.*\\." "(?:" "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: main.cpp =================================================================== RCS file: /cvsroot/boost/boost/tools/bcp/main.cpp,v retrieving revision 1.8 diff -d -u -r1.8 main.cpp --- main.cpp 10 Feb 2006 17:11:25 -0000 1.8 +++ main.cpp 20 May 2007 14:01:51 -0000 @@ -33,10 +33,12 @@ "\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 namespace 'ns' 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 existing original\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" @@ -123,12 +125,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: scan_cvs_path.cpp =================================================================== RCS file: /cvsroot/boost/boost/tools/bcp/scan_cvs_path.cpp,v retrieving revision 1.4 diff -d -u -r1.4 scan_cvs_path.cpp --- scan_cvs_path.cpp 3 Nov 2005 12:12:37 -0000 1.4 +++ scan_cvs_path.cpp 20 May 2007 14:01:51 -0000 @@ -29,7 +29,7 @@ static const boost::regex dir_expression("^(?:A\\s+)?D/([^/\\n]+)/"); static const int file_subs[] = {1,2,}; - for(int entry = 0; entry < sizeof(file_list)/sizeof(file_list[0]); ++entry) + for(unsigned int entry = 0; entry < sizeof(file_list)/sizeof(file_list[0]); ++entry) { fs::path entries(m_boost_path / p / file_list[entry]); if(fs::exists(entries)) _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost |
|
|
Re: Using multiple versions of Booston Wed May 16 2007, Piyo <cybermax_69-AT-yahoo.com> wrote: > I am open to any form of solution whether it be macro-based or bcp or > Xerces style. I just find it sad that I am stopping 1.34 from entering > our company on purpose because I do not think that adding to our > existing 1.32 and 1.33.1 installations will help. Is there anyway we can > get the core boost developers to look into this? It's an important problem (it's been raised several times), but that said, what do you think the core boost developers can "look into" that you can't? Most of the core devels are probably not as familiar with the problem as you are. My suggestion is that you write up a concrete proposal for what we should do, what the consequences are, and how it should be used, and post it to this list. We'll discuss it. Once semi-stable it should go on a wiki, and we'll have to decide if it should be adopted. There are many different tools you could use to approach this, in various combinations, with different implications: namespace aliases macros using declarations using directives nested namespaces I'd want to see that you had considered all the viable permutations and chosen the best one. > Since I am the only boost-evangelist here, I can't imagine me > stopping progress over something like this. > > HELP!! :) What can we do to help? -- Dave Abrahams Boost Consulting http://www.boost-consulting.com _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost |
| < Prev | 1 - 2 | Next > |
| Free embeddable forum powered by Nabble | Forum Help |