X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fobjectfile.cpp;h=256807c1d7930d7db3e1c6e6360d5d6ceb1f26f7;hb=5ccb12706ac217a7f0b07e4c73ca870bb70fabdf;hp=0536755bb26788354d5e147e021f38fe64d0af36;hpb=0f7867524bf87a389ff5d4f9d3290d68a254b693;p=builder.git diff --git a/source/objectfile.cpp b/source/objectfile.cpp index 0536755..256807c 100644 --- a/source/objectfile.cpp +++ b/source/objectfile.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include "builder.h" #include "component.h" @@ -21,21 +21,22 @@ ObjectFile::ObjectFile(Builder &b, const Component &c, SourceFile &s): FS::Path ObjectFile::generate_target_path(const Component &comp, const FS::Path &src) { const SourcePackage &pkg = comp.get_package(); - FS::Path temp_dir = pkg.get_temp_directory()/comp.get_name(); + FS::Path temp_dir = pkg.get_temp_directory(); FS::Path rel_src; if(FS::descendant_depth(src, temp_dir)>=0) rel_src = FS::relative(src, temp_dir); else rel_src = FS::relative(src, pkg.get_source_directory()); string fn; - for(FS::Path::Iterator i=rel_src.begin(); i!=rel_src.end(); ++i) + for(const string &c: rel_src) { if(!fn.empty()) fn += '_'; - if(*i!=".") - fn += *i; + if(c!=".") + fn += c; } - return temp_dir/(FS::basepart(fn)+".o"); + const Architecture &arch = comp.get_package().get_builder().get_current_arch(); + return temp_dir/comp.get_name()/arch.create_filename(FS::basepart(fn)); } void ObjectFile::set_used_in_shared_library(bool u) @@ -51,10 +52,10 @@ void ObjectFile::collect_build_info(BuildInfo &binfo) const void ObjectFile::find_dependencies() { - for(Dependencies::iterator i=depends.begin(); i!=depends.end(); ++i) + for(Target *d: depends) { - (*i)->prepare(); - find_dependencies(dynamic_cast(*i)); + d->prepare(); + find_dependencies(dynamic_cast(d)); } } @@ -71,41 +72,41 @@ void ObjectFile::find_dependencies(FileTarget *tgt) } else { + FS::Path inst_dir = rtgt->get_component()->get_install_map().get_install_location(*rtgt); /* The target has been displaced by installing it. Displace any dependencies that come from the same package as well. */ const SourcePackage *tpkg = rtgt->get_package(); - for(Dependencies::const_iterator i=tdeps.begin(); i!=tdeps.end(); ++i) + for(Target *d: tdeps) { - FileTarget *file = dynamic_cast(*i); + FileTarget *file = dynamic_cast(d); if(file && file->get_package()==tpkg && FS::descendant_depth(file->get_path(), tpkg->get_source_directory())>=0) { - FS::Path displaced = tgt->get_path()/FS::relative(file->get_path(), rtgt->get_path()); + const Component *tcomp = file->get_component(); + FS::Path dep_inst = tcomp->get_install_map().get_install_location(*file); + FS::Path displaced = FS::dirname(tgt->get_path())/FS::relative(dep_inst, inst_dir)/FS::basename(file->get_path()); if(Target *ddep = builder.get_vfs().get_target(displaced)) deps_to_add.push_back(ddep); else { - const Component *tcomp = file->get_component(); - const Component::OverlayList &overlays = tcomp->get_overlays(); string last_dir = FS::basename(FS::dirname(displaced)); - for(Component::OverlayList::const_iterator j=overlays.begin(); j!=overlays.end(); ++j) - if(last_dir==*j) - { - displaced = displaced.subpath(0, displaced.size()-2)/FS::basename(file->get_path()); - if((ddep = builder.get_vfs().get_target(displaced))) - deps_to_add.push_back(ddep); - } + if(any_equals(tcomp->get_overlays(), last_dir)) + { + displaced = displaced.subpath(0, displaced.size()-2)/FS::basename(file->get_path()); + if((ddep = builder.get_vfs().get_target(displaced))) + deps_to_add.push_back(ddep); + } } } else - deps_to_add.push_back(*i); + deps_to_add.push_back(d); } } - for(Dependencies::const_iterator i=deps_to_add.begin(); i!=deps_to_add.end(); ++i) - if(find(depends.begin(), depends.end(), *i)==depends.end()) + for(Target *d: deps_to_add) + if(!any_equals(depends, d)) { - add_dependency(**i); - if((*i)->get_real_target()->is_buildable()) - (*i)->signal_modified.connect(sigc::mem_fun(this, static_cast(&ObjectFile::find_dependencies))); + add_dependency(*d); + if(d->get_real_target()->is_buildable()) + d->signal_modified.connect(sigc::mem_fun(this, static_cast(&ObjectFile::find_dependencies))); } }