Add timestamp to cache key for modules importing files. Fixes #141

felipesanches-svg
Marius Kintel 2012-07-14 21:57:41 -04:00
parent 3085bcc65c
commit 2495df6bab
5 changed files with 42 additions and 5 deletions

View File

@ -237,6 +237,7 @@ PolySet *ImportNode::evaluate_polyset(class PolySetEvaluator *) const
std::string ImportNode::toString() const
{
std::stringstream stream;
fs::path path(this->filename);
stream << this->name();
stream << "(file = " << this->filename << ", "
@ -244,7 +245,13 @@ std::string ImportNode::toString() const
"origin = [" << std::dec << this->origin_x << ", " << this->origin_y << "], "
"scale = " << this->scale << ", "
"convexity = " << this->convexity << ", "
"$fn = " << this->fn << ", $fa = " << this->fa << ", $fs = " << this->fs << ")";
"$fn = " << this->fn << ", $fa = " << this->fa << ", $fs = " << this->fs
#ifndef OPENSCAD_TESTING
// timestamp is needed for caching, but disturbs the test framework
<< ", " "timestamp = " << (fs::exists(path) ? fs::last_write_time(path) : 0)
#endif
<< ")";
return stream.str();
}

View File

@ -38,6 +38,9 @@
#include <boost/assign/std/vector.hpp>
using namespace boost::assign; // bring 'operator+=()' into scope
#include <boost/filesystem.hpp>
namespace fs = boost::filesystem;
class LinearExtrudeModule : public AbstractModule
{
public:
@ -143,11 +146,17 @@ std::string LinearExtrudeNode::toString() const
stream << this->name() << "(";
if (!this->filename.empty()) { // Ignore deprecated parameters if empty
fs::path path(this->filename);
stream <<
"file = " << this->filename << ", "
"layer = " << QuotedString(this->layername) << ", "
"origin = [" << this->origin_x << ", " << this->origin_y << "], "
"scale = " << this->scale << ", ";
"scale = " << this->scale << ", "
#ifndef OPENSCAD_TESTING
// timestamp is needed for caching, but disturbs the test framework
<< "timestamp = " << (fs::exists(path) ? fs::last_write_time(path) : 0) << ", "
#endif
;
}
stream <<
"height = " << std::dec << this->height << ", "

View File

@ -38,6 +38,9 @@
#include <boost/assign/std/vector.hpp>
using namespace boost::assign; // bring 'operator+=()' into scope
#include <boost/filesystem.hpp>
namespace fs = boost::filesystem;
class RotateExtrudeModule : public AbstractModule
{
public:
@ -112,11 +115,17 @@ std::string RotateExtrudeNode::toString() const
stream << this->name() << "(";
if (!this->filename.empty()) { // Ignore deprecated parameters if empty
fs::path path(this->filename);
stream <<
"file = " << this->filename << ", "
"layer = " << QuotedString(this->layername) << ", "
"origin = [" << std::dec << this->origin_x << ", " << this->origin_y << "], "
"scale = " << this->scale << ", ";
"scale = " << this->scale << ", "
#ifndef OPENSCAD_TESTING
// timestamp is needed for caching, but disturbs the test framework
<< "timestamp = " << (fs::exists(path) ? fs::last_write_time(path) : 0) << ", "
#endif
;
}
stream <<
"convexity = " << this->convexity << ", "

View File

@ -43,6 +43,9 @@
#include <boost/assign/std/vector.hpp>
using namespace boost::assign; // bring 'operator+=()' into scope
#include <boost/filesystem.hpp>
namespace fs = boost::filesystem;
class SurfaceModule : public AbstractModule
{
public:
@ -222,9 +225,15 @@ PolySet *SurfaceNode::evaluate_polyset(class PolySetEvaluator *) const
std::string SurfaceNode::toString() const
{
std::stringstream stream;
fs::path path(this->filename);
stream << this->name() << "(file = " << this->filename << ", "
"center = " << (this->center ? "true" : "false") << ")";
"center = " << (this->center ? "true" : "false")
#ifndef OPENSCAD_TESTING
// timestamp is needed for caching, but disturbs the test framework
<< ", " "timestamp = " << (fs::exists(path) ? fs::last_write_time(path) : 0)
#endif
<< ")";
return stream.str();
}

View File

@ -132,7 +132,10 @@ int main(int argc, char **argv)
fprintf(stderr, "Error: Unable to read back dumped file\n");
exit(1);
}
fs::current_path(original_path);
if (fs::path(filename).has_parent_path()) {
fs::current_path(fs::path(filename).parent_path());
}
AbstractNode::resetIndexCounter();
root_node = root_module->evaluate(&root_ctx, &root_inst);