X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fsharedlibrary.cpp;h=9b2fdbb1bd99b02bc3a99f877ec67779b4790c31;hb=6f76342d14c7b7ec7b9629fcfd40199bca1e5e0f;hp=c4f42e574ed7a484150966c063d9513d6bb72437;hpb=632361796a7ddadf8a726526c937fab22281fb7b;p=builder.git diff --git a/source/sharedlibrary.cpp b/source/sharedlibrary.cpp index c4f42e5..9b2fdbb 100644 --- a/source/sharedlibrary.cpp +++ b/source/sharedlibrary.cpp @@ -1,5 +1,6 @@ #include #include +#include "builder.h" #include "component.h" #include "sharedlibrary.h" #include "sourcepackage.h" @@ -7,35 +8,41 @@ using namespace std; using namespace Msp; +SharedLibrary::SharedLibrary(Builder &b, const Msp::FS::Path &p): + Binary(b, p) +{ + libname = FS::basepart(FS::basename(path)); + if(!libname.compare(0, 3, "lib")) + libname = libname.substr(3); +} + SharedLibrary::SharedLibrary(Builder &b, const Component &c, const list &objs): - FileTarget(b, &c.get_package(), generate_target_path(c)), - Binary(b, c, objs), - Library(b, &c.get_package(), path, c.get_name()), - soname(create_soname(c)) + Binary(b, c, generate_filename(c), objs), + libname(c.get_name()) { install_location = "lib"; if(component->get_type()==Component::MODULE) + install_location /= package->get_name(); + + const string &version = component->get_package().get_version(); + if(!version.empty()) { - install_location += '/'; - install_location += package->get_name(); + 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::create_soname(const Component &c) +string SharedLibrary::generate_filename(const Component &comp) { - 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)); + if(comp.get_type()==Component::MODULE) + return comp.get_name()+".m"; + else + { + const Architecture &arch = comp.get_package().get_builder().get_current_arch(); + return arch.get_shared_library_patterns().front().apply(comp.get_name()); + } }