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 const string &staticlibs=package->get_config().get_option("staticlibs").value;
33 else if(staticlibs=="local")
36 //XXX Duplicate libraries?
37 list<const Component *> queue;
38 queue.push_back(&comp);
41 const Component *c=queue.front();
42 queue.erase(queue.begin());
44 const list<string> &libs=c->get_build_info().libs;
45 for(StringList::const_iterator i=libs.begin(); i!=libs.end(); ++i)
47 Target *lib=builder.get_library(*i, c->get_build_info().libpath, libmode);
50 if(contains(depends, lib))
54 if(dynamic_cast<Install *>(lib))
55 lib=lib->get_depends().front();
56 if(StaticLibrary *stlib=dynamic_cast<StaticLibrary *>(lib))
57 queue.push_back(&stlib->get_component());
60 cout<<"Couldn't find library "<<*i<<" for "<<name<<'\n';
61 //XXX Throw an exception here or something
68 Action *Executable::build()
70 return Target::build(new Link(builder, *this));;
74 Returns the name for the executable. We can't do this in the constructor since
75 we need to pass the value to the Target c'tor.
77 string Executable::generate_target_name(const Component &c)
81 if(c.get_type()==Component::LIBRARY)
87 return (c.get_package().get_source()/(prefix+c.get_name()+suffix)).str();