]> git.tdb.fi Git - builder.git/blob - source/executable.cpp
Builder can build itself now.
[builder.git] / source / executable.cpp
1 #include "component.h"
2 #include "executable.h"
3 #include "link.h"
4 #include "objectfile.h"
5 #include "package.h"
6
7 using namespace std;
8
9 Executable::Executable(Builder &b, const Component &c, const list<ObjectFile *> &objs):
10         Target(b, &c.get_package(), generate_target_name(c)),
11         comp(c)
12 {
13         buildable=true;
14         for(list<ObjectFile *>::const_iterator i=objs.begin(); i!=objs.end(); ++i)
15                 add_depend(*i);
16 }
17
18 Action *Executable::build()
19 {
20         return Target::build(new Link(builder, *this, comp));;
21 }
22
23 string Executable::generate_target_name(const Component &comp)
24 {
25         string prefix;
26         string suffix;
27
28         if(comp.get_type()==Component::LIBRARY)
29         {
30                 prefix="lib";
31                 suffix=".so";
32         }
33
34         return (comp.get_package().get_source()/(prefix+comp.get_name()+suffix)).str();
35 }