X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fbinary.cpp;h=753ddbc391a427aae7c35487ac3395a76d08b512;hb=720daf583decd04b228caeed02d89f60513b93ef;hp=b3b882d314427f6bf8efdd73b50210edd50d1112;hpb=f182274c67f6e22cef57df560d33cd180a72f167;p=builder.git diff --git a/source/binary.cpp b/source/binary.cpp index b3b882d..753ddbc 100644 --- a/source/binary.cpp +++ b/source/binary.cpp @@ -24,6 +24,20 @@ Binary::Binary(Builder &b, const Component &c, const string &p, const list::const_iterator i=objects.begin(); i!=objects.end(); ++i) add_dependency(**i); + + nested_build_sig = true; + arch_in_build_sig = true; +} + +void Binary::collect_build_info(BuildInfo &binfo) const +{ + for(list::const_iterator i=objects.begin(); i!=objects.end(); ++i) + if(const Tool *obj_tool = (*i)->get_tool()) + binfo.update_from(obj_tool->get_build_info()); + + Target::collect_build_info(binfo); + + binfo.update_from(static_binfo); } void Binary::find_dependencies() @@ -31,16 +45,25 @@ void Binary::find_dependencies() if(!component) return; - list queue; + list queue; list dep_libs; set missing_libs; - queue.push_back(component); - while(!queue.empty()) + queue.push_back(this); + for(list::iterator j=queue.begin(); j!=queue.end(); ++j) { - const Component *c = queue.front(); - queue.erase(queue.begin()); + Target *tgt = *j; + + BuildInfo binfo; + tgt->collect_build_info(binfo); + if(tgt!=this) + { + static_binfo.libpath.insert(static_binfo.libpath.end(), binfo.libpath.begin(), binfo.libpath.end()); + static_binfo.keep_symbols.insert(static_binfo.keep_symbols.end(), binfo.keep_symbols.begin(), binfo.keep_symbols.end()); + if(binfo.threads) + static_binfo.threads = true; + } - const BuildInfo &binfo = c->get_build_info(); + list libs_to_process; for(BuildInfo::WordList::const_iterator i=binfo.libs.begin(); i!=binfo.libs.end(); ++i) { if(i->size()>10 && !i->compare(i->size()-10, 10, ".framework")) @@ -49,22 +72,32 @@ void Binary::find_dependencies() BuildInfo::LibraryMode libmode = component->get_build_info().get_libmode_for(*i); Target *lib = builder.get_vfs().find_library(*i, binfo.libpath, libmode); if(lib) - { - Target *real = lib->get_real_target(); - if(StaticLibrary *stlib = dynamic_cast(real)) - { - dep_libs.push_back(stlib); - if(stlib->get_component()) - queue.push_back(stlib->get_component()); - } - else - dep_libs.push_back(lib); - } + libs_to_process.push_back(lib); else if(missing_libs.insert(*i).second) problems.push_back(format("Required library %s not found", *i)); } + + if(tgt!=this) + { + const Target::Dependencies &tdeps = tgt->get_transitive_dependencies(); + libs_to_process.insert(libs_to_process.end(), tdeps.begin(), tdeps.end()); + } + + list::iterator insert_pos = j; + ++insert_pos; + for(list::const_iterator i=libs_to_process.begin(); i!=libs_to_process.end(); ++i) + { + Target *real = (*i)->get_real_target(); + if(StaticLibrary *stlib = dynamic_cast(real)) + queue.insert(insert_pos, stlib); + else + dep_libs.push_back(*i); + } } + queue.pop_front(); + dep_libs.splice(dep_libs.begin(), queue); + /* Add only the last occurrence of each library to the actual dependencies. This ensures that static library ordering is correct. */ for(list::iterator i=dep_libs.begin(); i!=dep_libs.end(); ++i) @@ -76,20 +109,3 @@ void Binary::find_dependencies() add_dependency(**i); } } - -string Binary::create_build_signature() const -{ - set object_tools; - for(list::const_iterator i=objects.begin(); i!=objects.end(); ++i) - object_tools.insert((*i)->get_tool()); - - list sigs; - for(set::const_iterator i=object_tools.begin(); i!=object_tools.end(); ++i) - sigs.push_back((*i)->create_build_signature(component->get_build_info())); - sigs.sort(); - sigs.push_front(tool->create_build_signature(component->get_build_info())); - if(const Architecture *arch = tool->get_architecture()) - sigs.push_front(arch->get_name()); - - return join(sigs.begin(), sigs.end(), ";"); -}