3 This file is part of builder
4 Copyright © 2006-2007 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
9 #include <msp/path/utils.h>
10 #include <msp/strings/utils.h>
12 #include "dependencycache.h"
18 DependencyCache::DependencyCache(Package &p):
23 const StringList &DependencyCache::get_deps(const string &tgt) const
25 DepsMap::const_iterator i=deps.find(tgt);
28 static StringList dummy;
34 void DependencyCache::set_deps(const string &tgt, const StringList &d)
41 Saves the depencency cache. If there are no cached dependencies or they
42 haven't been changed, does nothing.
44 void DependencyCache::save() const
46 if(deps.empty() || !changed || package.get_builder().get_dry_run())
49 ofstream out((package.get_source()/".deps").str().c_str());
53 for(DepsMap::const_iterator i=deps.begin(); i!=deps.end(); ++i)
56 for(StringList::const_iterator j=i->second.begin(); j!=i->second.end(); ++j)
62 void DependencyCache::load()
64 string fn=(package.get_source()/".deps").str();
65 ifstream in(fn.c_str());
70 while(getline(in, line))
72 vector<string> parts=split(line, '|');
73 deps[parts[0]]=StringList(parts.begin()+1, parts.end());
78 mtime=Time::TimeStamp::from_unixtime(st.st_mtime);