X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fbinarycomponent.cpp;h=3209ccc185438f721d0892053564724c17fb87fa;hb=451ef4f33b5a57dcb56bd7cb671bed359ac86247;hp=49c4897ce69d7d25492ebe1521257dca04c77062;hpb=54d0a3516164312bf9d04f455e2aad2af225aa51;p=builder.git diff --git a/source/binarycomponent.cpp b/source/binarycomponent.cpp index 49c4897..3209ccc 100644 --- a/source/binarycomponent.cpp +++ b/source/binarycomponent.cpp @@ -8,31 +8,25 @@ 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()); } } @@ -54,9 +48,10 @@ void BinaryComponent::create_targets() const const Toolchain &toolchain = builder.get_toolchain(); const Toolchain &pkg_tools = package.get_toolchain(); - list objs; - SourceList source_filenames = collect_source_files(); - for(SourceList::iterator i=source_filenames.begin(); i!=source_filenames.end(); ++i) + vector objs; + vector 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; @@ -64,22 +59,21 @@ void BinaryComponent::create_targets() const Tool *gen = pkg_tools.get_tool_for_suffix(ext); if(gen) { - list templates; + vector 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::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; @@ -109,17 +103,17 @@ void BinaryComponent::create_targets() const if(dynamic_cast(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(*j)->is_installable()) - build_graph.add_installed_target(**j); + for(Target *s: src->get_side_effects()) + if(dynamic_cast(s)->is_installable()) + build_graph.add_installed_target(*s); } } } Tool &linker = toolchain.get_tool("LINK"); - list results; + vector results; + results.reserve(2); if(type==LIBRARY) { Tool &archiver = toolchain.get_tool("AR"); @@ -131,11 +125,11 @@ void BinaryComponent::create_targets() const else results.push_back(linker.create_target(objs)); - for(list::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); } }