From: Mikko Rasa Date: Wed, 20 Jun 2012 21:02:55 +0000 (+0300) Subject: Move some target creation logic to SourcePackage X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;ds=sidebyside;h=102de418e552cb1e1f91bb85954c4c101fdea82d;p=builder.git Move some target creation logic to SourcePackage --- diff --git a/source/builder.cpp b/source/builder.cpp index e8f8927..1159689 100644 --- a/source/builder.cpp +++ b/source/builder.cpp @@ -24,7 +24,6 @@ #include "gnulinker.h" #include "installedfile.h" #include "package.h" -#include "pkgconfigfile.h" #include "pkgconfiggenerator.h" #include "sharedlibrary.h" #include "sourcepackage.h" @@ -495,24 +494,8 @@ int Builder::create_targets() world->add_depend(tarballs); for(PackageMap::const_iterator i=packages.begin(); i!=packages.end(); ++i) - { - if(!i->second || !i->second->is_configured()) - continue; - - SourcePackage *spkg = dynamic_cast(i->second); - if(!spkg) - continue; - - const ComponentList &components = spkg->get_components(); - for(ComponentList::const_iterator j=components.begin(); j!=components.end(); ++j) - j->create_targets(); - - if(spkg->get_install_flags()&(SourcePackage::LIB|SourcePackage::INCLUDE)) - { - PkgConfigFile *pc = new PkgConfigFile(*this, *spkg); - install->add_depend(toolchain.get_tool("CP").create_target(*pc)); - } - } + if(i->second && i->second->is_configured()) + i->second->create_targets(); // Apply what-ifs // XXX This does not currently work with targets found during dependency discovery diff --git a/source/package.h b/source/package.h index e63fd77..e107abc 100644 --- a/source/package.h +++ b/source/package.h @@ -62,6 +62,9 @@ public: protected: virtual void do_configure(const StringMap &, unsigned) { } virtual void create_build_info() { } + +public: + virtual void create_targets() { } }; #endif diff --git a/source/sourcepackage.cpp b/source/sourcepackage.cpp index 7d0ed1d..246a6db 100644 --- a/source/sourcepackage.cpp +++ b/source/sourcepackage.cpp @@ -5,6 +5,8 @@ #include "binarypackage.h" #include "builder.h" #include "misc.h" +#include "pkgconfigfile.h" +#include "tool.h" #include "sourcepackage.h" using namespace std; @@ -226,6 +228,23 @@ void SourcePackage::create_build_info() } } +void SourcePackage::create_targets() +{ + bool pc_needed = false; + for(ComponentList::const_iterator i=components.begin(); i!=components.end(); ++i) + { + i->create_targets(); + if(i->get_type()==Component::LIBRARY || i->get_type()==Component::HEADERS) + pc_needed = true; + } + + if(pc_needed) + { + PkgConfigFile *pc = new PkgConfigFile(builder, *this); + builder.get_target("install")->add_depend(builder.get_toolchain().get_tool("CP").create_target(*pc)); + } +} + SourcePackage::Loader::Loader(Package &p): Package::Loader(p) diff --git a/source/sourcepackage.h b/source/sourcepackage.h index cf63b0e..b09ccf2 100644 --- a/source/sourcepackage.h +++ b/source/sourcepackage.h @@ -92,6 +92,8 @@ private: /** Fills in build info based on configuration. All required packages must be configured when this is called. */ virtual void create_build_info(); + + virtual void create_targets(); }; #endif