X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fsharedlibrary.cpp;h=9f983ef1d666fc7a690ed17da7a7cdb135e7ccaf;hb=2606b03da59dc10e3826b833a2fceb0831d79972;hp=25034f3fcd0245bf1a8d848f81d8fba413744c09;hpb=7aeaa4ba965f596edad438c02e345a8843f7469a;p=builder.git diff --git a/source/sharedlibrary.cpp b/source/sharedlibrary.cpp index 25034f3..9f983ef 100644 --- a/source/sharedlibrary.cpp +++ b/source/sharedlibrary.cpp @@ -1,18 +1,60 @@ -/* $Id$ - -This file is part of builder -Copyright © 2006-2007 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ - +#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) +{ + 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()), + soname(create_soname(c)) +{ + install_location = "lib"; + if(component->get_type()==Component::MODULE) + { + install_location += '/'; + install_location += package->get_name(); + } +} + +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()); + } +} + +string SharedLibrary::create_soname(const Component &c) +{ + const string &ver = c.get_package().get_version(); + if(ver.empty()) + return string(); + + unsigned dots = 0; + unsigned i = 0; + for(; i=2) + break; + } + return format("%s.%s", FS::basename(path), ver.substr(0, i)); +}