diff options
Diffstat (limited to 'src/module.cc')
-rw-r--r-- | src/module.cc | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/src/module.cc b/src/module.cc index 6641ff7..69623dd 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,33 @@ 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; + PRINTB_NOCACHE(" %s: %p", curr->first % curr->second); + if (!curr->second) { + PRINTB_NOCACHE("WARNING: Failed to compile library '%s'.", curr->first); + this->usedlibs.erase(curr); + } + } + return changed; } |