]> git.tdb.fi Git - builder.git/blobdiff - source/link.cpp
Code reorganizing and cleanup
[builder.git] / source / link.cpp
index e2c0f1222a83cb9d7baea296f8fcda4da17c0130..7cbdc03c84db1b0b7dbaaa4f96d54fcfc6935d74 100644 (file)
@@ -1,15 +1,20 @@
 #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();
+
+       //XXX Determine whether to use g++ or gcc
        argv.push_back("g++");
        
        if(comp.get_type()==Component::LIBRARY)
@@ -25,12 +30,14 @@ Link::Link(Builder &b, const Executable &exe, const Component &comp):
        
        argv.push_back("-o");
        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());
+       const TargetList &deps=exe.get_depends();
+       for(TargetList::const_iterator i=deps.begin(); i!=deps.end(); ++i)
+               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());