X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fsharedlibrary.cpp;h=5e479f3c9f652f64c03a9ab3eb472ae645c807ed;hb=bf0883b6dd3946612922aa1b7c04a87d06442df7;hp=a3225171836eafb10a67f30e3191ccc660d8901c;hpb=05a2b9dabd01414e9e9a91f9d69babaca4ccb32d;p=builder.git diff --git a/source/sharedlibrary.cpp b/source/sharedlibrary.cpp index a322517..5e479f3 100644 --- a/source/sharedlibrary.cpp +++ b/source/sharedlibrary.cpp @@ -1,40 +1,70 @@ -/* $Id$ - -This file is part of builder -Copyright © 2006-2007 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ - -#include -#include "component.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 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)) -{ } +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); +} -string SharedLibrary::create_soname(const Component &c) +SharedLibrary::SharedLibrary(Builder &b, const Component &c, const list &objs): + Binary(b, c, generate_filename(c), objs), + libname(c.get_name()), + import_lib(0) { - const string &ver = c.get_package().get_version(); - if(ver.empty()) - return string(); - - unsigned dots = 0; - unsigned i = 0; - for(; i(*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()) { - ++dots; - if(dots>=2) - break; + 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(list::const_iterator i=objects.begin(); i!=objects.end(); ++i) + (*i)->set_used_in_shared_library(true); +} - return format("%s.%s", name, ver.substr(0, i)); +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; }