]> git.tdb.fi Git - builder.git/blobdiff - source/builder.cpp
Update deprecated things
[builder.git] / source / builder.cpp
index bbb95b6634cb03292ae1d37a017bd82094ce6eba..6eeaa2fa3ca3b39e05298b3bd780ff5401cccbaa 100644 (file)
@@ -7,23 +7,18 @@
 #include <msp/io/file.h>
 #include <msp/io/print.h>
 #include <msp/strings/format.h>
-#include <msp/time/units.h>
+#include <msp/time/timedelta.h>
 #include <msp/time/utils.h>
+#include "androidtools.h"
 #include "binarypackage.h"
 #include "builder.h"
-#include "copy.h"
+#include "builtintools.h"
 #include "datatool.h"
-#include "gnuarchiver.h"
-#include "gnuccompiler.h"
-#include "gnucxxcompiler.h"
-#include "gnulinker.h"
 #include "installedfile.h"
-#include "mingwdlltool.h"
 #include "package.h"
-#include "pkgconfiggenerator.h"
 #include "sharedlibrary.h"
 #include "sourcepackage.h"
-#include "tar.h"
+#include "systemtools.h"
 #include "task.h"
 #include "virtualtarget.h"
 
@@ -81,15 +76,10 @@ void Builder::set_temp_directory(const FS::Path &p)
 
 void Builder::add_default_tools()
 {
-       toolchain.add_tool(new GnuCCompiler(*this, *current_arch));
-       toolchain.add_tool(new GnuCxxCompiler(*this, *current_arch));
-       toolchain.add_tool(new GnuLinker(*this, *current_arch));
-       toolchain.add_tool(new GnuArchiver(*this, *current_arch));
-       toolchain.add_tool(new Copy(*this));
-       toolchain.add_tool(new Tar(*this));
-       toolchain.add_tool(new PkgConfigGenerator(*this));
-       if(current_arch->get_system()=="windows")
-               toolchain.add_tool(new MingwDllTool(*this, *current_arch));
+       if(current_arch->get_system()=="android")
+               toolchain.add_toolchain(new AndroidTools(*this, *current_arch));
+       toolchain.add_toolchain(new SystemTools(*this, *current_arch));
+       toolchain.add_toolchain(new BuiltinTools(*this));
        toolchain.add_tool(new DataTool(*this));
 }
 
@@ -98,9 +88,57 @@ void Builder::set_logger(const Logger *l)
        logger = (l ? l : &default_logger);
 }
 
-void Builder::problem(const string &p, const string &d)
+list<string> Builder::collect_problems() const
 {
-       problems.push_back(Problem(p, d));
+       list<string> problems;
+       set<const Package *> broken_packages;
+       set<const Component *> broken_components;
+       set<const Tool *> broken_tools;
+
+       const BuildGraph::TargetMap &targets = build_graph.get_targets();
+       for(BuildGraph::TargetMap::const_iterator i=targets.begin(); i!=targets.end(); ++i)
+               if(i->second->is_broken())
+               {
+                       const list<string> &tgt_problems = i->second->get_problems();
+                       for(list<string>::const_iterator j=tgt_problems.begin(); j!=tgt_problems.end(); ++j)
+                               problems.push_back(format("%s: %s", i->second->get_name(), *j));
+
+                       const Package *package = i->second->get_package();
+                       if(package && !package->get_problems().empty())
+                               broken_packages.insert(package);
+
+                       const Component *component = i->second->get_component();
+                       if(component && !component->get_problems().empty())
+                               broken_components.insert(component);
+
+                       const Tool *tool = i->second->get_tool();
+                       if(tool && !tool->get_problems().empty())
+                               broken_tools.insert(tool);
+               }
+
+       // TODO Sort components after their packages, and targets last
+       for(set<const Package *>::const_iterator i=broken_packages.begin(); i!=broken_packages.end(); ++i)
+       {
+               const list<string> &pkg_problems = (*i)->get_problems();
+               for(list<string>::const_iterator j=pkg_problems.begin(); j!=pkg_problems.end(); ++j)
+                       problems.push_back(format("%s: %s", (*i)->get_name(), *j));
+       }
+
+       for(set<const Component *>::const_iterator i=broken_components.begin(); i!=broken_components.end(); ++i)
+       {
+               const list<string> &comp_problems = (*i)->get_problems();
+               for(list<string>::const_iterator j=comp_problems.begin(); j!=comp_problems.end(); ++j)
+                       problems.push_back(format("%s/%s: %s", (*i)->get_package().get_name(), (*i)->get_name(), *j));
+       }
+
+       for(set<const Tool *>::const_iterator i=broken_tools.begin(); i!=broken_tools.end(); ++i)
+       {
+               const list<string> &tool_problems = (*i)->get_problems();
+               for(list<string>::const_iterator j=tool_problems.begin(); j!=tool_problems.end(); ++j)
+                       problems.push_back(format("%s: %s", (*i)->get_tag(), *j));
+       }
+
+       return problems;
 }
 
 void Builder::load_build_file(const FS::Path &fn, const Config::InputOptions *opts, bool all)
@@ -217,12 +255,12 @@ int Builder::clean(bool all, bool dry_run)
 
        set<Target *> clean_tgts;
        list<Target *> queue;
-       queue.push_back(build_graph.get_target("cmdline"));
+       queue.push_back(&build_graph.get_goals());
 
        while(!queue.empty())
        {
                Target *tgt = queue.front();
-               queue.erase(queue.begin());
+               queue.pop_front();
 
                if(tgt->is_buildable() && (tgt->get_package()==&package_manager.get_main_package() || all))
                        clean_tgts.insert(tgt);
@@ -252,7 +290,6 @@ Builder::Loader::Loader(Builder &b, const Config::InputOptions *o, bool a):
        add("architecture", &Loader::architecture);
        add("binary_package", &Loader::binpkg);
        add("build_type", &Loader::build_type);
-       add("profile", &Loader::profile);
        add("package", &Loader::package);
 
        if(!obj.top_loader)
@@ -288,11 +325,6 @@ void Builder::Loader::build_type(const string &n)
                obj.build_type = &i->second;
 }
 
-void Builder::Loader::profile(const string &)
-{
-       IO::print("Profiles are deprecated\n");
-}
-
 void Builder::Loader::package(const string &n)
 {
        SourcePackage *pkg = new SourcePackage(obj, n, get_source());