Distributed under the LGPL
*/
+#include <iostream>
#include <msp/core/except.h>
#include <msp/fs/dir.h>
#include <msp/fs/stat.h>
hdr=new Header(builder, this, i->str());
// Install headers if requested
- if(!install_headers.empty())
+ if(type==HEADERS && install)
inst_tgts.push_back(hdr);
}
}
{
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)
+{
+ cout<<get_source()<<": Note: install_headers is deprecated\n";
+ if(comp.type==HEADERS)
+ {
+ comp.name=p;
+ comp.install=true;
+ }
+ else
+ inst_hdr=p;
+}
+
void Component::Loader::build_info()
{
load_sub(comp.build_info);
{
private:
Component ∁
+ std::string inst_hdr;
public:
Loader(Component &);
Component &get_object() { return comp; }
private:
+ virtual void finish();
void source(const std::string &);
void require(const std::string &);
void modular();
void host(const std::string &);
+ void install_headers(const std::string &);
void build_info();
};
std::string name;
PathList sources;
bool install;
- std::string install_headers;
const Component *module_host;
bool modular;
BuildInfo build_info;
const PathList &get_sources() const { return sources; }
const BuildInfo &get_build_info() const { return build_info; }
bool get_install() const { return install; }
- const std::string &get_install_headers() const { return install_headers; }
bool get_modular() const { return modular; }
const PackageList &get_requires() const { return requires; }
bool get_default() const { return deflt; }
string mid;
if(const Header *hdr=dynamic_cast<const Header *>(&tgt))
- mid="include/"+hdr->get_component()->get_install_headers();
+ {
+ if(hdr->get_component()->get_type()!=Component::HEADERS)
+ throw Exception("Header install from non-header component?");
+ mid="include/"+hdr->get_component()->get_name();
+ }
else if(dynamic_cast<const Executable *>(&tgt))
mid="bin";
else if(const SharedLibrary *shlib=dynamic_cast<const SharedLibrary *>(&tgt))
{
unsigned flags=0;
for(ComponentList::iterator i=components.begin(); i!=components.end(); ++i)
- {
if(i->get_install())
{
if(i->get_type()==Component::PROGRAM)
flags|=BIN;
else if(i->get_type()==Component::LIBRARY || i->get_type()==Component::MODULE)
flags|=LIB;
+ else if(i->get_type()==Component::HEADERS)
+ flags|=INCLUDE;
}
- if(!i->get_install_headers().empty())
- flags|=INCLUDE;
- }
return flags;
}