]> git.tdb.fi Git - builder.git/commitdiff
Move soname generation to constructor
authorMikko Rasa <tdb@tdb.fi>
Sun, 6 May 2012 21:02:32 +0000 (00:02 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sun, 8 Jul 2012 21:08:50 +0000 (00:08 +0300)
source/sharedlibrary.cpp
source/sharedlibrary.h

index 9f983ef1d666fc7a690ed17da7a7cdb135e7ccaf..24e0e205682acec12951035b32d84bc26a9a0ece 100644 (file)
@@ -18,8 +18,7 @@ SharedLibrary::SharedLibrary(Builder &b, const Msp::FS::Path &p):
 
 SharedLibrary::SharedLibrary(Builder &b, const Component &c, const list<ObjectFile *> &objs):
        Binary(b, c, generate_filename(c), objs),
-       libname(c.get_name()),
-       soname(create_soname(c))
+       libname(c.get_name())
 {
        install_location = "lib";
        if(component->get_type()==Component::MODULE)
@@ -27,6 +26,17 @@ SharedLibrary::SharedLibrary(Builder &b, const Component &c, const list<ObjectFi
                install_location += '/';
                install_location += package->get_name();
        }
+
+       const string &version = component->get_package().get_version();
+       if(!version.empty())
+       {
+               string::size_type i = 0;
+               for(unsigned dots=0; i<version.size(); ++i)
+                       if(version[i]=='.' && ++dots>=2)
+                               break;
+
+               soname = format("%s.%s", FS::basename(path), version.substr(0, i));
+       }
 }
 
 string SharedLibrary::generate_filename(const Component &comp)
@@ -39,22 +49,3 @@ string SharedLibrary::generate_filename(const Component &comp)
                return arch.get_shared_library_patterns().front().apply(comp.get_name());
        }
 }
-
-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", FS::basename(path), ver.substr(0, i));
-}
index c2fa985c7dcfd5d6d84ea76e09180a7c226c8ebe..076cfdb71ab89bb82493b90608c0280dd28b7c98 100644 (file)
@@ -25,7 +25,6 @@ public:
 
 private:
        static std::string generate_filename(const Component &);
-       std::string create_soname(const Component &);
 };
 
 #endif