5 #include "executable.h"
8 #include "objectfile.h"
10 #include "staticlibrary.h"
15 Executable::Executable(Builder &b, const Component &c, const list<ObjectFile *> &objs):
16 Target(b, &c.get_package(), generate_target_name(c)),
20 for(list<ObjectFile *>::const_iterator i=objs.begin(); i!=objs.end(); ++i)
25 Finds and adds any required libraries to the dependencies.
27 void Executable::find_depends()
29 LibMode libmode=package->get_library_mode();
31 //XXX Duplicate libraries?
32 list<const Component *> queue;
33 queue.push_back(&comp);
36 const Component *c=queue.front();
37 queue.erase(queue.begin());
39 const list<string> &libs=c->get_build_info().libs;
40 for(StringList::const_iterator i=libs.begin(); i!=libs.end(); ++i)
42 Target *lib=builder.get_library(*i, c->get_build_info().libpath, libmode);
45 if(contains(depends, lib))
49 if(dynamic_cast<Install *>(lib))
50 lib=lib->get_depends().front();
51 if(StaticLibrary *stlib=dynamic_cast<StaticLibrary *>(lib))
52 queue.push_back(&stlib->get_component());
55 cout<<"Couldn't find library "<<*i<<" for "<<name<<'\n';
56 //XXX Throw an exception here or something
63 Action *Executable::build()
65 return Target::build(new Link(builder, *this));;
69 Returns the name for the executable. We can't do this in the constructor since
70 we need to pass the value to the Target c'tor.
72 string Executable::generate_target_name(const Component &c)
76 if(c.get_type()==Component::LIBRARY)
82 return (c.get_package().get_out_dir()/(prefix+c.get_name()+suffix)).str();