diff options
| -rw-r--r-- | src/ModuleCache.cc | 29 | ||||
| -rw-r--r-- | src/module.cc | 4 | ||||
| -rw-r--r-- | src/parsersettings.cc | 13 | 
3 files changed, 26 insertions, 20 deletions
| diff --git a/src/ModuleCache.cc b/src/ModuleCache.cc index 505015e..0e443e8 100644 --- a/src/ModuleCache.cc +++ b/src/ModuleCache.cc @@ -30,34 +30,37 @@ ModuleCache *ModuleCache::inst = NULL;  */  FileModule *ModuleCache::evaluate(const std::string &filename)  { +	bool shouldCompile = true;  	FileModule *lib_mod = NULL;  	// Create cache ID  	struct stat st;  	memset(&st, 0, sizeof(struct stat)); -	stat(filename.c_str(), &st); +	bool valid = (stat(filename.c_str(), &st) == 0);  	std::string cache_id = str(boost::format("%x.%x") % st.st_mtime % st.st_size);  	// Lookup in cache -	if (this->entries.find(filename) != this->entries.end() &&  -			this->entries[filename].cache_id == cache_id) { -#ifdef DEBUG -// Causes too much debug output -//		PRINTB("Using cached library: %s (%s)", filename % cache_id); -#endif +	if (this->entries.find(filename) != this->entries.end()) {  		lib_mod = &(*this->entries[filename].module); - -		BOOST_FOREACH(const FileModule::IncludeContainer::value_type &include, lib_mod->includes) { -			if (lib_mod->include_modified(include.second)) { -				lib_mod = NULL; -				break; +		if (this->entries[filename].cache_id == cache_id) { +			shouldCompile = false; +			 +			BOOST_FOREACH(const FileModule::IncludeContainer::value_type &include, lib_mod->includes) { +				if (lib_mod->include_modified(include.second)) { +					lib_mod = NULL; +					shouldCompile = true; +					break; +				}  			}  		}  	} +	else { +		shouldCompile = valid; +	}  	// If cache lookup failed (non-existing or old timestamp), compile module -	if (!lib_mod) { +	if (shouldCompile) {  #ifdef DEBUG  		if (this->entries.find(filename) != this->entries.end()) {  			PRINTB("Recompiling cached library: %s (%s)", filename % cache_id); diff --git a/src/module.cc b/src/module.cc index 425403b..080a3dd 100644 --- a/src/module.cc +++ b/src/module.cc @@ -228,9 +228,11 @@ bool FileModule::handleDependencies()  		FileModule::ModuleContainer::iterator curr = iter++;  		FileModule *oldmodule = curr->second; +		bool wasmissing = false;  		// Get an absolute filename for the module  		std::string filename = curr->first;  		if (!boosty::is_absolute(filename)) { +			wasmissing = true;  			fs::path fullpath = find_valid_path(this->path, filename);  			if (!fullpath.empty()) filename = boosty::stringy(fullpath);  		} @@ -242,7 +244,7 @@ bool FileModule::handleDependencies()  			PRINTB_NOCACHE("  %s: %p", filename % curr->second);  #endif  		} -		if (!curr->second) { +		if (!curr->second && !wasmissing) {  			PRINTB_NOCACHE("WARNING: Failed to compile library '%s'.", filename);  		}  	} diff --git a/src/parsersettings.cc b/src/parsersettings.cc index 8db33a8..ab93b78 100644 --- a/src/parsersettings.cc +++ b/src/parsersettings.cc @@ -30,23 +30,24 @@ fs::path search_libs(const fs::path &localpath)  }  // files must be 'ordinary' - they must exist and be non-directories +// FIXME: We cannot print any output here since these function is called periodically +// from "Automatic reload and compile"  static bool check_valid(const fs::path &p, const std::vector<std::string> *openfilenames)  {  	if (p.empty()) { -		PRINTB("WARNING: File path is blank: %s",p); +//		PRINTB("WARNING: File path is blank: %s",p);  		return false;  	}  	if (!p.has_parent_path()) { -		PRINTB("WARNING: No parent path: %s",p); +//		PRINTB("WARNING: No parent path: %s",p);  		return false;  	}  	if (!fs::exists(p)) { -		PRINTB("WARNING: File not found: %s",p); -		// searched === +//		PRINTB("WARNING: File not found: %s",p);  		return false;  	}  	if (fs::is_directory(p)) { -		PRINTB("WARNING: %s invalid - points to a directory",p); +//		PRINTB("WARNING: %s invalid - points to a directory",p);  		return false;  	}  	std::string fullname = boosty::stringy(p); @@ -54,7 +55,7 @@ static bool check_valid(const fs::path &p, const std::vector<std::string> *openf  	if (openfilenames) {  		BOOST_FOREACH(const std::string &s, *openfilenames) {  			if (s == fullname) { -				PRINTB("WARNING: circular include file %s", fullname); +//				PRINTB("WARNING: circular include file %s", fullname);  				return false;  			}  		} | 
