From: Mikko Rasa Date: Tue, 10 Jul 2012 15:20:44 +0000 (+0300) Subject: Deprecate the headers component type X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=75ac80cb255e4def7ee685ce9c46db7c2f6625aa;p=builder.git Deprecate the headers component type --- diff --git a/source/component.cpp b/source/component.cpp index 902cf49..f5ca812 100644 --- a/source/component.cpp +++ b/source/component.cpp @@ -158,23 +158,6 @@ void Component::create_targets() const if(install) inst_list.push_back(result); } - else - { - for(PathList::const_iterator i=source_filenames.begin(); i!=source_filenames.end(); ++i) - { - string ext = FS::extpart(FS::basename(*i)); - if(ext==".h") - { - FileTarget *hdr = builder.get_vfs().get_target(*i); - if(!hdr) - hdr = new CSourceFile(builder, *this, *i); - - // Install headers if requested - if(type==HEADERS && install) - inst_list.push_back(hdr); - } - } - } if(type==PROGRAM || type==LIBRARY || type==MODULE) { @@ -182,12 +165,18 @@ void Component::create_targets() const for(PathList::const_iterator i=source_filenames.begin(); i!=source_filenames.end(); ++i) { string ext = FS::extpart(FS::basename(*i)); - const Tool *tool = toolchain.get_tool_for_suffix(ext); + const Tool *tool = toolchain.get_tool_for_suffix(ext, true); if(tool) { Target *src = tool->create_source(*this, *i); - Target *obj = tool->create_target(*src); - objs.push_back(obj); + if(tool->accepts_suffix(ext)) + { + Target *obj = tool->create_target(*src); + objs.push_back(obj); + } + + if(type==LIBRARY && install && !dynamic_cast(src)->get_install_location().empty()) + inst_list.push_back(src); } } diff --git a/source/component.h b/source/component.h index 5efed1a..cdb3f8d 100644 --- a/source/component.h +++ b/source/component.h @@ -37,7 +37,6 @@ public: enum Type { - HEADERS, LIBRARY, PROGRAM, MODULE, diff --git a/source/csourcefile.cpp b/source/csourcefile.cpp index 3c3aad9..e2b029a 100644 --- a/source/csourcefile.cpp +++ b/source/csourcefile.cpp @@ -19,7 +19,7 @@ CSourceFile::CSourceFile(Builder &b, const Component &c, const FS::Path &p): { string ext = FS::extpart(FS::basename(path)); if(ext==".h" || ext==".H" || ext==".hpp") - install_location = FS::Path("include")/component->get_name(); + install_location = FS::Path("include")/package->get_name(); } void CSourceFile::find_depends() diff --git a/source/sourcepackage.cpp b/source/sourcepackage.cpp index ab66c00..904e2b4 100644 --- a/source/sourcepackage.cpp +++ b/source/sourcepackage.cpp @@ -53,9 +53,7 @@ unsigned SourcePackage::get_install_flags() 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; + flags |= LIB|INCLUDE; } return flags; @@ -233,7 +231,7 @@ void SourcePackage::create_targets() for(ComponentList::const_iterator i=components.begin(); i!=components.end(); ++i) { i->create_targets(); - if(i->get_type()==Component::LIBRARY || i->get_type()==Component::HEADERS) + if(i->get_type()==Component::LIBRARY) pc_needed = true; } @@ -256,7 +254,7 @@ SourcePackage::Loader::Loader(Package &p): add("program", &Loader::component); add("library", &Loader::component); add("module", &Loader::component); - add("headers", &Loader::component); + add("headers", &Loader::headers); add("install", &Loader::component); add("datafile", &Loader::component); add("tarball", &Loader::tarball); @@ -267,6 +265,21 @@ void SourcePackage::Loader::finish() { SourcePackage &spkg = static_cast(pkg); spkg.components.sort(component_sort); + + for(map::const_iterator i=install_map.begin(); i!=install_map.end(); ++i) + { + for(ComponentList::iterator j=spkg.components.begin(); j!=spkg.components.end(); ++j) + { + const StringList &sources = j->get_sources(); + for(StringList::const_iterator k=sources.begin(); k!=sources.end(); ++k) + { + if(!i->first.compare(0, k->size(), *k)) + { + const_cast(j->get_install_map()).add_mapping(spkg.source/i->first, i->second); + } + } + } + } } void SourcePackage::Loader::feature(const string &n, const string &d) @@ -300,6 +313,17 @@ void SourcePackage::Loader::build_info() load_sub(static_cast(pkg).build_info); } +void SourcePackage::Loader::headers(const string &n) +{ + IO::print("%s: Note: headers components are deprecated\n", get_source()); + SourcePackage &spkg = static_cast(pkg); + Component comp(spkg, Component::LIBRARY, n); + load_sub(comp); + const StringList &sources = comp.get_sources(); + for(StringList::const_iterator i=sources.begin(); i!=sources.end(); ++i) + install_map[*i] = "include/"+comp.get_name(); +} + void SourcePackage::Loader::tarball(const string &n) { SourcePackage &spkg = static_cast(pkg); diff --git a/source/sourcepackage.h b/source/sourcepackage.h index b09ccf2..8ba3eb3 100644 --- a/source/sourcepackage.h +++ b/source/sourcepackage.h @@ -36,6 +36,9 @@ public: class Loader: public Package::Loader { + private: + std::map install_map; + public: Loader(Package &); SourcePackage &get_object() { return static_cast(pkg); } @@ -46,6 +49,7 @@ public: void component(const std::string &); void condition(const std::string &); void build_info(); + void headers(const std::string &); void tarball(const std::string &); void tar_file(const std::string &); };