]> git.tdb.fi Git - builder.git/blobdiff - source/component.cpp
It's okay to throw exceptions from Loader functions
[builder.git] / source / component.cpp
index feb5094b27a071fa8823eabd4e09c2fae466a11d..6bfce1fb6b8682f19c775552812b26af9da1b451 100644 (file)
@@ -68,6 +68,19 @@ void Component::create_build_info()
        final_build_info.update_from(build_info);
        build_info = final_build_info;
 
+       for(UseList::const_iterator i=uses.begin(); i!=uses.end(); ++i)
+       {
+               /* Select an include path that contains all the sources for this and the
+               used component.  This should produce a sensible result in most cases. */
+               FS::Path base;
+               for(SourceList::const_iterator j=sources.begin(); j!=sources.end(); ++j)
+                       base = base.empty() ? *j : FS::common_ancestor(base, *j);
+               const SourceList &use_sources = (*i)->get_sources();
+               for(SourceList::const_iterator j=use_sources.begin(); j!=use_sources.end(); ++j)
+                       base = FS::common_ancestor(base, *j);
+               build_info.incpath.push_back(base);
+       }
+
        if(type==LIBRARY || type==MODULE)
                if(build_info.libmode<BuildInfo::DYNAMIC)
                        build_info.libmode = BuildInfo::DYNAMIC;
@@ -289,5 +302,5 @@ void Component::Loader::use(const string &n)
                        obj.uses.push_back(&*i);
                        return;
                }
-       error(format("Unknown library component '%s'", n));
+       throw invalid_argument("Component::Loader::use");
 }