]> git.tdb.fi Git - builder.git/commitdiff
Deprecate the install_headers statement
authorMikko Rasa <tdb@tdb.fi>
Tue, 5 May 2009 19:44:22 +0000 (19:44 +0000)
committerMikko Rasa <tdb@tdb.fi>
Tue, 5 May 2009 19:44:22 +0000 (19:44 +0000)
Use the headers component name as install location

source/component.cpp
source/component.h
source/install.cpp
source/sourcepackage.cpp

index dd33941c7ed20f6b08b0bf8e4929f26ddf5c57fe..338b44f43c0e83c10ebd62133533d7bf2b642db0 100644 (file)
@@ -5,6 +5,7 @@ Copyright © 2006-2009  Mikko Rasa, Mikkosoft Productions
 Distributed under the LGPL
 */
 
+#include <iostream>
 #include <msp/core/except.h>
 #include <msp/fs/dir.h>
 #include <msp/fs/stat.h>
@@ -109,7 +110,7 @@ void Component::create_targets() const
                                hdr=new Header(builder, this, i->str());
 
                        // Install headers if requested
-                       if(!install_headers.empty())
+                       if(type==HEADERS && install)
                                inst_tgts.push_back(hdr);
                }
        }
@@ -174,7 +175,7 @@ Component::Loader::Loader(Component &c):
 {
        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);
@@ -182,6 +183,17 @@ Component::Loader::Loader(Component &c):
        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);
@@ -216,6 +228,18 @@ void Component::Loader::host(const string &n)
        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);
index ce4a821c822e5d6dcf99485fed93e0ee51e42c58..899abc37c81b21e7f41237ffb69b07145dd94fa4 100644 (file)
@@ -30,15 +30,18 @@ public:
        {
        private:
                Component &comp;
+               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();
        };
 
@@ -56,7 +59,6 @@ protected:
        std::string name;
        PathList sources;
        bool install;
-       std::string install_headers;
        const Component *module_host;
        bool modular;
        BuildInfo build_info;
@@ -71,7 +73,6 @@ public:
        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; }
index 1eb510e4505f768f49d82aebadfddcd51e126cc4..d80f9a74d80e15f9c2110f4c9745e6ba0dd7a8d9 100644 (file)
@@ -51,7 +51,11 @@ FS::Path Install::generate_target_path(const FileTarget &tgt)
 
        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))
index 4edb70280917fa0f5fda438df9685bdfc5dfe613..432575f400db29633003b115013d78e361adaaa0 100644 (file)
@@ -43,17 +43,15 @@ unsigned SourcePackage::get_install_flags()
 {
        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;
 }