]> git.tdb.fi Git - builder.git/commitdiff
Deprecate the headers component type
authorMikko Rasa <tdb@tdb.fi>
Tue, 10 Jul 2012 15:20:44 +0000 (18:20 +0300)
committerMikko Rasa <tdb@tdb.fi>
Tue, 10 Jul 2012 20:55:52 +0000 (23:55 +0300)
source/component.cpp
source/component.h
source/csourcefile.cpp
source/sourcepackage.cpp
source/sourcepackage.h

index 902cf49abfe6d1142d0d4c50819a7cc103e0edaa..f5ca812169c3d4b4910289c4bf97a8d1962fd502 100644 (file)
@@ -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<FileTarget *>(src)->get_install_location().empty())
+                                       inst_list.push_back(src);
                        }
                }
 
index 5efed1a08ad06bd1ef4db470b3c263f4f4d53f09..cdb3f8d8dba01f9829d917c6cdb0157848595986 100644 (file)
@@ -37,7 +37,6 @@ public:
 
        enum Type
        {
-               HEADERS,
                LIBRARY,
                PROGRAM,
                MODULE,
index 3c3aad935f965e7c039ad68bbe3d7419afb832f6..e2b029a0d1f7080d29a409f7962356db6799c966 100644 (file)
@@ -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()
index ab66c0056651cbfddaa768fed2dbb47577779870..904e2b49e5524a54434bf9a600c1644264ad2ab0 100644 (file)
@@ -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<Component::PROGRAM>);
        add("library",     &Loader::component<Component::LIBRARY>);
        add("module",      &Loader::component<Component::MODULE>);
-       add("headers",     &Loader::component<Component::HEADERS>);
+       add("headers",     &Loader::headers);
        add("install",     &Loader::component<Component::INSTALL>);
        add("datafile",    &Loader::component<Component::DATAFILE>);
        add("tarball",     &Loader::tarball);
@@ -267,6 +265,21 @@ void SourcePackage::Loader::finish()
 {
        SourcePackage &spkg = static_cast<SourcePackage &>(pkg);
        spkg.components.sort(component_sort);
+
+       for(map<string, string>::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<InstallMap &>(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<SourcePackage &>(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<SourcePackage &>(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<SourcePackage &>(pkg);
index b09ccf2a704f993cd8d873e0b28c2e198cf5149f..8ba3eb3c899fa4febd920ba9b18bcc2e6920e535 100644 (file)
@@ -36,6 +36,9 @@ public:
 
        class Loader: public Package::Loader
        {
+       private:
+               std::map<std::string, std::string> install_map;
+
        public:
                Loader(Package &);
                SourcePackage &get_object() { return static_cast<SourcePackage &>(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 &);
        };