X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;ds=sidebyside;f=source%2Fsharedlibrary.cpp;h=06a99442b2fb47377044546d1646d7d599da5dcb;hb=82ae60a647ebb9567f7177c353245f4d72faaf5e;hp=0431f27f91e44c26ab45475e5dff48deefeb3c4e;hpb=4f78d9f016482ce1ac7d726852e33e07c090df1b;p=builder.git diff --git a/source/sharedlibrary.cpp b/source/sharedlibrary.cpp index 0431f27..06a9944 100644 --- a/source/sharedlibrary.cpp +++ b/source/sharedlibrary.cpp @@ -1,11 +1,57 @@ +#include +#include +#include "builder.h" #include "component.h" -#include "package.h" #include "sharedlibrary.h" +#include "sourcepackage.h" using namespace std; +using namespace Msp; + +SharedLibrary::SharedLibrary(Builder &b, const Msp::FS::Path &p): + Binary(b, p), + import_lib(0) +{ + 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): - Executable(b, c, objs), - libname(c.get_name()) -{ } + Binary(b, c, generate_filename(c), objs), + libname(c.get_name()), + import_lib(0) +{ + install_location = "lib"; + if(component->get_type()==Component::MODULE) + install_location /= package->get_name(); + + const string &version = component->get_package().get_interface_version(); + if(!version.empty()) + { + const Architecture &arch = builder.get_current_arch(); + const Pattern &pattern = arch.get_shared_library_patterns().front(); + if(arch.get_system()=="windows") + soname = pattern.apply(format("%s-%s", component->get_name(), version)); + else + soname = format("%s.%s", pattern.apply(component->get_name()), version); + + install_filename = soname; + } +} + +string SharedLibrary::generate_filename(const Component &comp) +{ + 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()); + } +} +void SharedLibrary::set_import_library(ImportLibrary *imp) +{ + import_lib = imp; +}