X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fobjectfile.cpp;h=1e6cb232135ca489aeeacd2045d86168394b0098;hb=bf0883b6dd3946612922aa1b7c04a87d06442df7;hp=cee8c87d2d6078b90210aa81615d48bd0db0aaf9;hpb=07503a34b80778fe74977f0fb0c2094c92d64ce0;p=builder.git diff --git a/source/objectfile.cpp b/source/objectfile.cpp index cee8c87..1e6cb23 100644 --- a/source/objectfile.cpp +++ b/source/objectfile.cpp @@ -11,7 +11,8 @@ using namespace Msp; ObjectFile::ObjectFile(Builder &b, const Component &c, SourceFile &s): FileTarget(b, c.get_package(), generate_target_path(c, s.get_path())), - source(s) + source(s), + used_in_shlib(false) { component = &c; add_dependency(source); @@ -20,7 +21,12 @@ 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 rel_src = FS::relative(src, pkg.get_source_directory()).str(); + FS::Path temp_dir = pkg.get_temp_directory()/comp.get_name(); + 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) { @@ -29,7 +35,19 @@ FS::Path ObjectFile::generate_target_path(const Component &comp, const FS::Path if(*i!=".") fn += *i; } - return pkg.get_temp_directory()/comp.get_name()/(FS::basepart(fn)+".o"); + const Architecture &arch = comp.get_package().get_builder().get_current_arch(); + return temp_dir/arch.create_filename(FS::basepart(fn)); +} + +void ObjectFile::set_used_in_shared_library(bool u) +{ + used_in_shlib = u; +} + +void ObjectFile::collect_build_info(BuildInfo &binfo) const +{ + Target::collect_build_info(binfo); + binfo.update_from(component->get_build_info_for_path(source.get_path())); } void ObjectFile::find_dependencies() @@ -44,7 +62,7 @@ void ObjectFile::find_dependencies() void ObjectFile::find_dependencies(FileTarget *tgt) { FileTarget *rtgt = dynamic_cast(tgt->get_real_target()); - const Dependencies &tdeps = rtgt->get_dependencies(); + const Dependencies &tdeps = rtgt->get_transitive_dependencies(); Dependencies deps_to_add; if(rtgt==tgt) { @@ -54,6 +72,7 @@ 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(); @@ -62,12 +81,13 @@ void ObjectFile::find_dependencies(FileTarget *tgt) FileTarget *file = dynamic_cast(*i); 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) @@ -86,5 +106,9 @@ void ObjectFile::find_dependencies(FileTarget *tgt) for(Dependencies::const_iterator i=deps_to_add.begin(); i!=deps_to_add.end(); ++i) if(find(depends.begin(), depends.end(), *i)==depends.end()) + { add_dependency(**i); + if((*i)->get_real_target()->is_buildable()) + (*i)->signal_modified.connect(sigc::mem_fun(this, static_cast(&ObjectFile::find_dependencies))); + } }