]> git.tdb.fi Git - builder.git/commitdiff
Move some target creation logic to SourcePackage
authorMikko Rasa <tdb@tdb.fi>
Wed, 20 Jun 2012 21:02:55 +0000 (00:02 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sun, 8 Jul 2012 21:08:53 +0000 (00:08 +0300)
source/builder.cpp
source/package.h
source/sourcepackage.cpp
source/sourcepackage.h

index e8f8927d580ea0e2739aadf1bd32b055f420e1a5..115968982ef93cb5b71700ae868a1c647ad3b499 100644 (file)
@@ -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<SourcePackage *>(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
index e63fd77ff09fd26d50ba670e1c33a129a0ff12ab..e107abc273fd1f691ef7d31cc55cfd36d3197d6d 100644 (file)
@@ -62,6 +62,9 @@ public:
 protected:
        virtual void do_configure(const StringMap &, unsigned) { }
        virtual void create_build_info() { }
+
+public:
+       virtual void create_targets() { }
 };
 
 #endif
index 7d0ed1d97095f034ff074a8d46858ddb9a36db11..246a6db5187db78ac9b88264b171f8f9b2530dba 100644 (file)
@@ -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)
index cf63b0ecbb8dd1c9960d8563751b966cd31989ea..b09ccf2a704f993cd8d873e0b28c2e198cf5149f 100644 (file)
@@ -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