From 8932cbfa8cdb0b9edf9894bd4c56980dab0a2f4b Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Mon, 7 May 2012 00:02:32 +0300 Subject: [PATCH] Move soname generation to constructor --- source/sharedlibrary.cpp | 33 ++++++++++++--------------------- source/sharedlibrary.h | 1 - 2 files changed, 12 insertions(+), 22 deletions(-) diff --git a/source/sharedlibrary.cpp b/source/sharedlibrary.cpp index 9f983ef..24e0e20 100644 --- a/source/sharedlibrary.cpp +++ b/source/sharedlibrary.cpp @@ -18,8 +18,7 @@ SharedLibrary::SharedLibrary(Builder &b, const Msp::FS::Path &p): SharedLibrary::SharedLibrary(Builder &b, const Component &c, const list &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 listget_name(); } + + const string &version = component->get_package().get_version(); + if(!version.empty()) + { + string::size_type i = 0; + for(unsigned dots=0; i=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=2) - break; - } - - return format("%s.%s", FS::basename(path), ver.substr(0, i)); -} diff --git a/source/sharedlibrary.h b/source/sharedlibrary.h index c2fa985..076cfdb 100644 --- a/source/sharedlibrary.h +++ b/source/sharedlibrary.h @@ -25,7 +25,6 @@ public: private: static std::string generate_filename(const Component &); - std::string create_soname(const Component &); }; #endif -- 2.45.2