]> git.tdb.fi Git - builder.git/blob - source/link.cpp
Builder can build itself now.
[builder.git] / source / link.cpp
1 #include <msp/path/utils.h>
2 #include "component.h"
3 #include "executable.h"
4 #include "link.h"
5 #include "package.h"
6
7 using namespace std;
8 using namespace Msp;
9
10 Link::Link(Builder &b, const Executable &exe, const Component &comp):
11         ExternalAction(b)
12 {
13         argv.push_back("g++");
14         
15         const BuildInfo &binfo=comp.get_build_info();
16         for(list<string>::const_iterator i=binfo.ldflags.begin(); i!=binfo.ldflags.end(); ++i)
17                 argv.push_back(*i);
18         for(list<string>::const_iterator i=binfo.libpath.begin(); i!=binfo.libpath.end(); ++i)
19                 argv.push_back("-L"+*i);
20         for(list<string>::const_iterator i=binfo.libs.begin(); i!=binfo.libs.end(); ++i)
21                 argv.push_back("-l"+*i);
22         
23         argv.push_back("-o");
24         argv.push_back(exe.get_name());
25         const list<Target *> &deps=exe.get_depends();
26         for(list<Target *>::const_iterator i=deps.begin(); i!=deps.end(); ++i)
27                 argv.push_back((*i)->get_name());
28
29         Path::Path epath=exe.get_name();
30         Path::mkpath(epath.subpath(0, epath.size()-1), 0755);
31
32         announce(comp.get_package().get_name(), "LINK", relative(epath, comp.get_package().get_source()).str());
33
34         launch();
35 }