]> git.tdb.fi Git - builder.git/commitdiff
Refactor create_build_info functions and fix build info application order
authorMikko Rasa <tdb@tdb.fi>
Tue, 17 Jul 2012 13:05:35 +0000 (16:05 +0300)
committerMikko Rasa <tdb@tdb.fi>
Tue, 17 Jul 2012 13:05:35 +0000 (16:05 +0300)
source/component.cpp
source/sourcepackage.cpp

index e9d9a700d202d0fcebab400c01df24ca6e5484e5..5a735d09c4e6561484704d33e388906d542e404c 100644 (file)
@@ -38,6 +38,8 @@ void Component::prepare()
 
 void Component::create_build_info()
 {
+       BuildInfo final_build_info;
+
        const PackageList &pkg_reqs = package.get_required_packages();
        PackageList direct_reqs = requires;
        direct_reqs.insert(direct_reqs.end(), pkg_reqs.begin(), pkg_reqs.end());
@@ -48,7 +50,7 @@ void Component::create_build_info()
                BuildInfo::UpdateLevel level = BuildInfo::CHAINED;
                if(find(direct_reqs.begin(), direct_reqs.end(), *i)!=direct_reqs.end())
                        level = BuildInfo::DEPENDENCY;
-               build_info.update_from((*i)->get_exported_build_info(), level);
+               final_build_info.update_from((*i)->get_exported_build_info(), level);
 
                const PackageList &reqs = (*i)->get_required_packages();
                for(PackageList::const_iterator j=reqs.begin(); j!=reqs.end(); ++j)
@@ -56,13 +58,16 @@ void Component::create_build_info()
                                all_reqs.push_back(*j);
        }
 
-       build_info.update_from(package.get_build_info());
+       final_build_info.update_from(package.get_build_info());
 
        for(BuildInfo::PathList::iterator i=build_info.incpath.begin(); i!=build_info.incpath.end(); ++i)
                *i = (package.get_source_directory() / *i).str();
        for(BuildInfo::PathList::iterator i=build_info.libpath.begin(); i!=build_info.libpath.end(); ++i)
                *i = (package.get_source_directory() / *i).str();
 
+       final_build_info.update_from(build_info);
+       build_info = final_build_info;
+
        if(type==LIBRARY || type==MODULE)
                if(build_info.libmode<BuildInfo::DYNAMIC)
                        build_info.libmode = BuildInfo::DYNAMIC;
index d0524e84dab7af88e1d48f40c63fdded7b00e677..3b9f7f0ebebafcbd58f391fe39fe76cec57fa277 100644 (file)
@@ -70,32 +70,38 @@ FS::Path SourcePackage::get_out_dir() const
 
 void SourcePackage::create_build_info()
 {
+       BuildInfo final_build_info;
+
        if(build_type)
-               build_info.update_from(build_type->get_build_info());
+               final_build_info.update_from(build_type->get_build_info());
+
+       final_build_info.update_from(build_info);
+       build_info = final_build_info;
 
        build_info.incpath.push_back((builder.get_prefix()/"include").str());
        build_info.libpath.push_back((builder.get_prefix()/"lib").str());
 
-       bool export_paths = false;
-       for(ComponentList::const_iterator i=components.begin(); (!export_paths && i!=components.end()); ++i)
-               export_paths = (i->get_type()==Component::LIBRARY);
-
-       if(export_paths)
-       {
-               export_binfo.incpath.push_back((builder.get_prefix()/"include").str());
-               export_binfo.libpath.push_back((builder.get_prefix()/"lib").str());
-       }
-
        for(FeatureList::iterator i=features.begin(); i!=features.end(); ++i)
                if(lexical_cast<bool>(config.get_option("with_"+i->name).value))
                        build_info.defines["WITH_"+toupper(i->name)] = "1";
 
+       bool export_paths = false;
        for(list<Component>::iterator i=components.begin(); i!=components.end(); ++i)
        {
                i->prepare();
                i->create_build_info();
+
                if(i->get_type()==Component::LIBRARY)
+               {
                        export_binfo.libs.push_back(i->get_name());
+                       export_paths = true;
+               }
+       }
+
+       if(export_paths)
+       {
+               export_binfo.incpath.push_back((builder.get_prefix()/"include").str());
+               export_binfo.libpath.push_back((builder.get_prefix()/"lib").str());
        }
 }