diff options
author | Marius Kintel <marius@kintel.net> | 2012-10-30 13:43:49 (GMT) |
---|---|---|
committer | Marius Kintel <marius@kintel.net> | 2012-10-30 13:43:49 (GMT) |
commit | 467f8968434c9a46c17edae1bfdba5eb1c756eff (patch) | |
tree | b44bfd37aaa8a835af72bbde9426895ea9c85b04 | |
parent | 73d8d3cca4de55e81d47732f2b1f9507cc0d23b4 (diff) | |
parent | 65c57886769b86cf785ab2049d32311c4c52126a (diff) |
Merge branch 'master' into issue202svg
-rw-r--r-- | RELEASE_NOTES | 11 | ||||
-rw-r--r-- | doc/TODO.txt | 2 | ||||
-rwxr-xr-x | scripts/macosx-build-dependencies.sh | 67 | ||||
-rw-r--r-- | setenv_mac-clang.sh | 12 | ||||
-rw-r--r-- | src/ModuleCache.cc | 6 | ||||
-rw-r--r-- | src/lexer.l | 11 | ||||
-rw-r--r-- | src/parsersettings.cc | 10 | ||||
-rw-r--r-- | testdata/modulecache-tests/README.txt | 26 | ||||
-rw-r--r-- | testdata/modulecache-tests/circularincludefirst.scad | 1 | ||||
-rw-r--r-- | testdata/modulecache-tests/circularincludemain.scad | 1 | ||||
-rw-r--r-- | testdata/modulecache-tests/circularincludesecond.scad | 1 |
11 files changed, 116 insertions, 32 deletions
diff --git a/RELEASE_NOTES b/RELEASE_NOTES index 32f3788..f629cd6 100644 --- a/RELEASE_NOTES +++ b/RELEASE_NOTES @@ -1,4 +1,4 @@ -OpenSCAD 2012.XX +OpenSCAD 2012.11 ================ Features: @@ -9,6 +9,9 @@ o Added Dot product operator: vec * vec o Added Matrix multiplication operator: vec * mat, mat * mat o Added search() function o Dependencies are now tracked - any changes in uses/included files will be detected and cause a recompile +o The OPENSCADPATH environment variable is now implemented will have precedence when searching for libraries +o .csg files can now be opened from the GUI +o linear_extrude() will now assume that the first parameter means 'height' if it's a number Bugfixes: o use'ing an non-existing file sometimes crashed under Windows @@ -19,6 +22,12 @@ o Fixed crashes in shared_ptr.hpp (or similar places) due bugs in cache manageme o scale() with a scale factor of zero could cause a crash o Fixed a number of issues related to use/include o Providing an unknown parameter on the cmd-line caused a crash +o cmd-line overrides using -D now also work for USEd modules +o Modifier characters can now be used in front of if statements +o rotate() with a vector argument with less that 3 elements used uninitialized variables, ending up being non-deterministic. +o .csg files will now have relative filenames whenever possible +o A lot of build script fixes +o Some other crash bugs fixes Deprecations: o The old include syntax "<filename.scad>" without the include keyword is no diff --git a/doc/TODO.txt b/doc/TODO.txt index 7f8378d..be70c26 100644 --- a/doc/TODO.txt +++ b/doc/TODO.txt @@ -239,6 +239,8 @@ o Collect "all" available OpenSCAD scripts from the internets and run the integr MISSING TESTS: -------------- +o cmd-line -D variable override +o OPENSCADPATH env.variable o all functions o mirror o scale diff --git a/scripts/macosx-build-dependencies.sh b/scripts/macosx-build-dependencies.sh index 73e4118..1036320 100755 --- a/scripts/macosx-build-dependencies.sh +++ b/scripts/macosx-build-dependencies.sh @@ -9,6 +9,7 @@ # Usage: macosx-build-dependencies.sh [-6l] # -6 Build only 64-bit binaries # -l Force use of LLVM compiler +# -c Force use of clang compiler # # Prerequisites: # - MacPorts: curl, cmake @@ -26,14 +27,18 @@ DEPLOYDIR=$BASEDIR/install MAC_OSX_VERSION_MIN=10.5 OPTION_32BIT=true OPTION_LLVM=false +OPTION_CLANG=false +OPTION_GCC=false +DETECTED_LION=false export QMAKESPEC=macx-g++ printUsage() { - echo "Usage: $0 [-6l]" + echo "Usage: $0 [-6lc]" echo echo " -6 Build only 64-bit binaries" echo " -l Force use of LLVM compiler" + echo " -c Force use of clang compiler" } # Hack warning: gmplib is built separately in 32-bit and 64-bit mode @@ -180,16 +185,21 @@ build_boost() tar xjf boost_$bversion.tar.bz2 cd boost_$bversion # We only need the thread and program_options libraries - ./bootstrap.sh --prefix=$DEPLOYDIR --with-libraries=thread,program_options,filesystem,system,regex + ./bootstrap.sh --prefix=$DEPLOYDIR --with-libraries=thread,program_options,filesystem,chrono,system,regex if $OPTION_32BIT; then BOOST_EXTRA_FLAGS="-arch i386" fi if $OPTION_LLVM; then BOOST_TOOLSET="toolset=darwin-llvm" echo "using darwin : llvm : llvm-g++ ;" >> tools/build/v2/user-config.jam + elif $OPTION_CLANG; then + BOOST_TOOLSET="toolset=clang" + echo "using clang ;" >> tools/build/v2/user-config.jam fi ./b2 -d+2 $BOOST_TOOLSET cflags="-mmacosx-version-min=$MAC_OSX_VERSION_MIN -arch x86_64 $BOOST_EXTRA_FLAGS" linkflags="-mmacosx-version-min=$MAC_OSX_VERSION_MIN -arch x86_64 $BOOST_EXTRA_FLAGS" install install_name_tool -id $DEPLOYDIR/lib/libboost_thread.dylib $DEPLOYDIR/lib/libboost_thread.dylib + install_name_tool -change libboost_system.dylib $DEPLOYDIR/lib/libboost_system.dylib $DEPLOYDIR/lib/libboost_thread.dylib + install_name_tool -change libboost_chrono.dylib $DEPLOYDIR/lib/libboost_chrono.dylib $DEPLOYDIR/lib/libboost_thread.dylib install_name_tool -id $DEPLOYDIR/lib/libboost_program_options.dylib $DEPLOYDIR/lib/libboost_program_options.dylib install_name_tool -id $DEPLOYDIR/lib/libboost_filesystem.dylib $DEPLOYDIR/lib/libboost_filesystem.dylib install_name_tool -change libboost_system.dylib $DEPLOYDIR/lib/libboost_system.dylib $DEPLOYDIR/lib/libboost_filesystem.dylib @@ -206,8 +216,10 @@ build_cgal() cd $BASEDIR/src rm -rf CGAL-$version if [ ! -f CGAL-$version.tar.gz ]; then - # 4.0.2 - curl -O https://gforge.inria.fr/frs/download.php/31175/CGAL-$version.tar.gz + # 4.1 + curl -O https://gforge.inria.fr/frs/download.php/31641/CGAL-$version.tar.gz + # 4.1-beta1 curl -O https://gforge.inria.fr/frs/download.php/31348/CGAL-$version.tar.gz + # 4.0.2 curl -O https://gforge.inria.fr/frs/download.php/31175/CGAL-$version.tar.gz # 4.0 curl -O https://gforge.inria.fr/frs/download.php/30387/CGAL-$version.tar.gz # 3.9 curl -O https://gforge.inria.fr/frs/download.php/29125/CGAL-$version.tar.gz # 3.8 curl -O https://gforge.inria.fr/frs/download.php/28500/CGAL-$version.tar.gz @@ -218,7 +230,7 @@ build_cgal() if $OPTION_32BIT; then CGAL_EXTRA_FLAGS=";i386" fi - cmake -DCMAKE_INSTALL_PREFIX=$DEPLOYDIR -DGMP_INCLUDE_DIR=$DEPLOYDIR/include -DGMP_LIBRARIES=$DEPLOYDIR/lib/libgmp.dylib -DGMPXX_LIBRARIES=$DEPLOYDIR/lib/libgmpxx.dylib -DGMPXX_INCLUDE_DIR=$DEPLOYDIR/include -DMPFR_INCLUDE_DIR=$DEPLOYDIR/include -DMPFR_LIBRARIES=$DEPLOYDIR/lib/libmpfr.dylib -DWITH_CGAL_Qt3=OFF -DWITH_CGAL_Qt4=OFF -DWITH_CGAL_ImageIO=OFF -DBUILD_SHARED_LIBS=TRUE -DCMAKE_OSX_DEPLOYMENT_TARGET="$MAC_OSX_VERSION_MIN" -DCMAKE_OSX_ARCHITECTURES="x86_64$CGAL_EXTRA_FLAGS" -DBOOST_ROOT=$DEPLOYDIR + cmake -DCMAKE_INSTALL_PREFIX=$DEPLOYDIR -DGMP_INCLUDE_DIR=$DEPLOYDIR/include -DGMP_LIBRARIES=$DEPLOYDIR/lib/libgmp.dylib -DGMPXX_LIBRARIES=$DEPLOYDIR/lib/libgmpxx.dylib -DGMPXX_INCLUDE_DIR=$DEPLOYDIR/include -DMPFR_INCLUDE_DIR=$DEPLOYDIR/include -DMPFR_LIBRARIES=$DEPLOYDIR/lib/libmpfr.dylib -DWITH_CGAL_Qt3=OFF -DWITH_CGAL_Qt4=OFF -DWITH_CGAL_ImageIO=OFF -DBUILD_SHARED_LIBS=TRUE -DCMAKE_OSX_DEPLOYMENT_TARGET="$MAC_OSX_VERSION_MIN" -DCMAKE_OSX_ARCHITECTURES="x86_64$CGAL_EXTRA_FLAGS" -DBOOST_ROOT=$DEPLOYDIR -DBoost_USE_MULTITHREADED=false make -j4 make install install_name_tool -id $DEPLOYDIR/lib/libCGAL.dylib $DEPLOYDIR/lib/libCGAL.dylib @@ -241,7 +253,7 @@ build_glew() if $OPTION_32BIT; then GLEW_EXTRA_FLAGS="-arch i386" fi - make GLEW_DEST=$DEPLOYDIR CFLAGS.EXTRA="-no-cpp-precomp -dynamic -fno-common -mmacosx-version-min=$MAC_OSX_VERSION_MIN $GLEW_EXTRA_FLAGS -arch x86_64" LDFLAGS.EXTRA="-mmacosx-version-min=$MAC_OSX_VERSION_MIN $GLEW_EXTRA_FLAGS -arch x86_64" STRIP= install + make GLEW_DEST=$DEPLOYDIR CC=$CC CFLAGS.EXTRA="-no-cpp-precomp -dynamic -fno-common -mmacosx-version-min=$MAC_OSX_VERSION_MIN $GLEW_EXTRA_FLAGS -arch x86_64" LDFLAGS.EXTRA="-mmacosx-version-min=$MAC_OSX_VERSION_MIN $GLEW_EXTRA_FLAGS -arch x86_64" STRIP= install } build_opencsg() @@ -301,33 +313,54 @@ if [ ! -f $OPENSCADDIR/openscad.pro ]; then exit 0 fi -while getopts '6l' c +while getopts '6lc' c do case $c in 6) OPTION_32BIT=false;; l) OPTION_LLVM=true;; + c) OPTION_CLANG=true;; esac done OSVERSION=`sw_vers -productVersion | cut -d. -f2` if [[ $OSVERSION -ge 7 ]]; then echo "Detected Lion or later" - export LION=1 - export CC=gcc - export CXX=g++ - export CPP=cpp - # Somehow, qmake in Qt-4.8.2 doesn't detect Lion's gcc and falls back into - # project file mode unless manually given a QMAKESPEC - export QMAKESPEC=macx-llvm + DETECTED_LION=true else echo "Detected Snow Leopard or earlier" fi +USING_LLVM=false +USING_GCC=false +USING_CLANG=false if $OPTION_LLVM; then - echo "Using LLVM compiler" + USING_LLCM=true +elif $OPTION_GCC; then + USING_GCC=true +elif $OPTION_CLANG; then + USING_CLANG=true +elif $DETECTED_LION; then + USING_GCC=true +fi + +if $USING_LLVM; then + echo "Using gcc LLVM compiler" export CC=llvm-gcc export CXX=llvm-g++ export QMAKESPEC=macx-llvm +elif $USING_GCC; then + echo "Using gcc compiler" + export CC=gcc + export CXX=g++ + export CPP=cpp + # Somehow, qmake in Qt-4.8.2 doesn't detect Lion's gcc and falls back into + # project file mode unless manually given a QMAKESPEC + export QMAKESPEC=macx-llvm +elif $USING_CLANG; then + echo "Using clang compiler" + export CC=clang + export CXX=clang++ + export QMAKESPEC=unsupported/macx-clang fi echo "Using basedir:" $BASEDIR @@ -335,8 +368,8 @@ mkdir -p $SRCDIR $DEPLOYDIR build_eigen 3.1.1 build_gmp 5.0.5 build_mpfr 3.1.1 -build_boost 1.50.0 +build_boost 1.51.0 # NB! For CGAL, also update the actual download URL in the function -build_cgal 4.0.2 +build_cgal 4.1 build_glew 1.9.0 build_opencsg 1.3.2 diff --git a/setenv_mac-clang.sh b/setenv_mac-clang.sh new file mode 100644 index 0000000..2bc9234 --- /dev/null +++ b/setenv_mac-clang.sh @@ -0,0 +1,12 @@ +export OPENSCAD_LIBRARIES=$PWD/../libraries/install +export DYLD_LIBRARY_PATH=$OPENSCAD_LIBRARIES/lib +export QMAKESPEC=unsupported/macx-clang + +#export OPENCSGDIR=$PWD/../OpenCSG-1.3.0 +#export CGALDIR=$PWD/../install/CGAL-3.6 +#export QCODEEDITDIR=$PWD/../qcodeedit-2.2.3/install +#export DYLD_LIBRARY_PATH=$OPENCSGDIR/lib:$QCODEEDITDIR/lib + +# ccache: +export PATH=/opt/local/libexec/ccache:$PATH +export CCACHE_BASEDIR=$PWD/.. diff --git a/src/ModuleCache.cc b/src/ModuleCache.cc index c215342..19a3f84 100644 --- a/src/ModuleCache.cc +++ b/src/ModuleCache.cc @@ -72,7 +72,9 @@ Module *ModuleCache::evaluate(const std::string &filename) PRINTB("WARNING: Can't open library file '%s'\n", filename); return NULL; } - std::string text((std::istreambuf_iterator<char>(ifs)), std::istreambuf_iterator<char>()); + std::stringstream textbuf; + textbuf << ifs.rdbuf(); + textbuf << "\n" << commandline_commands; print_messages_push(); @@ -84,7 +86,7 @@ Module *ModuleCache::evaluate(const std::string &filename) this->entries[filename] = e; std::string pathname = boosty::stringy(fs::path(filename).parent_path()); - lib_mod = dynamic_cast<Module*>(parse(text.c_str(), pathname.c_str(), false)); + lib_mod = dynamic_cast<Module*>(parse(textbuf.str().c_str(), pathname.c_str(), false)); PRINTB_NOCACHE(" compiled module: %p", lib_mod); if (lib_mod) { diff --git a/src/lexer.l b/src/lexer.l index 1e3bd5b..63b0047 100644 --- a/src/lexer.l +++ b/src/lexer.l @@ -80,6 +80,7 @@ void includefile(); fs::path sourcepath(); std::vector<fs::path> path_stack; std::vector<FILE*> openfiles; +std::vector<std::string> openfilenames; std::string filename; std::string filepath; @@ -142,6 +143,7 @@ use[ \t\r\n>]*"<" { BEGIN(cond_use); } assert(!openfiles.empty()); fclose(openfiles.back()); openfiles.pop_back(); + openfilenames.pop_back(); } yypop_buffer_state(); if (!YY_CURRENT_BUFFER) @@ -227,10 +229,15 @@ void includefile() PRINTB("WARNING: Can't find 'include' file '%s'.", filename); } + std::string fullname = boosty::absolute(finfo).string(); + // Detect circular includes + BOOST_FOREACH(std::string &s, openfilenames) { + if (s == fullname) return; + } + filepath.clear(); path_stack.push_back(finfo.parent_path()); - std::string fullname = boosty::absolute(finfo).string(); handle_dep(fullname); currmodule->registerInclude(fullname); yyin = fopen(fullname.c_str(), "r"); @@ -240,6 +247,7 @@ void includefile() return; } openfiles.push_back(yyin); + openfilenames.push_back(fullname); filename.clear(); yypush_buffer_state(yy_create_buffer(yyin, YY_BUF_SIZE)); @@ -253,5 +261,6 @@ void lexerdestroy() { BOOST_FOREACH (FILE *f, openfiles) fclose(f); openfiles.clear(); + openfilenames.clear(); path_stack.clear(); } diff --git a/src/parsersettings.cc b/src/parsersettings.cc index 47859c7..3dda132 100644 --- a/src/parsersettings.cc +++ b/src/parsersettings.cc @@ -28,7 +28,15 @@ std::string locate_file(const std::string &filename) void parser_init(const std::string &applicationpath) { - // FIXME: Append paths from OPENSCADPATH before adding built-in paths + // Add path from OPENSCADPATH before adding built-in paths + const char *openscadpath = getenv("OPENSCADPATH"); + if (openscadpath) { + add_librarydir(boosty::absolute(fs::path(openscadpath)).string()); + } + + // FIXME: Support specifying more than one path in OPENSCADPATH + // FIXME: Add ~/.openscad/libraries + // FIXME: Add ~/Documents/OpenSCAD/libraries on Mac? std::string librarydir; fs::path libdir(applicationpath); diff --git a/testdata/modulecache-tests/README.txt b/testdata/modulecache-tests/README.txt index 463261c..277cff8 100644 --- a/testdata/modulecache-tests/README.txt +++ b/testdata/modulecache-tests/README.txt @@ -5,13 +5,13 @@ Compile OpenSCAD in debug mode. This will give console output related to module /path/to/used.scad: 0x103612f70 Module cache size: 1 modules -Test1: +Test1: Basic cache ------ o Open use.scad o Compile twice (F5) - check that module reference is the same -Test2: +Test2: Dependency tracking of USE ------ o Open use.scad @@ -19,42 +19,42 @@ o Compile (F5) o touch used.scad o Compile (F5) - check that the module reference changed -Test3: +Test3: MCAD ------ o Open use-mcad.scad o Compile (F5) o Check that you get a rounded box -Test4: +Test4: USE Non-existing file ------ o Open usenonexsistingfile.scad o Compile (F5) o Verify that you get: WARNING: Can't open 'use' file 'nofile.scad'. -Test5: +Test5: Overload USEd module ------ o Open moduleoverload.scad o Compile (F5) o Verify that you get a sphere rather than a cylinder -Test6: +Test6: Recursive USE ------ o Open recursivemain.scad o Compile (F5) o Verify that OpenSCAD won't hang or crash -Test7: +Test7: Circular USE ------ o Open circularmain.scad o Compile (F5) o Verify that OpenSCAD won't hang or crash -Test8: +Test8: Dependency tracking of common file USEd by multiple modules ------ o Open multiplemain.scad @@ -64,7 +64,7 @@ o Edit multipleB.scad: + cube(2.5*F(), center=true); o Reload and Compile (F4) - verify that the cube got larger -Test9: +Test9: Dependency tracking of file included from module ------ o Open includefrommodule.scad @@ -72,4 +72,10 @@ o Compile (F5) - Verify that you get a circular disc o Edit radius.scad: Change RADIUS o Compile (F5) - Verify that the disc changed size -FIXME: Test circular include +Test9: Circular include +------ + +o Open circularincludemain.scad +o Compile (F5) +o Verify that OpenSCAD won't hang or crash + diff --git a/testdata/modulecache-tests/circularincludefirst.scad b/testdata/modulecache-tests/circularincludefirst.scad new file mode 100644 index 0000000..f94606a --- /dev/null +++ b/testdata/modulecache-tests/circularincludefirst.scad @@ -0,0 +1 @@ +include <circularincludesecond.scad> diff --git a/testdata/modulecache-tests/circularincludemain.scad b/testdata/modulecache-tests/circularincludemain.scad new file mode 100644 index 0000000..b973956 --- /dev/null +++ b/testdata/modulecache-tests/circularincludemain.scad @@ -0,0 +1 @@ +include <circularincludefirst.scad> diff --git a/testdata/modulecache-tests/circularincludesecond.scad b/testdata/modulecache-tests/circularincludesecond.scad new file mode 100644 index 0000000..b973956 --- /dev/null +++ b/testdata/modulecache-tests/circularincludesecond.scad @@ -0,0 +1 @@ +include <circularincludefirst.scad> |