]> git.tdb.fi Git - builder.git/blob - source/sharedlibrary.cpp
Replace per-file copyright notices with a single file
[builder.git] / source / sharedlibrary.cpp
1 #include <msp/strings/format.h>
2 #include "component.h"
3 #include "sharedlibrary.h"
4 #include "sourcepackage.h"
5
6 using namespace std;
7 using namespace Msp;
8
9 SharedLibrary::SharedLibrary(Builder &b, const Component &c, const list<ObjectFile *> &objs):
10         FileTarget(b, &c.get_package(), generate_target_path(c)),
11         Binary(b, c, objs),
12         Library(b, &c.get_package(), path, c.get_name()),
13         soname(create_soname(c))
14 { }
15
16 string SharedLibrary::create_soname(const Component &c)
17 {
18         const string &ver = c.get_package().get_version();
19         if(ver.empty())
20                 return string();
21
22         unsigned dots = 0;
23         unsigned i = 0;
24         for(; i<ver.size(); ++i)
25                 if(ver[i]=='.')
26                 {
27                         ++dots;
28                         if(dots>=2)
29                                 break;
30                 }
31
32         return format("%s.%s", name, ver.substr(0, i));
33 }