1 #include <msp/fs/stat.h>
2 #include <msp/fs/utils.h>
4 #include "installedfile.h"
5 #include "sharedlibrary.h"
10 InstalledFile::InstalledFile(Builder &b, const SourcePackage &p, FileTarget &s, const string &loc):
11 FileTarget(b, p, generate_target_path(b.get_prefix(), s, loc)),
14 add_dependency(source);
16 if(const SharedLibrary *shlib = dynamic_cast<const SharedLibrary *>(&source))
17 if(!shlib->get_soname().empty())
18 link = FS::dirname(path)/FS::basename(shlib->get_path());
21 builder.get_vfs().register_path(link, this);
24 FS::Path InstalledFile::generate_target_path(const FS::Path &prefix, const FileTarget &tgt, const string &loc)
26 if(!tgt.is_installable() && loc.empty())
27 throw invalid_argument(tgt.get_name()+" is not installable");
32 else if(const Component *comp = tgt.get_component())
33 mid = comp->get_install_map().get_install_location(tgt);
35 mid = tgt.get_install_location();
37 string fn = FS::basename(tgt.get_path());
38 if(const SharedLibrary *shlib = dynamic_cast<const SharedLibrary *>(&tgt))
39 if(!shlib->get_soname().empty())
40 fn = shlib->get_soname();
45 Target *InstalledFile::get_real_target()
47 return source.get_real_target();
50 void InstalledFile::check_rebuild()
53 mark_rebuild("Does not exist");
54 else if(source.get_mtime()>mtime || source.get_size()!=size)
55 mark_rebuild(source.get_name()+" has changed");
56 else if(source.needs_rebuild())
57 mark_rebuild(source.get_name()+" needs rebuilding");
58 else if(!link.empty() && !FS::exists(link))
59 mark_rebuild("Symlink does not exist");