1 #include <msp/fs/utils.h>
3 #include "installedfile.h"
4 #include "sharedlibrary.h"
9 InstalledFile::InstalledFile(Builder &b, const SourcePackage &p, FileTarget &s, const string &loc):
10 FileTarget(b, &p, generate_target_path(b.get_prefix(), s, loc)),
15 if(const SharedLibrary *shlib = dynamic_cast<const SharedLibrary *>(&source))
16 if(!shlib->get_soname().empty())
17 link = FS::dirname(path)/FS::basename(shlib->get_path());
20 builder.get_vfs().register_path(link, this);
23 Target *InstalledFile::get_real_target()
25 return source.get_real_target();
28 void InstalledFile::check_rebuild()
31 mark_rebuild("Does not exist");
32 else if(source.get_mtime()>mtime || source.get_size()!=size)
33 mark_rebuild(source.get_name()+" has changed");
34 else if(source.needs_rebuild())
35 mark_rebuild(source.get_name()+" needs rebuilding");
38 FS::Path InstalledFile::generate_target_path(const FS::Path &prefix, const FileTarget &tgt, const string &loc)
40 if(!tgt.is_installable() && loc.empty())
41 throw invalid_argument(tgt.get_name()+" is not installable");
47 mid = tgt.get_install_location();
49 return prefix/mid/FS::basename(tgt.get_path());