3 This file is part of builder
4 Copyright © 2007-2009 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
8 #include <msp/core/maputils.h>
9 #include <msp/fs/stat.h>
10 #include <msp/io/file.h>
11 #include <msp/io/print.h>
12 #include <msp/strings/utils.h>
14 #include "dependencycache.h"
15 #include "sourcepackage.h"
20 DependencyCache::DependencyCache(SourcePackage &p):
25 void DependencyCache::set_deps(const string &tgt, const StringList &d)
31 const StringList &DependencyCache::get_deps(const string &tgt) const
33 return get_item(deps, tgt);
36 void DependencyCache::save() const
38 if(deps.empty() || !changed || package.get_builder().get_dry_run())
41 IO::BufferedFile out((package.get_source()/".deps").str(), IO::M_WRITE);
43 for(DepsMap::const_iterator i=deps.begin(); i!=deps.end(); ++i)
45 IO::print(out, i->first);
46 for(StringList::const_iterator j=i->second.begin(); j!=i->second.end(); ++j)
47 IO::print(out, "|%s", *j);
52 void DependencyCache::load()
54 string fn = (package.get_source()/".deps").str();
58 IO::BufferedFile in(fn);
61 while(in.getline(line))
63 vector<string> parts = split(line, '|');
64 deps[parts[0]] = StringList(parts.begin()+1, parts.end());
67 mtime = FS::stat(fn).get_modify_time();
69 catch(const IO::file_not_found &)