using namespace std;
using namespace Msp;
-BinaryComponent::BinaryComponent(SourcePackage &p, const string &n, Type t):
- Component(p, n),
- type(t)
-{ }
-
void BinaryComponent::create_build_info()
{
Component::create_build_info();
- for(UseList::const_iterator i=uses.begin(); i!=uses.end(); ++i)
+ for(const Component *u: uses)
{
/* Select an include path that contains all the sources for this and the
used component. This should produce a sensible result in most cases. */
FS::Path base;
- for(SourceList::const_iterator j=sources.begin(); j!=sources.end(); ++j)
- base = base.empty() ? *j : FS::common_ancestor(base, *j);
- const SourceList &use_sources = (*i)->get_sources();
- for(SourceList::const_iterator j=use_sources.begin(); j!=use_sources.end(); ++j)
- base = FS::common_ancestor(base, *j);
+ for(const FS::Path &s: sources)
+ base = base.empty() ? s : FS::common_ancestor(base, s);
+ for(const FS::Path &s: u->get_sources())
+ base = FS::common_ancestor(base, s);
build_info.incpath.push_back(base);
- build_info.libs.push_back((*i)->get_name());
- if(!(*i)->get_install())
+ build_info.libs.push_back(u->get_name());
+ if(!u->get_install())
{
- build_info.libmodes[(*i)->get_name()] = BuildInfo::STATIC;
- build_info.libpath.push_back((*i)->get_package().get_output_directory());
+ build_info.libmodes[u->get_name()] = BuildInfo::STATIC;
+ build_info.libpath.push_back(u->get_package().get_output_directory());
}
}
const Toolchain &toolchain = builder.get_toolchain();
const Toolchain &pkg_tools = package.get_toolchain();
- list<Target *> objs;
- SourceList source_filenames = collect_source_files();
- for(SourceList::const_iterator i=source_filenames.begin(); i!=source_filenames.end(); ++i)
+ vector<Target *> objs;
+ vector<FS::Path> source_filenames = collect_source_files();
+ objs.reserve(source_filenames.size());
+ for(auto i=source_filenames.begin(); i!=source_filenames.end(); ++i)
{
string ext = FS::extpart(FS::basename(*i));
Target *src = 0;
Tool *gen = pkg_tools.get_tool_for_suffix(ext);
if(gen)
{
- list<Target *> templates;
+ vector<Target *> templates;
templates.push_back(gen->create_source(*this, *i));
Tool::ProcessingUnit processing_unit = gen->get_processing_unit();
if(processing_unit!=Tool::ONE_FILE)
{
FS::Path source_dir = FS::dirname(*i);
- SourceList::const_iterator j = i;
- for(++j; j!=source_filenames.end(); )
+ for(auto j=next(i); j!=source_filenames.end(); )
{
if((processing_unit!=Tool::DIRECTORY || FS::dirname(*j)==source_dir) &&
pkg_tools.get_tool_for_suffix(FS::extpart(FS::basename(*j)))==gen)
{
templates.push_back(gen->create_source(*this, *j));
// Remove additional files so they won't get processed again
- source_filenames.erase(j++);
+ j = source_filenames.erase(j);
}
else
++j;
if(dynamic_cast<FileTarget *>(src)->is_installable())
build_graph.add_installed_target(*src);
- const Target::Dependencies &side_effects = src->get_side_effects();
- for(Target::Dependencies::const_iterator j=side_effects.begin(); j!=side_effects.end(); ++j)
- if(dynamic_cast<FileTarget *>(*j)->is_installable())
- build_graph.add_installed_target(**j);
+ for(Target *s: src->get_side_effects())
+ if(dynamic_cast<FileTarget *>(s)->is_installable())
+ build_graph.add_installed_target(*s);
}
}
}
Tool &linker = toolchain.get_tool("LINK");
- list<Target *> results;
+ vector<Target *> results;
+ results.reserve(2);
if(type==LIBRARY)
{
Tool &archiver = toolchain.get_tool("AR");
else
results.push_back(linker.create_target(objs));
- for(list<Target *>::const_iterator i=results.begin(); i!=results.end(); ++i)
+ for(Target *r: results)
{
- build_graph.add_primary_target(**i);
+ build_graph.add_primary_target(*r);
if(install)
- build_graph.add_installed_target(**i);
+ build_graph.add_installed_target(*r);
}
}