diff options
author | don bright <hugh.m.bright@gmail.com> | 2013-03-21 03:29:54 (GMT) |
---|---|---|
committer | don bright <hugh.m.bright@gmail.com> | 2013-03-21 03:29:54 (GMT) |
commit | f242a7a6934effdb292c0fedafa954bafc615cc3 (patch) | |
tree | 1aa67e86d902fc9f3cd6a756ab36d0572e0318ed /src/boosty.h | |
parent | 3211e7f1e32cc0df415780f623e19f58c966266f (diff) |
backport to boost 1.37. improve dependency build for older lib versions
including the requirement of symlink to $DEPLOYDIR/include/boost if
boost is so old that it uses version numbers in the path name
Diffstat (limited to 'src/boosty.h')
-rw-r--r-- | src/boosty.h | 43 |
1 files changed, 24 insertions, 19 deletions
diff --git a/src/boosty.h b/src/boosty.h index 8b0c93e..82c765b 100644 --- a/src/boosty.h +++ b/src/boosty.h @@ -26,6 +26,7 @@ #include <string> #include <boost/version.hpp> #include <boost/filesystem.hpp> +#include <boost/algorithm/string.hpp> namespace fs = boost::filesystem; #include "printutils.h" @@ -97,29 +98,33 @@ inline fs::path canonical( fs::path p ) inline fs::path canonical( fs::path p, fs::path p2 ) { - // dotpath: win32/mac builds will be using newer versions of boost - // so we can treat this as though it is unix only - const fs::path dot_path("."); - const fs::path dot_dot_path(".."); +#if defined (__WIN32__) || defined(__APPLE__) +#error you should be using a newer version of boost on win/mac +#endif + // based on the code in boost fs::path result; - if (p=="") + if (p=="") p=p2; + std::string result_s; + std::vector<std::string> resultv, pieces; + std::vector<std::string>::iterator pi; + std::string tmps = boosty::stringy( p ); + boost::split( pieces, tmps, boost::is_any_of("/") ); + for ( pi = pieces.begin(); pi != pieces.end(); ++pi ) + { + if (*pi == "..") + resultv.erase( resultv.end() ); + else + resultv.push_back( *pi ); + } + for ( pi = resultv.begin(); pi != resultv.end(); ++pi ) { - p=p2; + if ((*pi).length()>0) result_s = result_s + "/" + *pi; } - for (fs::path::iterator itr = p.begin(); itr != p.end(); itr++) + result = fs::path( result_s ); + if (fs::is_symlink(result)) { - if (*itr == dot_path) continue; - if (*itr == dot_dot_path) - { - result.remove_filename(); - continue; - } - result /= *itr; - if (fs::is_symlink(result)) - { - PRINT("WARNING: canonical() wrapper can't do symlinks. rebuild openscad with boost >=1.48"); - PRINT("WARNING: or don't use symbolic links"); - } + PRINT("WARNING: canonical() wrapper can't do symlinks. rebuild openscad with boost >=1.48"); + PRINT("WARNING: or don't use symbolic links"); } return result; } |