]> git.tdb.fi Git - builder.git/blob - source/executable.cpp
Add command line options (not all of them work yet)
[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
30 Action *Executable::build()
31 {
32         return Target::build(new Link(builder, *this, comp));;
33 }
34
35 string Executable::generate_target_name(const Component &comp)
36 {
37         string prefix;
38         string suffix;
39
40         if(comp.get_type()==Component::LIBRARY)
41         {
42                 prefix="lib";
43                 suffix=".so";
44         }
45
46         return (comp.get_package().get_source()/(prefix+comp.get_name()+suffix)).str();
47 }