diff options
author | Don Bright <hugh.m.bright@gmail.com> | 2012-05-28 16:48:46 (GMT) |
---|---|---|
committer | Don Bright <hugh.m.bright@gmail.com> | 2012-05-28 16:48:46 (GMT) |
commit | dd2002a81673b3875ce8c4e8a61cb10278c4eb03 (patch) | |
tree | 7aaadf1c9b12cd37a7a913d3e76256f6406fa939 /src/module.cc | |
parent | 4381762f5aa2e6a56258618e585e1510ead88684 (diff) | |
parent | 67eb2ebe90447e966dc1e08b91c43d937c521583 (diff) |
Tidy up code. Generate proper test png images. Merge branch 'master' into caliston1.
Conflicts:
src/PolySetCGALEvaluator.cc
Diffstat (limited to 'src/module.cc')
-rw-r--r-- | src/module.cc | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/src/module.cc b/src/module.cc index 6641ff7..fc849ff 100644 --- a/src/module.cc +++ b/src/module.cc @@ -25,13 +25,16 @@ */ #include "module.h" +#include "ModuleCache.h" #include "node.h" #include "context.h" #include "expression.h" #include "function.h" #include "printutils.h" + #include <boost/foreach.hpp> #include <sstream> +#include <sys/stat.h> AbstractModule::~AbstractModule() { @@ -201,7 +204,37 @@ std::string Module::dump(const std::string &indent, const std::string &name) con return dump.str(); } -void Module::clear_library_cache() +void Module::registerInclude(const std::string &filename) +{ + struct stat st; + memset(&st, 0, sizeof(struct stat)); + stat(filename.c_str(), &st); + this->includes[filename] = st.st_mtime; +} + +/*! + Check if any dependencies have been modified and recompile them. + Returns true if anything was recompiled. +*/ +bool Module::handleDependencies() { - Module::libs_cache.clear(); + bool changed = false; + // Iterating manually since we want to modify the container while iterating + Module::ModuleContainer::iterator iter = this->usedlibs.begin(); + while (iter != this->usedlibs.end()) { + Module::ModuleContainer::iterator curr = iter++; + Module *oldmodule = curr->second; + curr->second = ModuleCache::instance()->evaluate(curr->first); + if (curr->second != oldmodule) { + changed = true; +#ifdef DEBUG + PRINTB_NOCACHE(" %s: %p", curr->first % curr->second); +#endif + } + if (!curr->second) { + PRINTB_NOCACHE("WARNING: Failed to compile library '%s'.", curr->first); + this->usedlibs.erase(curr); + } + } + return changed; } |