X-Git-Url: http://git.tdb.fi/?p=builder.git;a=blobdiff_plain;f=source%2Fsourcepackage.cpp;h=1dd7dbd1062263b91f71bc7fd0cd007cd28e8f97;hp=ddfa00fb9bf3175eb59a7391b2e16cd38555370b;hb=35f2979869bff43706f3163ec0979c7084aaa3c4;hpb=ec0d6014aa2db4a02588c9027e7dba17507df364 diff --git a/source/sourcepackage.cpp b/source/sourcepackage.cpp index ddfa00f..1dd7dbd 100644 --- a/source/sourcepackage.cpp +++ b/source/sourcepackage.cpp @@ -1,13 +1,19 @@ +#include #include +#include #include #include #include #include +#include "binarycomponent.h" #include "binarypackage.h" #include "booleanevaluator.h" #include "builder.h" +#include "datapackcomponent.h" #include "file.h" +#include "installcomponent.h" #include "pkgconfigfile.h" +#include "tarballcomponent.h" #include "tool.h" #include "sourcegenerator.h" #include "sourcepackage.h" @@ -15,14 +21,6 @@ using namespace std; using namespace Msp; -namespace { - -bool component_sort(const Component &c1, const Component &c2) -{ return c1.get_type()get_name()==n) + return **i; + throw key_error(n); +} + bool SourcePackage::match_feature(const string &feat, const string *comp) const { string value = config.get_option("with_"+feat).value; @@ -101,37 +113,24 @@ void SourcePackage::do_prepare() build_info.defines[ident] = "1"; } - bool export_paths = false; - for(list::iterator i=components.begin(); i!=components.end(); ++i) + for(ComponentList::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; - } - } + (*i)->prepare(); + (*i)->create_build_info(); - if(export_paths) - { - export_binfo.incpath.push_back((builder.get_prefix()/"include").str()); - export_binfo.libpath.push_back((builder.get_prefix()/"lib").str()); + (*i)->update_exported_build_info(export_binfo); } cache.load(); - bool pc_needed = false; - for(ComponentList::const_iterator i=components.begin(); i!=components.end(); ++i) - { - i->create_targets(); - if(i->get_type()==Component::LIBRARY) - pc_needed = true; - } + for(ComponentList::iterator i=components.begin(); i!=components.end(); ++i) + (*i)->create_targets(); - if(pc_needed) + if(!export_binfo.libs.empty()) { + export_binfo.incpath.push_back((builder.get_prefix()/"include").str()); + export_binfo.libpath.push_back((builder.get_prefix()/"lib").str()); + PkgConfigFile *pc = new PkgConfigFile(builder, *this); builder.get_build_graph().get_target("install")->add_dependency(*builder.get_toolchain().get_tool("CP").create_target(*pc)); } @@ -164,12 +163,12 @@ void SourcePackage::Loader::init(const Config::InputOptions *o) add("feature", &Loader::feature); add("generate", &Loader::generate); add("if_feature", &Loader::if_feature); - add("program", &Loader::component); - add("library", &Loader::component); - add("module", &Loader::component); - add("install", &Loader::component); + add("program", &Loader::component_arg); + add("library", &Loader::component_arg); + add("module", &Loader::component_arg); + add("install", &Loader::component); add("interface_version", &Loader::interface_version); - add("datapack", &Loader::component); + add("datapack", &Loader::component); add("source_tarball", &Loader::source_tarball); add("tarball", &Loader::tarball); add("version", &Loader::version); @@ -177,7 +176,11 @@ void SourcePackage::Loader::init(const Config::InputOptions *o) void SourcePackage::Loader::finish() { - obj.components.sort(component_sort); + /* Make sure the source tarball is last in the list so targets from all + other components wil be created first */ + ComponentList::iterator i = find(obj.components.begin(), obj.components.end(), obj.source_tarball); + if(i!=obj.components.end()) + obj.components.splice(obj.components.end(), obj.components, i); } void SourcePackage::Loader::feature(const string &n, const string &d) @@ -196,11 +199,19 @@ void SourcePackage::Loader::feature(const string &n, const string &d) } } -template +template void SourcePackage::Loader::component(const string &n) { - Component comp(obj, t, n); - load_sub(comp); + C *comp = new C(obj, n); + load_sub(*comp); + obj.components.push_back(comp); +} + +template +void SourcePackage::Loader::component_arg(const string &n) +{ + C *comp = new C(obj, n, a); + load_sub(*comp); obj.components.push_back(comp); } @@ -239,7 +250,7 @@ void SourcePackage::Loader::source_tarball() void SourcePackage::Loader::tarball(const string &n) { - Component trbl(obj, Component::TARBALL, n); + TarballComponent trbl(obj, n); load_sub(trbl); }