]> git.tdb.fi Git - builder.git/blobdiff - source/sharedlibrary.cpp
Add Symlink target and associated action
[builder.git] / source / sharedlibrary.cpp
index 5c2d26fea27f799521c6697fc3803db959ea23f4..a3225171836eafb10a67f30e3191ccc660d8901c 100644 (file)
@@ -5,14 +5,36 @@ Copyright © 2006-2007 Mikko Rasa, Mikkosoft Productions
 Distributed under the LGPL
 */
 
+#include <msp/strings/formatter.h>
 #include "component.h"
 #include "sharedlibrary.h"
 #include "sourcepackage.h"
 
 using namespace std;
+using namespace Msp;
 
 SharedLibrary::SharedLibrary(Builder &b, const Component &c, const list<ObjectFile *> &objs):
        FileTarget(b, &c.get_package(), generate_target_path(c)),
        Binary(b, c, objs),
-       Library(b, &c.get_package(), path, c.get_name())
+       Library(b, &c.get_package(), path, c.get_name()),
+       soname(create_soname(c))
 { }
+
+string SharedLibrary::create_soname(const Component &c)
+{
+       const string &ver = c.get_package().get_version();
+       if(ver.empty())
+               return string();
+
+       unsigned dots = 0;
+       unsigned i = 0;
+       for(; i<ver.size(); ++i)
+               if(ver[i]=='.')
+               {
+                       ++dots;
+                       if(dots>=2)
+                               break;
+               }
+
+       return format("%s.%s", name, ver.substr(0, i));
+}