X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flink.cpp;h=7cbdc03c84db1b0b7dbaaa4f96d54fcfc6935d74;hb=1a46151c99a406123c4ddfc797a7841baf3e4cc2;hp=242c966dfab7ab58acc77054e1ae0478e7f70ed8;hpb=59ac0a44d6edf179c01604c6ced744873213f855;p=builder.git diff --git a/source/link.cpp b/source/link.cpp index 242c966..7cbdc03 100644 --- a/source/link.cpp +++ b/source/link.cpp @@ -1,17 +1,25 @@ #include +#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) + argv.push_back("-shared"); + const BuildInfo &binfo=comp.get_build_info(); for(list::const_iterator i=binfo.ldflags.begin(); i!=binfo.ldflags.end(); ++i) argv.push_back(*i); @@ -22,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 &deps=exe.get_depends(); - for(list::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(*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());