X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fsharedlibrary.cpp;h=6600b740332a23dff7a882a0a63e6c99afcbd8ec;hb=ec0d6014aa2db4a02588c9027e7dba17507df364;hp=d3a8ceb25568e8f4077cc077f3deeb3dea69062a;hpb=dc4b917034c9d3718f07139e2f0f3631a080c6f3;p=builder.git diff --git a/source/sharedlibrary.cpp b/source/sharedlibrary.cpp index d3a8ceb..6600b74 100644 --- a/source/sharedlibrary.cpp +++ b/source/sharedlibrary.cpp @@ -1,6 +1,8 @@ #include #include +#include "builder.h" #include "component.h" +#include "objectfile.h" #include "sharedlibrary.h" #include "sourcepackage.h" @@ -8,7 +10,8 @@ using namespace std; using namespace Msp; SharedLibrary::SharedLibrary(Builder &b, const Msp::FS::Path &p): - Binary(b, p) + Binary(b, p), + import_lib(0) { libname = FS::basepart(FS::basename(path)); if(!libname.compare(0, 3, "lib")) @@ -16,33 +19,56 @@ SharedLibrary::SharedLibrary(Builder &b, const Msp::FS::Path &p): } SharedLibrary::SharedLibrary(Builder &b, const Component &c, const list &objs): - Binary(b, c, objs), + Binary(b, c, generate_filename(c), objs), libname(c.get_name()), - soname(create_soname(c)) + import_lib(0) { - install_location = "lib"; + if(builder.get_current_arch().get_system()=="windows") + install_location = "bin"; + else + install_location = "lib"; + if(component->get_type()==Component::MODULE) + install_location /= package->get_name(); + else { - install_location += '/'; - 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 if(arch.get_system()=="darwin") + { + string filename = pattern.apply(component->get_name()); + string base = FS::basepart(filename); + string ext = FS::extpart(filename); + soname = format("%s.%s%s", base, version, ext); + } + else + soname = format("%s.%s", pattern.apply(component->get_name()), version); + + install_filename = soname; + } } + + for(list::const_iterator i=objects.begin(); i!=objects.end(); ++i) + (*i)->set_used_in_shared_library(true); } -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; - } + 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()); + } +} - return format("%s.%s", FS::basename(path), ver.substr(0, i)); +void SharedLibrary::set_import_library(ImportLibrary *imp) +{ + import_lib = imp; }