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 string fn = FS::basename(tgt.get_path());
37 if(const SharedLibrary *shlib = dynamic_cast<const SharedLibrary *>(&tgt))
38 if(!shlib->get_soname().empty())
39 fn = shlib->get_soname();
44 Target *InstalledFile::get_real_target()
46 return source.get_real_target();
49 void InstalledFile::check_rebuild()
52 mark_rebuild("Does not exist");
53 else if(source.get_mtime()>mtime || source.get_size()!=size)
54 mark_rebuild(source.get_name()+" has changed");
55 else if(source.needs_rebuild())
56 mark_rebuild(source.get_name()+" needs rebuilding");