X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fdependencycache.cpp;h=e91bdbc91da0e0e8f59c5ec3cf4b010b8b41a793;hb=5c16082773d2589c69fe4d7920e56fa66a96fc2b;hp=f691d540190f65da3444ec97823562b3fb05afcd;hpb=0458300fda4f345f865a7f3ee4fc0f2020a91983;p=builder.git diff --git a/source/dependencycache.cpp b/source/dependencycache.cpp index f691d54..e91bdbc 100644 --- a/source/dependencycache.cpp +++ b/source/dependencycache.cpp @@ -1,10 +1,3 @@ -/* $Id$ - -This file is part of builder -Copyright © 2007-2009 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ - #include #include #include @@ -28,6 +21,11 @@ void DependencyCache::set_deps(const string &tgt, const StringList &d) changed = true; } +bool DependencyCache::has_deps(const string &tgt) const +{ + return deps.count(tgt); +} + const StringList &DependencyCache::get_deps(const string &tgt) const { return get_item(deps, tgt); @@ -35,10 +33,12 @@ const StringList &DependencyCache::get_deps(const string &tgt) const 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) { @@ -51,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)) @@ -64,8 +65,6 @@ void DependencyCache::load() deps[parts[0]] = StringList(parts.begin()+1, parts.end()); } - mtime = FS::stat(fn).get_modify_time(); + mtime = st.get_modify_time(); } - catch(const IO::file_not_found &) - { } }