]> git.tdb.fi Git - builder.git/commitdiff
Allow requirements for components
authorMikko Rasa <tdb@tdb.fi>
Sat, 30 Sep 2006 19:59:37 +0000 (19:59 +0000)
committerMikko Rasa <tdb@tdb.fi>
Sat, 30 Sep 2006 19:59:37 +0000 (19:59 +0000)
Use include path from component instead of package when resolving ObjectFile dependencies

source/component.cpp
source/component.h
source/objectfile.cpp
source/package.cpp
source/package.h

index e0630e6cf8a69547ecb27f6c845f5daa6857f041..6d80f3b0efc249511eae49e0d41cd0ec1d317172 100644 (file)
@@ -10,9 +10,24 @@ Component::Component(Package &p, Type t, const string &n):
        install(false)
 { }
 
+void Component::resolve_refs()
+{
+       for(list<PackageRef>::iterator i=requires.begin(); i!=requires.end(); ++i)
+               i->resolve();
+}
+
 void Component::create_build_info()
 {
        build_info.add(pkg.get_build_info());
+
+       for(list<PackageRef>::iterator i=requires.begin(); i!=requires.end(); ++i)
+       {
+               if(!i->get_package())
+                       continue;
+               i->get_package()->create_build_info();
+               build_info.add(i->get_package()->get_exported_binfo());
+       }
+
        build_info.unique();
 }
 
@@ -23,6 +38,7 @@ Component::Loader::Loader(Component &c):
        add("install",         &Component::install);
        add("install_headers", &Component::install_headers);
        add("build_info",      &Loader::build_info);
+       add("require",         &Loader::require);
 }
 
 void Component::Loader::source(const string &s)
@@ -30,6 +46,11 @@ void Component::Loader::source(const string &s)
        comp.sources.push_back(comp.pkg.get_source()/s);
 }
 
+void Component::Loader::require(const string &n)
+{
+       comp.requires.push_back(PackageRef(comp.pkg.get_builder(), n));
+}
+
 void Component::Loader::build_info()
 {
        load_sub(comp.build_info);
index b1ce222de40ce0bed9694ec9d585b2bb9dce77ba..04a0a41103b858a2a483c7b97e8ff75c2b3fcb68 100644 (file)
@@ -6,6 +6,7 @@
 #include <msp/path/path.h>
 #include "buildinfo.h"
 #include "misc.h"
+#include "packageref.h"
 
 class Package;
 
@@ -21,6 +22,7 @@ public:
                Component &comp;
 
                void source(const std::string &);
+               void require(const std::string &);
                void build_info();
        };
        
@@ -40,6 +42,7 @@ public:
        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; }
+       void              resolve_refs();
        void              create_build_info();
 protected:
        Package     &pkg;
@@ -49,6 +52,7 @@ protected:
        bool        install;
        std::string install_headers;
        BuildInfo   build_info;
+       std::list<PackageRef> requires;
 };
 typedef std::list<Component> ComponentList;
 
index bba701d23bc48ca87d03f42790a78f4640a5f907..8fbbed1913539bbee8718fef4549a028c8483ae6 100644 (file)
@@ -59,7 +59,7 @@ void ObjectFile::find_depends(Target *tgt)
        const list<string> &includes=src->get_includes();
        for(list<string>::const_iterator i=includes.begin(); i!=includes.end(); ++i)
        {
-               Target *hdr2=builder.get_header(*i, path, package->get_build_info().incpath);
+               Target *hdr2=builder.get_header(*i, path, comp.get_build_info().incpath);
                if(hdr2 && !contains(depends, hdr2))
                        add_depend(hdr2);
        }
index 2d5d97ccd49a4a8585c8ae573b549b0569eefb90..c55e5f47272122951c2e370bc6c6d632e156eb40 100644 (file)
@@ -38,6 +38,8 @@ void Package::resolve_refs()
 {
        for(list<PackageRef>::iterator i=requires.begin(); i!=requires.end(); ++i)
                i->resolve();
+       for(ComponentList::iterator i=components.begin(); i!=components.end(); ++i)
+               i->resolve_refs();
 }
 
 void Package::create_build_info()
index d5402ef9a168c6563ec01c6e0e573cf1c68cbdfc..bb2c41322c7dbd6185257159a1f7fff03ada4461 100644 (file)
@@ -40,6 +40,7 @@ public:
        const std::list<PackageRef> &get_requires() const { return requires; }
        const BuildInfo     &get_build_info() const { return build_info; }
        const BuildInfo     &get_exported_binfo() const { return export_binfo; }
+       Builder             &get_builder() const    { return builder; }
        void                resolve_refs();
        void                create_build_info();
        void                process_options(const RawOptionMap &);