1 #include <msp/fs/utils.h>
4 #include "executable.h"
6 #include "installedfile.h"
8 #include "sharedlibrary.h"
9 #include "staticlibrary.h"
14 InstalledFile::InstalledFile(Builder &b, const SourcePackage &p, FileTarget &s, const std::string &loc):
15 FileTarget(b, &p, generate_target_path(b.get_prefix(), s, loc)),
20 if(const SharedLibrary *shlib = dynamic_cast<const SharedLibrary *>(&source))
21 if(!shlib->get_soname().empty())
22 link = FS::dirname(path)/FS::basename(shlib->get_path());
25 builder.get_vfs().register_path(link, this);
28 Target *InstalledFile::get_real_target()
30 return source.get_real_target();
33 void InstalledFile::check_rebuild()
36 mark_rebuild("Does not exist");
37 else if(source.get_mtime()>mtime || source.get_size()!=size)
38 mark_rebuild(source.get_name()+" has changed");
39 else if(source.needs_rebuild())
40 mark_rebuild(source.get_name()+" needs rebuilding");
43 FS::Path InstalledFile::generate_target_path(const FS::Path &prefix, const FileTarget &tgt, const std::string &loc)
45 if(!tgt.is_installable() && loc.empty())
46 throw invalid_argument(tgt.get_name()+" is not installable");
52 mid = tgt.get_install_location();
54 return prefix/mid/FS::basename(tgt.get_path());