/* $Id$
This file is part of builder
-Copyright © 2006-2007 Mikko Rasa, Mikkosoft Productions
+Copyright © 2006-2009 Mikko Rasa, Mikkosoft Productions
Distributed under the LGPL
*/
#include <msp/strings/lexicalcast.h>
#include "builder.h"
#include "component.h"
+#include "executable.h"
#include "header.h"
#include "install.h"
#include "objectfile.h"
deflt(true)
{ }
-/**
-Prepares the build information for building.
-*/
void Component::create_build_info()
{
build_info.add(pkg.get_build_info());
for(StringList::iterator i=build_info.libpath.begin(); i!=build_info.libpath.end(); ++i)
*i=(pkg.get_source() / *i).str();
+ if(pkg.get_library_mode()!=DYNAMIC)
+ {
+ // XXX This may pull in some unnecessary libpaths too. More thought required.
+ PackageList reqs=pkg.collect_requires();
+ for(PackageList::iterator i=reqs.begin(); i!=reqs.end(); ++i)
+ {
+ const BuildInfo &ebi=(*i)->get_exported_binfo();
+ build_info.libpath.insert(build_info.libpath.end(), ebi.libpath.begin(), ebi.libpath.end());
+ }
+ }
+
if(type==PROGRAM)
{
string strip=pkg.get_config().get_option("strip").value;
build_info.unique();
}
-/**
-Creates all targets needed for building this component.
-*/
void Component::create_targets() const
{
Builder &builder=pkg.get_builder();
bool build_exe=(type!=HEADERS);
list<ObjectFile *> objs;
- list<Target *> inst_tgts;
+ list<FileTarget *> inst_tgts;
for(PathList::const_iterator i=files.begin(); i!=files.end(); ++i)
{
string ext=FS::extpart(FS::basename(*i));
}
else if(ext==".h")
{
- Target *hdr=builder.get_target(i->str());
+ FileTarget *hdr=dynamic_cast<FileTarget *>(builder.get_target(i->str()));
if(!hdr)
hdr=new Header(builder, this, i->str());
if(build_exe)
{
- Executable *exe=0;
+ Binary *bin=0;
StaticLibrary *slib=0;
if(type==LIBRARY)
{
- exe=new SharedLibrary(builder, *this, objs);
+ bin=new SharedLibrary(builder, *this, objs);
slib=new StaticLibrary(builder, *this, objs);
}
else
- exe=new Executable(builder, *this, objs);
+ bin=new Executable(builder, *this, objs);
if(&pkg==builder.get_main_package() && deflt)
{
- def_tgt->add_depend(exe);
+ def_tgt->add_depend(bin);
if(slib) def_tgt->add_depend(slib);
}
else
{
- world->add_depend(exe);
+ world->add_depend(bin);
if(slib) world->add_depend(slib);
}
if(install)
{
- inst_tgts.push_back(exe);
+ inst_tgts.push_back(bin);
if(slib)
inst_tgts.push_back(slib);
}
}
Target *inst_tgt=builder.get_target("install");
- for(TargetList::const_iterator i=inst_tgts.begin(); i!=inst_tgts.end(); ++i)
+ for(list<FileTarget *>::const_iterator i=inst_tgts.begin(); i!=inst_tgts.end(); ++i)
inst_tgt->add_depend(new Install(builder, pkg, **i));
}
-/**
-Collects all files belonging to the component.
-*/
PathList Component::collect_source_files() const
{
PathList files;