1 #include <msp/fs/utils.h>
2 #include <msp/strings/format.h>
5 #include "sharedlibrary.h"
6 #include "sourcepackage.h"
11 SharedLibrary::SharedLibrary(Builder &b, const Msp::FS::Path &p):
15 libname = FS::basepart(FS::basename(path));
16 if(!libname.compare(0, 3, "lib"))
17 libname = libname.substr(3);
20 SharedLibrary::SharedLibrary(Builder &b, const Component &c, const list<ObjectFile *> &objs):
21 Binary(b, c, generate_filename(c), objs),
22 libname(c.get_name()),
25 if(builder.get_current_arch().get_system()=="windows")
26 install_location = "bin";
28 install_location = "lib";
29 if(component->get_type()==Component::MODULE)
30 install_location /= package->get_name();
32 const string &version = component->get_package().get_interface_version();
35 const Architecture &arch = builder.get_current_arch();
36 const Pattern &pattern = arch.get_shared_library_patterns().front();
37 if(arch.get_system()=="windows")
38 soname = pattern.apply(format("%s-%s", component->get_name(), version));
39 else if(arch.get_system()=="darwin")
41 string filename = pattern.apply(component->get_name());
42 string base = FS::basepart(filename);
43 string ext = FS::extpart(filename);
44 soname = format("%s.%s%s", base, version, ext);
47 soname = format("%s.%s", pattern.apply(component->get_name()), version);
49 install_filename = soname;
53 string SharedLibrary::generate_filename(const Component &comp)
55 if(comp.get_type()==Component::MODULE)
56 return comp.get_name()+".m";
59 const Architecture &arch = comp.get_package().get_builder().get_current_arch();
60 return arch.get_shared_library_patterns().front().apply(comp.get_name());
64 void SharedLibrary::set_import_library(ImportLibrary *imp)