* Patch 3043933 gmake incorrectly links using -l when a solution contains a .so and .a of the same name and the static lib is wanted (Jonathan Derque)

This commit is contained in:
Liam Devine 2011-03-26 00:21:44 +00:00
parent ed13aaeacf
commit 26db36c266
4 changed files with 62 additions and 1 deletions

View File

@ -10,6 +10,7 @@
* Bug 3138377: Link dependencies ignored within "SharedLib" configuration
* Bug 3163703: pdb file being set in the wrong section. (hodsondd)
* Bug 3157645: Full path for xcode frameworks
* Patch 3043933 gmake incorrectly links using -l when a solution contains a .so and .a of the same name and the static lib is wanted (Jonathan Derque)
-------
4.3

View File

@ -174,7 +174,23 @@
function premake.gcc.getlinkflags(cfg)
local result = { }
for _, value in ipairs(premake.getlinks(cfg, "all", "basename")) do
for _, value in ipairs(premake.getlinks(cfg, "dependencies", "object")) do
-- don't use "-llib" arguments when linking static libraries
if (value.kind == "StaticLib") then
local pathstyle = premake.getpathstyle(value)
local namestyle = premake.getnamestyle(value)
local linktarget = premake.gettarget(value, "link", pathstyle, namestyle, cfg.system)
table.insert(result, linktarget.fullpath)
else
if path.getextension(value.basename) == ".framework" then
table.insert(result, '-framework ' .. _MAKE.esc(path.getbasename(value.basename)))
else
table.insert(result, '-l' .. _MAKE.esc(value.basename))
end
end
end
-- "-llib" is fine for system dependencies
for _, value in ipairs(premake.getlinks(cfg, "system", "basename")) do
if path.getextension(value) == ".framework" then
table.insert(result, '-framework ' .. _MAKE.esc(path.getbasename(value)))
else

View File

@ -0,0 +1,43 @@
T.gcc_linking = { }
local suite = T.gcc_linking
local staticPrj
local linksToStaticProj
function suite.setup()
_ACTION = "gmake"
sln = solution "MySolution"
configurations { "Debug" }
platforms {}
staticPrj = project "staticPrj"
targetdir 'bar'
language 'C++'
kind "StaticLib"
linksToStaticProj = project "linksToStaticProj"
language 'C++'
kind 'ConsoleApp'
links{'staticPrj'}
end
function suite.teardown()
staticPrj = nil
linksToStaticProj = nil
end
local get_buffer = function()
io.capture()
premake.buildconfigs()
local cfg = premake.getconfig(linksToStaticProj, 'Debug', 'Native')
premake.gmake_cpp_config(cfg, premake.gcc)
local buffer = io.endcapture()
return buffer
end
function suite.ProjectLinksToStaticPremakeMadeLibrary_linksUsingTheFormat_pathNameExtension()
local buffer = get_buffer()
local format_exspected = 'LIBS %+%= bar/libstaticPrj.a'
test.string_contains(buffer,format_exspected)
end

View File

@ -77,6 +77,7 @@
-- Makefile tests
dofile("actions/make/test_make_escaping.lua")
dofile("actions/make/test_make_pch.lua")
dofile("actions/make/test_make_linking.lua")
-- Xcode tests
dofile("actions/xcode/test_xcode_common.lua")