]> git.tdb.fi Git - builder.git/blob - source/sharedlibrary.cpp
Move some install location assignments to more logical places
[builder.git] / source / sharedlibrary.cpp
1 #include <msp/fs/utils.h>
2 #include <msp/strings/format.h>
3 #include "component.h"
4 #include "sharedlibrary.h"
5 #include "sourcepackage.h"
6
7 using namespace std;
8 using namespace Msp;
9
10 SharedLibrary::SharedLibrary(Builder &b, const Component &c, const list<ObjectFile *> &objs):
11         FileTarget(b, &c.get_package(), generate_target_path(c)),
12         Binary(b, c, objs),
13         Library(b, &c.get_package(), path, c.get_name()),
14         soname(create_soname(c))
15 {
16         install_location = "lib";
17         if(comp.get_type()==Component::MODULE)
18         {
19                 install_location += '/';
20                 install_location += package->get_name();
21         }
22 }
23
24 string SharedLibrary::create_soname(const Component &c)
25 {
26         const string &ver = c.get_package().get_version();
27         if(ver.empty())
28                 return string();
29
30         unsigned dots = 0;
31         unsigned i = 0;
32         for(; i<ver.size(); ++i)
33                 if(ver[i]=='.')
34                 {
35                         ++dots;
36                         if(dots>=2)
37                                 break;
38                 }
39
40         return format("%s.%s", FS::basename(path), ver.substr(0, i));
41 }