]> git.tdb.fi Git - builder.git/commitdiff
Various fixes to package dependency and build info handling
authorMikko Rasa <tdb@tdb.fi>
Wed, 10 Feb 2010 14:18:12 +0000 (14:18 +0000)
committerMikko Rasa <tdb@tdb.fi>
Wed, 10 Feb 2010 14:18:12 +0000 (14:18 +0000)
source/builder.cpp
source/component.cpp
source/package.cpp
source/package.h
source/sourcepackage.cpp
source/sourcepackage.h

index 37ad766fe26c7a3ba501caef1c3217c730534a89..55bee1507c9e1253e399bb50dd2ef926d9eb1aa4 100644 (file)
@@ -243,33 +243,42 @@ int Builder::main()
                return 0;
        }
 
-       if(!conf_only && create_targets())
-               return 1;
-
-       PackageList all_reqs = main_pkg->collect_requires();
-
        if(conf_only)
                return 0;
 
+       if(create_targets())
+               return 1;
+
        if(verbose>=2)
        {
                IO::print("Building on %s, for %s%s\n", native_arch.get_name(),
                        current_arch->get_name(), (current_arch->is_native() ? " (native)" : ""));
                IO::print("Prefix is %s\n", prefix);
        }
+
        if(verbose>=1)
-               IO::print("%d active packages, %d targets\n", all_reqs.size(), targets.size());
+       {
+               unsigned n_packages = 0;
+               for(PackageMap::const_iterator i=packages.begin(); i!=packages.end(); ++i)
+                       if(i->second->is_configured())
+                               ++n_packages;
+               IO::print("%d active packages, %d targets\n", n_packages, targets.size());
+       }
+
        if(verbose>=2)
        {
-               for(PackageList::const_iterator i=all_reqs.begin(); i!=all_reqs.end(); ++i)
+               for(PackageMap::const_iterator i=packages.begin(); i!=packages.end(); ++i)
                {
-                       IO::print(" %s", (*i)->get_name());
-                       if(dynamic_cast<SourcePackage *>(*i))
+                       if(!i->second->is_configured())
+                               continue;
+
+                       IO::print(" %s", i->second->get_name());
+                       if(dynamic_cast<SourcePackage *>(i->second))
                                IO::print("*");
                        unsigned count = 0;
                        unsigned to_be_built = 0;
                        for(TargetMap::iterator j=targets.begin(); j!=targets.end(); ++j)
-                               if(j->second->get_package()==*i)
+                               if(j->second->get_package()==i->second)
                                {
                                        ++count;
                                        if(j->second->get_rebuild())
@@ -599,10 +608,12 @@ int Builder::create_targets()
        Target *tarballs = new VirtualTarget(*this, "tarballs");
        world->add_depend(tarballs);
 
-       PackageList all_reqs = main_pkg->collect_requires();
-       for(PackageList::iterator i=all_reqs.begin(); i!=all_reqs.end(); ++i)
+       for(PackageMap::const_iterator i=packages.begin(); i!=packages.end(); ++i)
        {
-               SourcePackage *spkg = dynamic_cast<SourcePackage *>(*i);
+               if(!i->second->is_configured())
+                       continue;
+
+               SourcePackage *spkg = dynamic_cast<SourcePackage *>(i->second);
                if(!spkg)
                        continue;
 
index cf4234607e978d1f6399a2732adaded39496602d..87252d574f98c67548861757cacbdc931a6bdf1e 100644 (file)
@@ -5,6 +5,7 @@ Copyright © 2006-2010  Mikko Rasa, Mikkosoft Productions
 Distributed under the LGPL
 */
 
+#include <algorithm>
 #include <msp/core/except.h>
 #include <msp/fs/dir.h>
 #include <msp/fs/stat.h>
@@ -41,10 +42,30 @@ Component::Component(SourcePackage &p, Type t, const string &n):
 
 void Component::create_build_info()
 {
-       build_info.add(pkg.get_build_info());
+       const PackageList &pkg_reqs = pkg.get_requires();
+       PackageList direct_reqs = requires;
+       direct_reqs.insert(direct_reqs.end(), pkg_reqs.begin(), pkg_reqs.end());
+
+       PackageList all_reqs = direct_reqs;
+       for(PackageList::iterator i=all_reqs.begin(); i!=all_reqs.end(); ++i)
+       {
+               if(find(direct_reqs.begin(), direct_reqs.end(), *i)!=direct_reqs.end())
+                       build_info.add((*i)->get_exported_binfo());
+               else
+               {
+                       const BuildInfo &ebi = (*i)->get_exported_binfo();
+                       build_info.cflags.insert(build_info.cflags.end(), ebi.cflags.begin(), ebi.cflags.end());
+                       build_info.incpath.insert(build_info.incpath.end(), ebi.incpath.begin(), ebi.incpath.end());
+                       build_info.defines.insert(build_info.defines.end(), ebi.defines.begin(), ebi.defines.end());
+               }
 
-       for(PackageList::iterator i=requires.begin(); i!=requires.end(); ++i)
-               build_info.add((*i)->get_exported_binfo());
+               const PackageList &reqs = (*i)->get_requires();
+               for(PackageList::const_iterator j=reqs.begin(); j!=reqs.end(); ++j)
+                       if(find(all_reqs.begin(), all_reqs.end(), *j)==all_reqs.end())
+                               all_reqs.push_back(*j);
+       }
+
+       build_info.add(pkg.get_build_info());
 
        for(StringList::iterator i=build_info.incpath.begin(); i!=build_info.incpath.end(); ++i)
                *i = (pkg.get_source() / *i).str();
@@ -53,9 +74,7 @@ void Component::create_build_info()
 
        if(pkg.get_library_mode()!=DYNAMIC)
        {
-               // XXX This may pull in some unnecessary libpaths too.  More thought required.
-               PackageList reqs = pkg.collect_requires();
-               for(PackageList::iterator i=reqs.begin(); i!=reqs.end(); ++i)
+               for(PackageList::iterator i=all_reqs.begin(); i!=all_reqs.end(); ++i)
                {
                        const BuildInfo &ebi = (*i)->get_exported_binfo();
                        build_info.libpath.insert(build_info.libpath.end(), ebi.libpath.begin(), ebi.libpath.end());
index f1374298eac0c8d14315a03d751498d5ba144a97..c3d7d75a0fcb037e021a9cfd45c219f8a694c552 100644 (file)
@@ -22,22 +22,6 @@ Package::Package(Builder &b, const string &n):
        use_pkgconfig(true)
 { }
 
-PackageList Package::collect_requires()
-{
-       PackageList result;
-       result.push_back(this);
-       for(PackageList::const_iterator i=requires.begin(); i!=requires.end(); ++i)
-       {
-               PackageList r = (*i)->collect_requires();
-               result.splice(result.end(), r);
-       }
-
-       result.sort();
-       result.unique();
-
-       return result;
-}
-
 void Package::configure(const StringMap &opts, unsigned flag)
 {
        if(conf_done)
index 2ee932bb8d7e00bb42361327c19164712d4ca2a7..411eff06060ac6048cc521cf91c0daf35cff0492 100644 (file)
@@ -56,10 +56,6 @@ public:
        Builder &get_builder() const { return builder; }
        const PackageList &get_requires() const { return requires; }
 
-       /** Returns a list of all directly and indirectly required packages,
-       including the package itself. */
-       PackageList collect_requires();
-
        const BuildInfo &get_exported_binfo() const { return export_binfo; }
 
        /// Indicates whether or not this package supports pkg-config
@@ -68,6 +64,8 @@ public:
        /** Processes configuration options that were most likely obtained from the
        command line. */
        void configure(const StringMap &, unsigned);
+
+       bool is_configured() const { return conf_done; }
 protected:
        virtual void do_configure(const StringMap &, unsigned) { }
        virtual void create_build_info() { }
index 3b107372c78935616ef98da15e2de2085c8ea765..df1677fcce8edc638f8a8eb66cfafe2b6dee7b25 100644 (file)
@@ -107,14 +107,6 @@ void SourcePackage::do_configure(const StringMap &opts, unsigned flag)
                                        requires.push_back(pkg);
                }
 
-       base_reqs = requires;
-
-       for(ComponentList::iterator i=components.begin(); i!=components.end(); ++i)
-       {
-               const PackageList &reqs = i->get_requires();
-               requires.insert(requires.end(), reqs.begin(), reqs.end());
-       }
-
        for(PackageList::iterator i=requires.begin(); i!=requires.end(); ++i)
        {
                BinaryPackage *bpkg = dynamic_cast<BinaryPackage *>(*i);
@@ -123,6 +115,13 @@ void SourcePackage::do_configure(const StringMap &opts, unsigned flag)
        }
 
        deps_cache.load();
+
+       for(ComponentList::iterator i=components.begin(); i!=components.end(); ++i)
+       {
+               const PackageList &reqs = i->get_requires();
+               for(PackageList::const_iterator j=reqs.begin(); j!=reqs.end(); ++j)
+                       (*j)->configure(opts, flag&2);
+       }
 }
 
 void SourcePackage::init_config()
@@ -150,16 +149,6 @@ void SourcePackage::create_build_info()
 {
        build_info.add(builder.get_current_arch().get_build_info());
 
-       for(PackageList::iterator i=base_reqs.begin(); i!=base_reqs.end(); ++i)
-       {
-               const BuildInfo &ebi = (*i)->get_exported_binfo();
-               build_info.add(ebi);
-
-               export_binfo.cflags.insert(export_binfo.cflags.end(), ebi.cflags.begin(), ebi.cflags.end());
-               export_binfo.incpath.insert(export_binfo.incpath.end(), ebi.incpath.begin(), ebi.incpath.end());
-               export_binfo.defines.insert(export_binfo.defines.end(), ebi.defines.begin(), ebi.defines.end());
-       }
-
        // XXX Currently, a package-specific settings will override cmdline.  This might or might not be desirable.
        const StringList &warnings = builder.get_warnings();
        build_info.warnings.insert(build_info.warnings.begin(), warnings.begin(), warnings.end());
index 883bbf65f345fe70fea0551ab14864362ba67526..e170399aa4ab14db6abd94a3b7bc1f17f884db66 100644 (file)
@@ -54,13 +54,11 @@ private:
        std::string description;
 
        Msp::FS::Path source;
-       PackageList base_reqs;
        FeatureList features;
        BuildInfo build_info;
        ConditionList conditions;
        ComponentList components;
        Config config;
-       bool conf_done;
        mutable DependencyCache deps_cache;
 
 public: