X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fsharedlibrary.cpp;h=4ef9bb6fdf09bfd76ab7820f6cbc4f58515e1d5b;hb=82c7d6187fdaeaa1b9cfbd6637d9b047a78f17ec;hp=06a99442b2fb47377044546d1646d7d599da5dcb;hpb=82ae60a647ebb9567f7177c353245f4d72faaf5e;p=builder.git diff --git a/source/sharedlibrary.cpp b/source/sharedlibrary.cpp index 06a9944..4ef9bb6 100644 --- a/source/sharedlibrary.cpp +++ b/source/sharedlibrary.cpp @@ -1,7 +1,8 @@ #include #include +#include "binarycomponent.h" #include "builder.h" -#include "component.h" +#include "objectfile.h" #include "sharedlibrary.h" #include "sourcepackage.h" @@ -17,37 +18,49 @@ SharedLibrary::SharedLibrary(Builder &b, const Msp::FS::Path &p): libname = libname.substr(3); } -SharedLibrary::SharedLibrary(Builder &b, const Component &c, const list &objs): +SharedLibrary::SharedLibrary(Builder &b, const Component &c, const vector &objs): 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(); + if(builder.get_current_arch().get_system()=="windows") + install_location = "bin"; + else + install_location = "lib"; - const string &version = component->get_package().get_interface_version(); - if(!version.empty()) + const BinaryComponent &bcomp = dynamic_cast(*component); + if(bcomp.get_type()==BinaryComponent::MODULE) + install_location /= package->get_name(); + else { - 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; + const string &version = component->get_package().get_interface_version(); + if(!version.empty()) + { + const Architecture &arch = builder.get_current_arch(); + if(arch.get_system()=="windows") + soname = arch.create_filename(format("%s-%s", libname, version)); + else if(arch.get_system()=="darwin") + soname = arch.create_filename(format("%s.%s", libname, version)); + else + soname = format("%s.%s", arch.create_filename(libname), version); + + install_filename = soname; + } } + + for(ObjectFile *o: objects) + o->set_used_in_shared_library(true); } string SharedLibrary::generate_filename(const Component &comp) { - if(comp.get_type()==Component::MODULE) - return comp.get_name()+".m"; + const BinaryComponent &bcomp = dynamic_cast(comp); + if(bcomp.get_type()==BinaryComponent::MODULE) + return comp.get_name()+".dlm"; else { const Architecture &arch = comp.get_package().get_builder().get_current_arch(); - return arch.get_shared_library_patterns().front().apply(comp.get_name()); + return arch.create_filename(comp.get_name()); } }