#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 "clangtools.h"
#include "datatool.h"
-#include "gnuarchiver.h"
-#include "gnuccompiler.h"
-#include "gnucxxcompiler.h"
-#include "gnulinker.h"
+#include "gnutools.h"
#include "installedfile.h"
-#include "mingwdlltool.h"
+#include "microsofttools.h"
#include "package.h"
-#include "pkgconfiggenerator.h"
#include "sharedlibrary.h"
#include "sourcepackage.h"
-#include "tar.h"
#include "task.h"
#include "virtualtarget.h"
}
}
+vector<string> Builder::get_build_types() const
+{
+ vector<string> keys;
+ keys.reserve(build_types.size());
+ for(const auto &kvp: build_types)
+ keys.push_back(kvp.first);
+ return keys;
+}
+
void Builder::set_build_type(const string &name)
{
build_type = &get_item(build_types, name);
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));
+ const string &arch_tc = current_arch->get_toolchain();
+ if(current_arch->get_system()=="android")
+ toolchain.add_toolchain(new AndroidTools(*this, *current_arch));
+ else if(arch_tc=="msvc")
+ toolchain.add_toolchain(new MicrosoftTools(*this, *current_arch));
+ else if(arch_tc=="clang")
+ toolchain.add_toolchain(new ClangTools(*this, *current_arch));
+ else if(arch_tc=="gnu")
+ toolchain.add_toolchain(new GnuTools(*this, *current_arch));
+ toolchain.add_toolchain(new BuiltinTools(*this));
toolchain.add_tool(new DataTool(*this));
}
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;
+
+ for(const auto &kvp: build_graph.get_targets())
+ if(kvp.second->is_broken())
+ {
+ for(const string &p: kvp.second->get_problems())
+ problems.push_back(format("%s: %s", kvp.second->get_name(), p));
+
+ const Package *package = kvp.second->get_package();
+ if(package && !package->get_problems().empty())
+ broken_packages.insert(package);
+
+ const Component *component = kvp.second->get_component();
+ if(component && !component->get_problems().empty())
+ broken_components.insert(component);
+
+ const Tool *tool = kvp.second->get_tool();
+ if(tool && !tool->get_problems().empty())
+ broken_tools.insert(tool);
+ }
+
+ // TODO Sort components after their packages, and targets last
+ for(const Package *p: broken_packages)
+ for(const string &b: p->get_problems())
+ problems.push_back(format("%s: %s", p->get_name(), b));
+
+ for(const Component *c: broken_components)
+ for(const string &b: c->get_problems())
+ problems.push_back(format("%s/%s: %s", c->get_package().get_name(), c->get_name(), b));
+
+ for(const Tool *t: broken_tools)
+ for(const string &b: t->get_problems())
+ problems.push_back(format("%s: %s", t->get_tag(), b));
+
+ return problems;
}
void Builder::load_build_file(const FS::Path &fn, const Config::InputOptions *opts, bool all)
loader.load(parser);
}
+void Builder::save_caches()
+{
+ for(const auto &kvp: package_manager.get_packages())
+ kvp.second->save_caches();
+}
+
int Builder::build(unsigned jobs, bool dry_run, bool show_progress)
{
unsigned total = build_graph.count_rebuild_targets();
else if(show_progress)
get_logger().log("summary", "Build complete");
- if(!dry_run)
- {
- const PackageManager::PackageMap &packages = package_manager.get_packages();
- for(PackageManager::PackageMap::const_iterator i=packages.begin(); i!=packages.end(); ++i)
- i->second->save_caches();
- }
-
return fail;
}
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);
- const Target::Dependencies &deps = tgt->get_dependencies();
- for(list<Target *>::const_iterator i=deps.begin(); i!=deps.end(); ++i)
- if(!clean_tgts.count(*i))
- queue.push_back(*i);
+ for(Target *t: tgt->get_dependencies())
+ if(!clean_tgts.count(t))
+ queue.push_back(t);
}
- for(set<Target *>::iterator i=clean_tgts.begin(); i!=clean_tgts.end(); ++i)
+ for(Target *t: clean_tgts)
{
- get_logger().log("tasks", format("RM %s", (*i)->get_name()));
+ get_logger().log("tasks", format("RM %s", t->get_name()));
if(!dry_run)
- (*i)->clean();
+ t->clean();
}
return 0;
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)
{
BuildType btype(n);
load_sub(btype);
- BuildTypeMap::iterator i = obj.build_types.insert(BuildTypeMap::value_type(n, btype)).first;
+ auto i = obj.build_types.insert({ n, btype }).first;
if(!obj.build_type)
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());
- if(options)
- load_sub(*pkg, *options);
- else
- load_sub(*pkg);
+ load_sub(*pkg, options);
if(obj.build_type)
pkg->set_build_type(*obj.build_type);