From 3f1f24c02c5ef21791e5b24ff535d59969cd7625 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Thu, 17 Jan 2013 10:54:54 +0200 Subject: [PATCH] Make static library dependencies consistent with what the linker does Rather than the linker using non-installed paths for static libraries, the binary target now does this when resolving dependencies. This avoids installing static libraries unnecessarily. --- source/binary.cpp | 11 +++++++---- source/gnulinker.cpp | 5 +++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/source/binary.cpp b/source/binary.cpp index 5856c19..05a475d 100644 --- a/source/binary.cpp +++ b/source/binary.cpp @@ -46,12 +46,15 @@ void Binary::find_dependencies() Target *lib = builder.get_vfs().find_library(*i, binfo.libpath, libmode); if(lib) { - dep_libs.push_back(lib); - - lib = lib->get_real_target(); - if(StaticLibrary *stlib = dynamic_cast(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); } else builder.problem(package->get_name(), format("Couldn't find library %s for %s", *i, name)); diff --git a/source/gnulinker.cpp b/source/gnulinker.cpp index ede0119..7088dfb 100644 --- a/source/gnulinker.cpp +++ b/source/gnulinker.cpp @@ -197,12 +197,13 @@ Task *GnuLinker::Linker::run(const Target &target) const const Target::Dependencies &depends = target.get_dependencies(); for(Target::Dependencies::const_iterator i=depends.begin(); i!=depends.end(); ++i) { + FileTarget *file = dynamic_cast(*i); Target *tgt = (*i)->get_real_target(); if(ObjectFile *obj = dynamic_cast(tgt)) argv.push_back(relative(obj->get_path(), work_dir).str()); else if(StaticLibrary *stlib = dynamic_cast(tgt)) - argv.push_back(stlib->get_path().str()); + argv.push_back((file?file:stlib)->get_path().str()); else if(SharedLibrary *shlib = dynamic_cast(tgt)) { argv.push_back("-l"+shlib->get_libname()); @@ -214,7 +215,7 @@ Task *GnuLinker::Linker::run(const Target &target) const if(shlib) argv.push_back("-l"+shlib->get_libname()); else - argv.push_back(imp->get_path().str()); + argv.push_back((file?file:imp)->get_path().str()); static_link_ok = false; } } -- 2.45.2