X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fsharedlibrary.cpp;h=a6e8239524c91fb9775620ac41445d2e08395e8b;hb=7c2db9e2b91da953701be233336c5bfa1f3c4af0;hp=25034f3fcd0245bf1a8d848f81d8fba413744c09;hpb=7aeaa4ba965f596edad438c02e345a8843f7469a;p=builder.git diff --git a/source/sharedlibrary.cpp b/source/sharedlibrary.cpp index 25034f3..a6e8239 100644 --- a/source/sharedlibrary.cpp +++ b/source/sharedlibrary.cpp @@ -1,18 +1,70 @@ -/* $Id$ - -This file is part of builder -Copyright © 2006-2007 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ - -#include "component.h" -#include "package.h" +#include +#include +#include "binarycomponent.h" +#include "builder.h" +#include "objectfile.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) +{ + if(builder.get_current_arch().get_system()=="windows") + install_location = "bin"; + else + install_location = "lib"; + + const BinaryComponent &bcomp = dynamic_cast(*component); + if(bcomp.get_type()==BinaryComponent::MODULE) + install_location /= package->get_name(); + else + { + 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) +{ + 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.create_filename(comp.get_name()); + } +} +void SharedLibrary::set_import_library(ImportLibrary *imp) +{ + import_lib = imp; +}