]> git.tdb.fi Git - builder.git/blobdiff - source/lib/component.cpp
Rearrange generated source paths
[builder.git] / source / lib / component.cpp
index 637bc187c8dc26fae0fa45600d7721a8dbe1387b..1ba258bd70a00f4011587bd3617ccff24796a7ce 100644 (file)
@@ -20,6 +20,21 @@ void Component::prepare()
                broken |= r->is_broken();
        }
 
+       if(!sources.empty())
+       {
+               for(auto i=sources.begin(); i!=sources.end(); ++i)
+               {
+                       FS::Path s = *i;
+                       if(!FS::is_dir(s))
+                               s = FS::dirname(s);
+
+                       if(i==sources.begin())
+                               source_base_path = s;
+                       else
+                               source_base_path = FS::common_ancestor(source_base_path, s);
+               }
+       }
+
        if(!problems.empty())
                broken = true;
 }
@@ -77,7 +92,7 @@ string Component::flatten_source_path(const FS::Path &source) const
        if(FS::descendant_depth(source, temp_dir)>=0)
                rel_src = FS::relative(source, temp_dir);
        else
-               rel_src = FS::relative(source, package.get_source_directory());
+               rel_src = FS::relative(source, source_base_path);
 
        string fn;
        for(const string &c: rel_src)
@@ -92,18 +107,6 @@ 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);