1 #include <msp/core/maputils.h>
2 #include <msp/fs/stat.h>
3 #include <msp/io/file.h>
4 #include <msp/io/print.h>
5 #include <msp/strings/utils.h>
7 #include "dependencycache.h"
8 #include "sourcepackage.h"
13 DependencyCache::DependencyCache(SourcePackage &p):
18 void DependencyCache::set_deps(const string &tgt, const StringList &d)
24 const StringList &DependencyCache::get_deps(const string &tgt) const
26 return get_item(deps, tgt);
29 void DependencyCache::save() const
31 if(deps.empty() || !changed || package.get_builder().get_dry_run())
34 IO::BufferedFile out((package.get_source()/".deps").str(), IO::M_WRITE);
36 for(DepsMap::const_iterator i=deps.begin(); i!=deps.end(); ++i)
38 IO::print(out, i->first);
39 for(StringList::const_iterator j=i->second.begin(); j!=i->second.end(); ++j)
40 IO::print(out, "|%s", *j);
45 void DependencyCache::load()
47 string fn = (package.get_source()/".deps").str();
49 if(FS::Stat st = FS::stat(fn))
51 IO::BufferedFile in(fn);
54 while(in.getline(line))
56 vector<string> parts = split(line, '|');
57 deps[parts[0]] = StringList(parts.begin()+1, parts.end());
60 mtime = st.get_modify_time();