X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fbinarycomponent.cpp;h=608ed3f6596b51b13522333358f2214cf6f093c1;hb=aa053d637e8259755af7d2e4b510a242f4d29c7b;hp=0d3e253b3d5d4afc8714fe8e16eff45724ab348c;hpb=35f2979869bff43706f3163ec0979c7084aaa3c4;p=builder.git diff --git a/source/binarycomponent.cpp b/source/binarycomponent.cpp index 0d3e253..608ed3f 100644 --- a/source/binarycomponent.cpp +++ b/source/binarycomponent.cpp @@ -17,22 +17,21 @@ 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_source_directory()); + build_info.libmodes[u->get_name()] = BuildInfo::STATIC; + build_info.libpath.push_back(u->get_package().get_output_directory()); } } @@ -54,9 +53,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::const_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,12 +64,29 @@ void BinaryComponent::create_targets() const Tool *gen = pkg_tools.get_tool_for_suffix(ext); if(gen) { - Target *tmpl = gen->create_source(*this, *i); - if(tmpl) + vector templates; + templates.push_back(gen->create_source(*this, *i)); + + Tool::ProcessingUnit processing_unit = gen->get_processing_unit(); + if(processing_unit!=Tool::ONE_FILE) { - src = gen->create_target(*tmpl); - ext = FS::extpart(FS::basename(dynamic_cast(*src).get_path())); + FS::Path source_dir = FS::dirname(*i); + 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 + j = source_filenames.erase(j); + } + else + ++j; + } } + + src = gen->create_target(templates); + ext = FS::extpart(FS::basename(dynamic_cast(*src).get_path())); } Tool *tool = toolchain.get_tool_for_suffix(ext, true); @@ -91,17 +108,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"); @@ -113,16 +130,16 @@ 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); } } BinaryComponent::Loader::Loader(BinaryComponent &c): - DerivedObjectLoader(c) + DataFile::DerivedObjectLoader(c) { add("use", &Loader::use); }