]> git.tdb.fi Git - builder.git/blobdiff - source/sharedlibrary.cpp
Split Binary filename generation to Executable and SharedLibrary
[builder.git] / source / sharedlibrary.cpp
index 6a197bac08c69535ccb53fd98b62d6a04c7c189f..9f983ef1d666fc7a690ed17da7a7cdb135e7ccaf 100644 (file)
@@ -1,5 +1,6 @@
 #include <msp/fs/utils.h>
 #include <msp/strings/format.h>
+#include "builder.h"
 #include "component.h"
 #include "sharedlibrary.h"
 #include "sourcepackage.h"
@@ -7,12 +8,37 @@
 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<ObjectFile *> &objs):
-       FileTarget(b, &c.get_package(), generate_target_path(c)),
-       Binary(b, c, objs),
-       Library(b, &c.get_package(), path, 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)
 {