]> git.tdb.fi Git - builder.git/blobdiff - source/sharedlibrary.cpp
Change the suffix of modules
[builder.git] / source / sharedlibrary.cpp
index ae44f2cd5751701dff67a5e18dc29183960adb6b..c25c6f213f3e7c791525aad240259384335c60ac 100644 (file)
@@ -1,7 +1,8 @@
 #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"
 
@@ -26,34 +27,42 @@ SharedLibrary::SharedLibrary(Builder &b, const Component &c, const list<ObjectFi
                install_location = "bin";
        else
                install_location = "lib";
-       if(component->get_type()==Component::MODULE)
-               install_location /= package->get_name();
 
-       const string &version = component->get_package().get_interface_version();
-       if(!version.empty())
+       const BinaryComponent &bcomp = dynamic_cast<const BinaryComponent &>(*component);
+       if(bcomp.get_type()==BinaryComponent::MODULE)
+               install_location /= package->get_name();
+       else
        {
-               const Architecture &arch = builder.get_current_arch();
-               const Pattern &pattern = arch.get_shared_library_patterns().front();
-               if(arch.get_system()=="windows")
-                       soname = pattern.apply(format("%s-%s", component->get_name(), version));
-               else if(arch.get_system()=="darwin")
+               const string &version = component->get_package().get_interface_version();
+               if(!version.empty())
                {
-                       string filename = pattern.apply(component->get_name());
-                       string base = FS::basepart(filename);
-                       string ext = FS::extpart(filename);
-                       soname = format("%s.%s%s", base, version, ext);
-               }
-               else
-                       soname = format("%s.%s", pattern.apply(component->get_name()), version);
+                       const Architecture &arch = builder.get_current_arch();
+                       const Pattern &pattern = arch.get_shared_library_patterns().front();
+                       if(arch.get_system()=="windows")
+                               soname = pattern.apply(format("%s-%s", component->get_name(), version));
+                       else if(arch.get_system()=="darwin")
+                       {
+                               string filename = pattern.apply(component->get_name());
+                               string base = FS::basepart(filename);
+                               string ext = FS::extpart(filename);
+                               soname = format("%s.%s%s", base, version, ext);
+                       }
+                       else
+                               soname = format("%s.%s", pattern.apply(component->get_name()), version);
 
-               install_filename = soname;
+                       install_filename = soname;
+               }
        }
+
+       for(list<ObjectFile *>::const_iterator i=objects.begin(); i!=objects.end(); ++i)
+               (*i)->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();