diff --git a/scripts/uni-build-dependencies.sh b/scripts/uni-build-dependencies.sh index dc61f743..784a1915 100755 --- a/scripts/uni-build-dependencies.sh +++ b/scripts/uni-build-dependencies.sh @@ -513,7 +513,7 @@ if [ $1 ]; then exit $? fi if [ $1 = "cgal" ]; then - build_cgal 4.0.2 use-sys-libs + build_cgal 4.1 use-sys-libs exit $? fi if [ $1 = "opencsg" ]; then diff --git a/src/boost-utils.cc b/src/boost-utils.cc index 51270474..534cbaad 100644 --- a/src/boost-utils.cc +++ b/src/boost-utils.cc @@ -1,3 +1,4 @@ +#include "boosty.h" #include "boost-utils.h" #include #include @@ -7,8 +8,8 @@ fs::path boostfs_relative_path(const fs::path &path, const fs::path &relative_to) { // create absolute paths - fs::path p = fs::absolute(boostfs_normalize(path)); - fs::path r = fs::absolute(relative_to); + fs::path p = boosty::absolute(boostfs_normalize(path)); + fs::path r = boosty::absolute(relative_to); // if root paths are different, return absolute path if (p.root_path() != r.root_path()) @@ -46,16 +47,17 @@ fs::path boostfs_relative_path(const fs::path &path, const fs::path &relative_to // Will normalize the given path, i.e. remove any redundant ".." path elements. fs::path boostfs_normalize(const fs::path &path) { - fs::path absPath = absolute(path); + fs::path absPath = boosty::absolute(path); fs::path::iterator it = absPath.begin(); - fs::path result = *it++; + fs::path result = *it; + if (it!=absPath.end()) it++; // Get canonical version of the existing part for(;exists(result) && it != absPath.end(); ++it) { result /= *it; } - result = canonical(result.parent_path()); - --it; + result = boosty::canonical(result.parent_path()); + if (it!=absPath.begin()) it--; // For the rest remove ".." and "." in a path with no symlinks for (; it != absPath.end(); ++it) { @@ -98,8 +100,8 @@ boostfs_uncomplete(fs::path const p, fs::path const base) which it most likely is... but then base shouldn't be a filename so... */ // create absolute paths - fs::path abs_p = fs::absolute(boostfs_normalize(p)); - fs::path abs_base = fs::absolute(base); + fs::path abs_p = boosty::absolute(boostfs_normalize(p)); + fs::path abs_base = boosty::absolute(base); fs::path from_path, from_base, output; diff --git a/src/boosty.h b/src/boosty.h index 6ec417a6..5c820026 100644 --- a/src/boosty.h +++ b/src/boosty.h @@ -10,9 +10,8 @@ versions of boost found on popular versions of linux, circa early 2012. design - hope that the user is compiling with boost>1.46 + filesystem v3 - if not, fall back to older deprecated functions, and rely on - testing to find bugs. implement the minimum needed by OpenSCAD and no more. + the boost filsystem changed around 1.46-1.48. we do a large #ifdef + based on boost version that wraps various functions appropriately. in a few years, this file should be deleted as unnecessary. see also @@ -28,6 +27,7 @@ #include #include namespace fs = boost::filesystem; +#include "printutils.h" namespace boosty { @@ -77,6 +77,62 @@ inline std::string extension_str( fs::path p) #endif + + + + +#if BOOST_VERSION >= 104800 + +inline fs::path canonical( fs::path p, fs::path p2 ) +{ + return fs::canonical( p, p2, NULL ); +} + +inline fs::path canonical( fs::path p ) +{ + return fs::canonical( p, fs::current_path(), NULL ); +} + +#else + +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(".."); + fs::path result; + if (p=="") + { + p=p2; + } + for (fs::path::iterator itr = p.begin(); itr != p.end(); itr++) + { + 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. upgrade boost to >1.48"); + } + } + return result; +} + +inline fs::path canonical( fs::path p ) +{ + return canonical( p, fs::current_path() ); +} + +#endif + + + + } // namespace #endif diff --git a/src/value.cc b/src/value.cc index ae810a23..ebb825d4 100644 --- a/src/value.cc +++ b/src/value.cc @@ -39,7 +39,9 @@ std::ostream &operator<<(std::ostream &stream, const Filename &filename) { - stream << QuotedString(boosty::stringy(boostfs_uncomplete(filename, fs::current_path()))); + fs::path fnpath = fs::path( (std::string)filename ); + fs::path fpath = boostfs_uncomplete(fnpath, fs::current_path()); + stream << QuotedString(boosty::stringy( fpath )); return stream; }