#include <msp/fs/utils.h>
#include <msp/strings/format.h>
+#include "binarycomponent.h"
#include "builder.h"
-#include "component.h"
+#include "objectfile.h"
#include "sharedlibrary.h"
#include "sourcepackage.h"
using namespace Msp;
SharedLibrary::SharedLibrary(Builder &b, const Msp::FS::Path &p):
- Binary(b, p)
+ Binary(b, p),
+ import_lib(0)
{
libname = FS::basepart(FS::basename(path));
if(!libname.compare(0, 3, "lib"))
SharedLibrary::SharedLibrary(Builder &b, const Component &c, const list<ObjectFile *> &objs):
Binary(b, c, generate_filename(c), objs),
- libname(c.get_name())
+ libname(c.get_name()),
+ import_lib(0)
{
- install_location = "lib";
- if(component->get_type()==Component::MODULE)
- {
- install_location += '/';
- 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_version();
- if(!version.empty())
+ const BinaryComponent &bcomp = dynamic_cast<const BinaryComponent &>(*component);
+ if(bcomp.get_type()==BinaryComponent::MODULE)
+ install_location /= package->get_name();
+ else
{
- string::size_type i = 0;
- for(unsigned dots=0; i<version.size(); ++i)
- if(version[i]=='.' && ++dots>=2)
- break;
+ 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<SharedLibrary>(format("%s-%s", libname, version));
+ else if(arch.get_system()=="darwin")
+ soname = arch.create_filename<SharedLibrary>(format("%s.%s", libname, version));
+ else
+ soname = format("%s.%s", arch.create_filename<SharedLibrary>(libname), version);
- soname = format("%s.%s", FS::basename(path), version.substr(0, i));
+ 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<const BinaryComponent &>(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<SharedLibrary>(comp.get_name());
}
}
+
+void SharedLibrary::set_import_library(ImportLibrary *imp)
+{
+ import_lib = imp;
+}