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 FS::Path InstalledFile::generate_target_path(const FS::Path &prefix, const FileTarget &tgt, const string &loc)
25 if(!tgt.is_installable() && loc.empty())
26 throw invalid_argument(tgt.get_name()+" is not installable");
31 else if(const Component *comp = tgt.get_component())
32 mid = comp->get_install_map().get_install_location(tgt);
34 mid = tgt.get_install_location();
36 return prefix/mid/FS::basename(tgt.get_path());
39 Target *InstalledFile::get_real_target()
41 return source.get_real_target();
44 void InstalledFile::check_rebuild()
47 mark_rebuild("Does not exist");
48 else if(source.get_mtime()>mtime || source.get_size()!=size)
49 mark_rebuild(source.get_name()+" has changed");
50 else if(source.needs_rebuild())
51 mark_rebuild(source.get_name()+" needs rebuilding");