diff options
-rw-r--r-- | src/boosty.h | 80 | ||||
-rw-r--r-- | src/context.cc | 3 | ||||
-rw-r--r-- | src/handle_dep.cc | 3 | ||||
-rw-r--r-- | src/import.cc | 4 | ||||
-rw-r--r-- | src/lexer.l | 11 | ||||
-rw-r--r-- | src/openscad.cc | 13 | ||||
-rw-r--r-- | src/parser.y | 4 | ||||
-rw-r--r-- | src/parsersettings.cc | 11 | ||||
-rw-r--r-- | tests/CMakeLists.txt | 5 | ||||
-rw-r--r-- | tests/cgalcachetest.cc | 3 | ||||
-rw-r--r-- | tests/cgalpngtest.cc | 3 | ||||
-rw-r--r-- | tests/cgalstlsanitytest.cc | 3 | ||||
-rw-r--r-- | tests/cgaltest.cc | 3 | ||||
-rw-r--r-- | tests/csgtermtest.cc | 3 | ||||
-rw-r--r-- | tests/csgtestcore.cc | 3 | ||||
-rw-r--r-- | tests/csgtexttest.cc | 3 | ||||
-rw-r--r-- | tests/dumptest.cc | 3 | ||||
-rw-r--r-- | tests/echotest.cc | 3 |
18 files changed, 130 insertions, 31 deletions
diff --git a/src/boosty.h b/src/boosty.h new file mode 100644 index 0000000..588c2a9 --- /dev/null +++ b/src/boosty.h @@ -0,0 +1,80 @@ +// boosty.h copyright 2012 don bright. released under the GPL 2, or later, +// as described in the file named 'COPYING' in OpenSCAD's project root. + +#ifndef boosty_h_ +#define boosty_h_ + +/* + boosty is a wrapper around boost so that OpenSCAD can work with old + 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. + in a few years, this file should be deleted as unnecessary. + + see also + http://www.boost.org/doc/libs/1_48_0/libs/filesystem/v3/doc/index.htm + http://www.boost.org/doc/libs/1_42_0/libs/filesystem/doc/index.htm + http://www.boost.org/doc/libs/1_35_0/libs/filesystem/doc/index.htm + include/boost/wave/util/filesystem_compatability.hpp + +*/ + +#include <string> +#include <boost/version.hpp> +#include <boost/filesystem.hpp> +namespace fs = boost::filesystem; + +namespace boosty { + +#if BOOST_VERSION >= 104600 && BOOST_FILESYSTEM_VERSION >= 3 + +inline bool is_absolute( fs::path p ) +{ + return p.is_absolute(); +} + +inline fs::path absolute( fs::path p ) +{ + return fs::absolute( p ); +} + +inline std::string stringy( fs::path p ) +{ + return p.generic_string(); +} + +inline std::string extension_str( fs::path p) +{ + return p.extension().generic_string(); +} + +#else + +inline bool is_absolute( fs::path p ) +{ + return p.is_complete(); +} + +inline fs::path absolute( fs::path p ) +{ + return fs::complete( p ); +} + +inline std::string stringy( fs::path p ) +{ + return p.string(); +} + +inline std::string extension_str( fs::path p) +{ + return p.extension(); +} + +#endif + +} // namespace + +#endif diff --git a/src/context.cc b/src/context.cc index 354195f..8d7b903 100644 --- a/src/context.cc +++ b/src/context.cc @@ -33,6 +33,7 @@ #include <boost/foreach.hpp> #include <boost/filesystem.hpp> using namespace boost::filesystem; +#include "boosty.h" std::vector<const Context*> Context::ctx_stack; @@ -176,7 +177,7 @@ AbstractNode *Context::evaluate_module(const ModuleInstantiation &inst) const std::string Context::getAbsolutePath(const std::string &filename) const { if (!filename.empty()) { - return absolute(path(this->document_path) / filename).string(); + return boosty::absolute(path(this->document_path) / filename).string(); } else { return filename; diff --git a/src/handle_dep.cc b/src/handle_dep.cc index d642555..cbf7157 100644 --- a/src/handle_dep.cc +++ b/src/handle_dep.cc @@ -7,6 +7,7 @@ #include <boost/regex.hpp> #include <boost/filesystem.hpp> using namespace boost::filesystem; +#include "boosty.h" boost::unordered_set<std::string> dependencies; const char *make_command = NULL; @@ -14,7 +15,7 @@ const char *make_command = NULL; void handle_dep(const std::string &filename) { path filepath(filename); - if (filepath.is_absolute()) { + if ( boosty::is_absolute( filepath )) { dependencies.insert(filename); } else { diff --git a/src/import.cc b/src/import.cc index 435d06d..e90965e 100644 --- a/src/import.cc +++ b/src/import.cc @@ -50,6 +50,7 @@ using namespace boost::filesystem; #include <boost/assign/std/vector.hpp> using namespace boost::assign; // bring 'operator+=()' into scope +#include "boosty.h" class ImportModule : public AbstractModule { @@ -81,7 +82,8 @@ AbstractNode *ImportModule::evaluate(const Context *ctx, const ModuleInstantiati std::string filename = c.getAbsolutePath(v.text); import_type_e actualtype = this->type; if (actualtype == TYPE_UNKNOWN) { - std::string ext = boost::algorithm::to_lower_copy(path(filename).extension().string()); + std::string extraw = boosty::extension_str( path(filename) ); + std::string ext = boost::algorithm::to_lower_copy( extraw ); if (ext == ".stl") actualtype = TYPE_STL; else if (ext == ".off") actualtype = TYPE_OFF; else if (ext == ".dxf") actualtype = TYPE_DXF; diff --git a/src/lexer.l b/src/lexer.l index 718874f..77308a0 100644 --- a/src/lexer.l +++ b/src/lexer.l @@ -35,6 +35,7 @@ #include <boost/lexical_cast.hpp> #include <boost/filesystem.hpp> namespace fs = boost::filesystem; +#include "boosty.h" //isatty for visual c++ and mingw-cross-env #if defined __WIN32__ && ! defined _MSC_VER @@ -109,13 +110,13 @@ use[ \t\r\n>]*"<" { BEGIN(cond_use); } ">" { BEGIN(INITIAL); fs::path usepath; - if (fs::path(filename).is_absolute()) { + if ( boosty::is_absolute( fs::path(filename) ) ) { usepath = filename; } else { usepath = fs::path(parser_source_path) / filename; if (!fs::exists(usepath)) { - usepath = fs::absolute(fs::path(librarydir) / filename); + usepath = boosty::absolute(fs::path(librarydir) / filename); } } handle_dep(usepath.string()); @@ -198,7 +199,7 @@ void includefile() fs::path dirinfo = sourcepath(); if (!filepath.empty()) { - if (fs::path(filepath).is_absolute()) { + if (boosty::is_absolute( fs::path(filepath) ) ) { dirinfo = filepath; } else { @@ -214,8 +215,8 @@ void includefile() filepath.clear(); path_stack.push_back(dirinfo); - handle_dep(fs::absolute(finfo).string()); - yyin = fopen(fs::absolute(finfo).string().c_str(), "r"); + handle_dep(boosty::absolute(finfo).string()); + yyin = fopen(boosty::absolute(finfo).string().c_str(), "r"); if (!yyin) { PRINTF("WARNING: Can't open input file `%s'.", filename.c_str()); path_stack.pop_back(); diff --git a/src/openscad.cc b/src/openscad.cc index b29eafd..b4d1c0f 100644 --- a/src/openscad.cc +++ b/src/openscad.cc @@ -58,6 +58,7 @@ #include <boost/program_options.hpp> #include <boost/filesystem.hpp> +#include "boosty.h" #ifdef _MSC_VER #define snprintf _snprintf @@ -199,7 +200,7 @@ int main(int argc, char **argv) } #endif - currentdir = fs::current_path().generic_string(); + currentdir = boosty::stringy( fs::current_path() ); QDir exdir(QApplication::instance()->applicationDirPath()); #ifdef Q_WS_MAC @@ -273,11 +274,13 @@ int main(int argc, char **argv) } fclose(fp); text << commandline_commands; - root_module = parse(text.str().c_str(), fs::absolute(filename).generic_string().c_str(), false); + fs::path abspath = boosty::absolute( filename ); + std::string fname = boosty::stringy( abspath ); + root_module = parse(text.str().c_str(), fname.c_str(), false); if (!root_module) exit(1); } - fs::path fpath = fs::absolute(fs::path(filename)); + fs::path fpath = boosty::absolute( fs::path(filename) ); fs::path fparent = fpath.parent_path(); fs::current_path( fparent ); @@ -374,7 +377,9 @@ int main(int argc, char **argv) #endif QString qfilename; - if (filename) qfilename = QString::fromStdString(fs::absolute(filename).string()); + fs::path abspath = boosty::absolute( filename ); + std::string absname = boosty::stringy( abspath ); + if (filename) qfilename = QString::fromStdString( absname ); #if 0 /*** disabled by clifford wolf: adds rendering artefacts with OpenCSG ***/ // turn on anti-aliasing diff --git a/src/parser.y b/src/parser.y index 1c4a784..7e27bfe 100644 --- a/src/parser.y +++ b/src/parser.y @@ -44,6 +44,7 @@ #include <boost/filesystem.hpp> using namespace boost::filesystem; +#include "boosty.h" int parser_error_pos = -1; @@ -641,7 +642,8 @@ Module *Module::compile_library(const std::string &filename) libs_cache[filename] = e; Module *backup_mod = module; - Module *lib_mod = dynamic_cast<Module*>(parse(text.str().c_str(), path(filename).parent_path().generic_string().c_str(), 0)); + std::string pathname = boosty::stringy( fs::path(filename).parent_path() ); + Module *lib_mod = dynamic_cast<Module*>(parse(text.str().c_str(), pathname.c_str(), 0)); module = backup_mod; if (lib_mod) { diff --git a/src/parsersettings.cc b/src/parsersettings.cc index 2d0b1b3..330e2e2 100644 --- a/src/parsersettings.cc +++ b/src/parsersettings.cc @@ -2,6 +2,7 @@ #include <boost/filesystem.hpp> using namespace boost::filesystem; +#include "boosty.h" std::string librarydir; @@ -14,14 +15,14 @@ void parser_init(const std::string &applicationpath) if (!is_directory(libdir / "libraries")) libdir /= "../../.."; #elif defined(Q_OS_UNIX) if (is_directory(tmpdir = libdir / "../share/openscad/libraries")) { - librarydir = tmpdir.generic_string(); + librarydir = boosty::stringy( tmpdir ); } else if (is_directory(tmpdir = libdir / "../../share/openscad/libraries")) { - librarydir = tmpdir.generic_string(); + librarydir = boosty::stringy( tmpdir ); } else if (is_directory(tmpdir = libdir / "../../libraries")) { - librarydir = tmpdir.generic_string(); + librarydir = boosty::stringy( tmpdir ); } else #endif - if (is_directory(tmpdir = libdir / "libraries")) { - librarydir = tmpdir.generic_string(); + if (is_directory(tmpdir = libdir / "libraries")) { + librarydir = boosty::stringy( tmpdir ); } } diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 9d5e24e..4534b67 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -125,10 +125,7 @@ if (NOT $ENV{BOOSTDIR} STREQUAL "") message(STATUS "BOOST_ROOT: " ${BOOST_ROOT}) endif() -find_package( Boost 1.44.0 COMPONENTS thread program_options filesystem system regex REQUIRED) -if ( ${Boost_VERSION} VERSION_LESS "104601" ) - add_definitions( -DBOOST_FILESYSTEM_VERSION=3 ) -endif() +find_package( Boost 1.35.0 COMPONENTS thread program_options filesystem system regex REQUIRED) message(STATUS "Boost includes found: " ${Boost_INCLUDE_DIRS}) message(STATUS "Boost libraries found:") foreach(boostlib ${Boost_LIBRARIES}) diff --git a/tests/cgalcachetest.cc b/tests/cgalcachetest.cc index ad856d2..1680c6e 100644 --- a/tests/cgalcachetest.cc +++ b/tests/cgalcachetest.cc @@ -53,6 +53,7 @@ namespace fs = boost::filesystem; #include <boost/program_options.hpp> namespace po = boost::program_options; +#include "boosty.h" std::string commandline_commands; std::string currentdir; @@ -135,7 +136,7 @@ int main(int argc, char **argv) QApplication app(argc, argv, false); fs::path original_path = fs::current_path(); - currentdir = fs::current_path().generic_string(); + currentdir = boosty::stringy( fs::current_path() ); parser_init(QApplication::instance()->applicationDirPath().toStdString()); diff --git a/tests/cgalpngtest.cc b/tests/cgalpngtest.cc index ca37572..9002f3b 100644 --- a/tests/cgalpngtest.cc +++ b/tests/cgalpngtest.cc @@ -53,6 +53,7 @@ #include <boost/filesystem.hpp> namespace fs = boost::filesystem; +#include "boosty.h" std::string commandline_commands; std::string currentdir; @@ -108,7 +109,7 @@ int main(int argc, char **argv) QApplication app(argc, argv, false); fs::path original_path = fs::current_path(); - currentdir = fs::current_path().generic_string(); + currentdir = boosty::stringy( fs::current_path() ); parser_init(QApplication::instance()->applicationDirPath().toStdString()); diff --git a/tests/cgalstlsanitytest.cc b/tests/cgalstlsanitytest.cc index e537b4a..548ab44 100644 --- a/tests/cgalstlsanitytest.cc +++ b/tests/cgalstlsanitytest.cc @@ -52,6 +52,7 @@ #include <boost/filesystem.hpp> namespace fs = boost::filesystem; +#include "boosty.h" std::string commandline_commands; std::string currentdir; @@ -94,7 +95,7 @@ int main(int argc, char **argv) QApplication app(argc, argv, false); fs::path original_path = fs::current_path(); - currentdir = fs::current_path().generic_string(); + currentdir = boosty::stringy( fs::current_path() ); parser_init(QApplication::instance()->applicationDirPath().toStdString()); diff --git a/tests/cgaltest.cc b/tests/cgaltest.cc index 956bf43..4c23ee1 100644 --- a/tests/cgaltest.cc +++ b/tests/cgaltest.cc @@ -48,6 +48,7 @@ #include <boost/filesystem.hpp> namespace fs = boost::filesystem; +#include "boosty.h" std::string commandline_commands; std::string currentdir; @@ -87,7 +88,7 @@ int main(int argc, char **argv) QApplication app(argc, argv, false); fs::path original_path = fs::current_path(); - currentdir = fs::current_path().generic_string(); + currentdir = boosty::stringy( fs::current_path() ); parser_init(QApplication::instance()->applicationDirPath().toStdString()); diff --git a/tests/csgtermtest.cc b/tests/csgtermtest.cc index 016285e..a7369e8 100644 --- a/tests/csgtermtest.cc +++ b/tests/csgtermtest.cc @@ -49,6 +49,7 @@ #include <boost/filesystem.hpp> namespace fs = boost::filesystem; +#include "boosty.h" std::string commandline_commands; std::string currentdir; @@ -73,7 +74,7 @@ int main(int argc, char **argv) QApplication app(argc, argv, false); fs::path original_path = fs::current_path(); - currentdir = fs::current_path().generic_string(); + currentdir = boosty::stringy( fs::current_path() ); parser_init(QApplication::instance()->applicationDirPath().toStdString()); diff --git a/tests/csgtestcore.cc b/tests/csgtestcore.cc index 65e9127..b5a6224 100644 --- a/tests/csgtestcore.cc +++ b/tests/csgtestcore.cc @@ -34,6 +34,7 @@ namespace po = boost::program_options; namespace fs = boost::filesystem; +#include "boosty.h" using std::string; using std::vector; @@ -254,7 +255,7 @@ int csgtestcore(int argc, char *argv[], test_type_e test_type) fs::path original_path = fs::current_path(); - std::string currentdir = fs::current_path().generic_string(); + std::string currentdir = boosty::stringy( fs::current_path() ); parser_init(QApplication::instance()->applicationDirPath().toStdString()); diff --git a/tests/csgtexttest.cc b/tests/csgtexttest.cc index daed4e4..4a1c9c6 100644 --- a/tests/csgtexttest.cc +++ b/tests/csgtexttest.cc @@ -48,6 +48,7 @@ #include <boost/filesystem.hpp> namespace fs = boost::filesystem; +#include "boosty.h" std::string commandline_commands; std::string currentdir; @@ -77,7 +78,7 @@ int main(int argc, char **argv) QApplication app(argc, argv, false); fs::path original_path = fs::current_path(); - currentdir = fs::current_path().generic_string(); + currentdir = boosty::stringy( fs::current_path() ); parser_init(QApplication::instance()->applicationDirPath().toStdString()); diff --git a/tests/dumptest.cc b/tests/dumptest.cc index 6dd65a4..8353f26 100644 --- a/tests/dumptest.cc +++ b/tests/dumptest.cc @@ -46,6 +46,7 @@ #include <boost/filesystem.hpp> namespace fs = boost::filesystem; +#include "boosty.h" std::string commandline_commands; std::string currentdir; @@ -83,7 +84,7 @@ int main(int argc, char **argv) QApplication app(argc, argv, false); fs::path original_path = fs::current_path(); - currentdir = fs::current_path().generic_string(); + currentdir = boosty::stringy( fs::current_path() ); parser_init(QApplication::instance()->applicationDirPath().toStdString()); diff --git a/tests/echotest.cc b/tests/echotest.cc index 7abfd78..b881503 100644 --- a/tests/echotest.cc +++ b/tests/echotest.cc @@ -45,6 +45,7 @@ #include <boost/filesystem.hpp> namespace fs = boost::filesystem; +#include "boosty.h" std::string commandline_commands; std::string currentdir; @@ -85,7 +86,7 @@ int main(int argc, char **argv) QApplication app(argc, argv, false); fs::path original_path = fs::current_path(); - currentdir = fs::current_path().generic_string(); + currentdir = boosty::stringy( fs::current_path() ); parser_init(QApplication::instance()->applicationDirPath().toStdString()); |