]> git.tdb.fi Git - builder.git/blob - source/installedfile.cpp
Remove the buildable flag and instead check for tool being non-null
[builder.git] / source / installedfile.cpp
1 #include <msp/fs/utils.h>
2 #include "builder.h"
3 #include "copy.h"
4 #include "executable.h"
5 #include "datafile.h"
6 #include "installedfile.h"
7 #include "package.h"
8 #include "pkgconfig.h"
9 #include "sharedlibrary.h"
10 #include "staticlibrary.h"
11
12 using namespace std;
13 using namespace Msp;
14
15 InstalledFile::InstalledFile(Builder &b, const SourcePackage &p, FileTarget &s, const std::string &loc):
16         FileTarget(b, &p, generate_target_path(b.get_prefix(), s, loc)),
17         source(s)
18 {
19         add_depend(&source);
20
21         if(const SharedLibrary *shlib = dynamic_cast<const SharedLibrary *>(&source))
22                 if(!shlib->get_soname().empty())
23                         link = FS::dirname(path)/FS::basename(shlib->get_path());
24
25         if(!link.empty())
26                 builder.get_vfs().register_path(link, this);
27 }
28
29 Target *InstalledFile::get_real_target()
30 {
31         return source.get_real_target();
32 }
33
34 void InstalledFile::check_rebuild()
35 {
36         if(!mtime)
37                 mark_rebuild("Does not exist");
38         else if(source.get_mtime()>mtime || source.get_size()!=size)
39                 mark_rebuild(source.get_name()+" has changed");
40         else if(source.get_rebuild())
41                 mark_rebuild(source.get_name()+" needs rebuilding");
42 }
43
44 FS::Path InstalledFile::generate_target_path(const FS::Path &prefix, const FileTarget &tgt, const std::string &loc)
45 {
46         if(!tgt.is_installable() && loc.empty())
47                 throw invalid_argument(tgt.get_name()+" is not installable");
48
49         string mid;
50         if(!loc.empty())
51                 mid = loc;
52         else
53                 mid = tgt.get_install_location();
54
55         return prefix/mid/FS::basename(tgt.get_path());
56 }