]> git.tdb.fi Git - builder.git/blobdiff - source/component.cpp
Add the corresponding generated source directory to local include path
[builder.git] / source / component.cpp
index a42b81cded44229d877882c535b11c2982ecfb77..2d09f8a0cd007ed12f9e7c09d2a1c78cc4670b47 100644 (file)
@@ -2,9 +2,7 @@
 #include <msp/fs/dir.h>
 #include <msp/fs/stat.h>
 #include <msp/fs/utils.h>
-#include <msp/io/print.h>
-#include <msp/strings/lexicalcast.h>
-#include "booleanevaluator.h"
+#include <msp/strings/format.h>
 #include "builder.h"
 #include "component.h"
 #include "sourcepackage.h"
@@ -61,6 +59,19 @@ BuildInfo Component::get_build_info_for_path(const FS::Path &path) const
 {
        // XXX Cache these and check that the directories actually exist before adding them
        BuildInfo binfo = build_info;
+
+       FS::Path gen_dir = package.get_temp_directory()/"generated";
+       if(FS::descendant_depth(path, gen_dir)>=0)
+       {
+               FS::Path subdir = FS::dirname(FS::relative(path, gen_dir));
+               binfo.local_incpath.push_back(package.get_source_directory()/subdir);
+       }
+       else
+       {
+               FS::Path subdir = FS::dirname(FS::relative(path, package.get_source_directory()));
+               binfo.local_incpath.push_back(gen_dir/subdir);
+       }
+
        if(!overlays.empty())
        {
                FS::Path dir = FS::dirname(path);
@@ -103,8 +114,8 @@ Component::SourceList Component::collect_source_files() const
                        for(SourceList::const_iterator j=dirs.begin(); j!=dirs.end(); ++j)
                        {
                                package.get_builder().get_logger().log("files", format("Traversing %s", *j));
-                               list<string> sfiles = list_files(*j);
-                               for(list<string>::iterator k=sfiles.begin(); k!=sfiles.end(); ++k)
+                               vector<string> sfiles = list_files(*j);
+                               for(vector<string>::iterator k=sfiles.begin(); k!=sfiles.end(); ++k)
                                {
                                        if(j!=dirs.begin())
                                        {
@@ -112,7 +123,9 @@ Component::SourceList Component::collect_source_files() const
                                                        continue;
                                                overlay_files.insert(*k);
                                        }
-                                       files.push_back(*j / *k);
+                                       FS::Path fn = *j / *k;
+                                       if(!FS::is_dir(fn))
+                                               files.push_back(fn);
                                }
                        }
                }
@@ -133,10 +146,9 @@ Component::SourceList Component::collect_source_files() const
 
 
 Component::Loader::Loader(Component &c):
-       DataFile::ObjectLoader<Component>(c)
+       DataFile::ObjectLoader<Component>(c),
+       ConditionalLoader(c.package, format("%s/%s", c.package.get_name(), c.name))
 {
-       add("if_arch",         &Loader::if_arch);
-       add("if_feature",      &Loader::if_feature);
        add("overlay",         &Loader::overlay);
        add("source",          &Loader::source);
        add("install",         &Component::install);
@@ -151,26 +163,6 @@ void Component::Loader::build_info()
        load_sub(obj.build_info);
 }
 
-void Component::Loader::if_arch(const string &cond)
-{
-       BooleanEvaluator eval(sigc::hide<1>(sigc::mem_fun(&obj.package.get_builder().get_current_arch(), &Architecture::match_name)), false);
-       bool match = eval.evaluate(cond);
-       obj.package.get_builder().get_logger().log("configure",
-               format("%s/%s: arch %s %smatched", obj.package.get_name(), obj.name, cond, (match ? "" : "not ")));
-       if(match)
-               load_sub_with(*this);
-}
-
-void Component::Loader::if_feature(const string &cond)
-{
-       BooleanEvaluator eval(sigc::mem_fun(&obj.package, &SourcePackage::match_feature));
-       bool match = eval.evaluate(cond);
-       obj.package.get_builder().get_logger().log("configure",
-               format("%s/%s: feature %s %smatched", obj.package.get_name(), obj.name, cond, (match ? "" : "not ")));
-       if(match)
-               load_sub_with(*this);
-}
-
 void Component::Loader::install_map()
 {
        load_sub(obj.install_map, obj.package.get_source_directory());