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