From adb36bf3e11ddadc39dc1e308298cb38e5d0b22c Mon Sep 17 00:00:00 2001 From: Jason Perkins Date: Tue, 28 Feb 2012 17:14:28 -0500 Subject: [PATCH] Fixed SNC linking to static library projects --- src/tools/snc.lua | 11 ++--------- tests/tools/test_snc.lua | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/tools/snc.lua b/src/tools/snc.lua index c057e425..17ec2a5b 100644 --- a/src/tools/snc.lua +++ b/src/tools/snc.lua @@ -81,17 +81,10 @@ -- --- Return the list of libraries to link, formatted for the linker command line. +-- The linking behavior is the same as GCC. -- - function snc.getlinks(cfg) - local result = {} - local links = config.getlinks(cfg, "all", "basename") - for _, link in ipairs(links) do - table.insert(result, "-l" .. link) - end - return result - end + snc.getlinks = premake.tools.gcc.getlinks diff --git a/tests/tools/test_snc.lua b/tests/tools/test_snc.lua index 5369f0e5..d87b27bd 100644 --- a/tests/tools/test_snc.lua +++ b/tests/tools/test_snc.lua @@ -76,4 +76,21 @@ prepare() test.isequal({ "-lfs_stub", "-lnet_stub" }, snc.getlinks(cfg)) end + + +-- +-- When linking to a static sibling library, the relative path to the library +-- should be used instead of the "-l" flag. This prevents linking against a +-- shared library of the same name, should one be present. +-- + + function suite.links_onStaticSiblingLibrary() + links { "MyProject2" } + test.createproject(sln) + kind "StaticLib" + location "MyProject2" + targetdir "lib" + prepare() + test.isequal({ "lib/libMyProject2.a" }, snc.getlinks(cfg)) + end \ No newline at end of file