]> git.tdb.fi Git - builder.git/commitdiff
Make static library dependencies consistent with what the linker does
authorMikko Rasa <tdb@tdb.fi>
Thu, 17 Jan 2013 08:54:54 +0000 (10:54 +0200)
committerMikko Rasa <tdb@tdb.fi>
Thu, 17 Jan 2013 08:54:54 +0000 (10:54 +0200)
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
source/gnulinker.cpp

index 5856c19e539bde29901e7d7ba0fdfcf1247e2077..05a475d71bb4b02ff82c8333f06cc1c976f6d40e 100644 (file)
@@ -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<StaticLibrary *>(lib))
+                               Target *real = lib->get_real_target();
+                               if(StaticLibrary *stlib = dynamic_cast<StaticLibrary *>(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));
index ede0119aeb44dec627cd37d39e14e15ad108420f..7088dfb866ce9fe55be1e51024f3cc2aae9db0ba 100644 (file)
@@ -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<FileTarget *>(*i);
                Target *tgt = (*i)->get_real_target();
 
                if(ObjectFile *obj = dynamic_cast<ObjectFile *>(tgt))
                        argv.push_back(relative(obj->get_path(), work_dir).str());
                else if(StaticLibrary *stlib = dynamic_cast<StaticLibrary *>(tgt))
-                       argv.push_back(stlib->get_path().str());
+                       argv.push_back((file?file:stlib)->get_path().str());
                else if(SharedLibrary *shlib = dynamic_cast<SharedLibrary *>(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;
                }
        }