#include <msp/fs/dir.h>
#include <msp/fs/stat.h>
#include <msp/fs/utils.h>
+#include <msp/io/print.h>
#include <msp/strings/lexicalcast.h>
#include "builder.h"
#include "component.h"
+#include "executable.h"
#include "header.h"
#include "install.h"
#include "objectfile.h"
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());
// Install headers if requested
- if(!install_headers.empty())
+ if(type==HEADERS && install)
inst_tgts.push_back(hdr);
}
}
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));
}
{
add("source", &Loader::source);
add("install", &Component::install);
- add("install_headers", &Component::install_headers);
+ add("install_headers", &Loader::install_headers);
add("build_info", &Loader::build_info);
add("require", &Loader::require);
add("modular", &Loader::modular);
add("default", &Component::deflt);
}
+void Component::Loader::finish()
+{
+ if(!inst_hdr.empty())
+ {
+ Component hdrcomp(comp.pkg, HEADERS, inst_hdr);
+ hdrcomp.sources=comp.sources;
+ hdrcomp.install=true;
+ const_cast<ComponentList &>(comp.pkg.get_components()).push_back(hdrcomp);
+ }
+}
+
void Component::Loader::source(const string &s)
{
comp.sources.push_back(comp.pkg.get_source()/s);
throw Msp::Exception("Unknown component");
}
+void Component::Loader::install_headers(const string &p)
+{
+ IO::print("%s: Note: install_headers is deprecated\n", get_source());
+ if(comp.type==HEADERS)
+ {
+ comp.name=p;
+ comp.install=true;
+ }
+ else
+ inst_hdr=p;
+}
+
void Component::Loader::build_info()
{
load_sub(comp.build_info);