]> git.tdb.fi Git - builder.git/blobdiff - source/link.cpp
Support building static libraries (but not using them yet)
[builder.git] / source / link.cpp
index 242c966dfab7ab58acc77054e1ae0478e7f70ed8..8b4c56421089e34d8bee43ffbd378c28cfb1566d 100644 (file)
@@ -1,17 +1,24 @@
 #include <msp/path/utils.h>
+#include "builder.h"
 #include "component.h"
 #include "executable.h"
 #include "link.h"
+#include "objectfile.h"
 #include "package.h"
 
 using namespace std;
 using namespace Msp;
 
-Link::Link(Builder &b, const Executable &exe, const Component &comp):
+Link::Link(Builder &b, const Executable &exe):
        ExternalAction(b)
 {
+       const Component &comp=exe.get_component();
+
        argv.push_back("g++");
        
+       if(comp.get_type()==Component::LIBRARY)
+               argv.push_back("-shared");
+
        const BuildInfo &binfo=comp.get_build_info();
        for(list<string>::const_iterator i=binfo.ldflags.begin(); i!=binfo.ldflags.end(); ++i)
                argv.push_back(*i);
@@ -24,10 +31,12 @@ Link::Link(Builder &b, const Executable &exe, const Component &comp):
        argv.push_back(exe.get_name());
        const list<Target *> &deps=exe.get_depends();
        for(list<Target *>::const_iterator i=deps.begin(); i!=deps.end(); ++i)
-               argv.push_back((*i)->get_name());
+               if(dynamic_cast<ObjectFile *>(*i))
+                       argv.push_back((*i)->get_name());
 
        Path::Path epath=exe.get_name();
-       Path::mkpath(epath.subpath(0, epath.size()-1), 0755);
+       if(!builder.get_dry_run())
+               Path::mkpath(epath.subpath(0, epath.size()-1), 0755);
 
        announce(comp.get_package().get_name(), "LINK", relative(epath, comp.get_package().get_source()).str());