X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fdependencycache.cpp;h=e91bdbc91da0e0e8f59c5ec3cf4b010b8b41a793;hb=f7e0a54c49480981a8d9bec064375323fce0aaf1;hp=ffc6fd63fbc7291c289395f9230abc78a83378ca;hpb=04c316da6d5d90e43cba262f54d90ca231f703bf;p=builder.git diff --git a/source/dependencycache.cpp b/source/dependencycache.cpp index ffc6fd6..e91bdbc 100644 --- a/source/dependencycache.cpp +++ b/source/dependencycache.cpp @@ -1,12 +1,5 @@ -/* $Id$ - -This file is part of builder -Copyright © 2007-2009 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ - +#include #include -#include #include #include #include @@ -28,21 +21,24 @@ void DependencyCache::set_deps(const string &tgt, const StringList &d) changed = true; } -const StringList &DependencyCache::get_deps(const string &tgt) const +bool DependencyCache::has_deps(const string &tgt) const { - DepsMap::const_iterator i = deps.find(tgt); - if(i==deps.end()) - throw KeyError("Unknown dependencies", tgt); + return deps.count(tgt); +} - return i->second; +const StringList &DependencyCache::get_deps(const string &tgt) const +{ + return get_item(deps, tgt); } void DependencyCache::save() const { - if(deps.empty() || !changed || package.get_builder().get_dry_run()) + if(deps.empty() || !changed) return; - IO::BufferedFile out((package.get_source()/".deps").str(), IO::M_WRITE); + FS::Path fn = package.get_source()/".deps"; + package.get_builder().get_logger().log("files", format("Writing %s", fn)); + IO::BufferedFile out(fn.str(), IO::M_WRITE); for(DepsMap::const_iterator i=deps.begin(); i!=deps.end(); ++i) { @@ -55,11 +51,12 @@ void DependencyCache::save() const void DependencyCache::load() { - string fn = (package.get_source()/".deps").str(); + FS::Path fn = package.get_source()/".deps"; - try + if(FS::Stat st = FS::stat(fn)) { - IO::BufferedFile in(fn); + package.get_builder().get_logger().log("files", format("Reading %s", fn)); + IO::BufferedFile in(fn.str()); string line; while(in.getline(line)) @@ -68,8 +65,6 @@ void DependencyCache::load() deps[parts[0]] = StringList(parts.begin()+1, parts.end()); } - mtime = Time::TimeStamp::from_unixtime(FS::stat(fn).st_mtime); + mtime = st.get_modify_time(); } - catch(const IO::FileNotFound &) - { } }