Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/windirstat/premake-4.x-stable.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLiam Devine <dmail00@gmail.com>2011-03-26 03:39:26 +0300
committerLiam Devine <dmail00@gmail.com>2011-03-26 03:39:26 +0300
commitb8d2fd4f2bda9f0511cf5f7323e024e719770661 (patch)
tree193db1b350580f8ab6c0a3388db88c058f1d4b32
parent39c9b7b88e78a7f0d193c4c022d8a46ddc3ac734 (diff)
parent0926bb12c8a8bab752960aef157b42fba5a0556f (diff)
* 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)
-rw-r--r--CHANGES.txt1
-rw-r--r--src/tools/gcc.lua18
-rw-r--r--tests/actions/make/test_make_linking.lua43
-rw-r--r--tests/premake4.lua1
4 files changed, 62 insertions, 1 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index 15b215a..ea4fcbc 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -11,6 +11,7 @@
* Bug 3163703: pdb file being set in the wrong section. (hodsondd)
* Bug 3157645: Full path for xcode frameworks
* Bug 3232160: Environment variables are cut off
+* 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)
-------
diff --git a/src/tools/gcc.lua b/src/tools/gcc.lua
index 1f5fc74..771cd17 100644
--- a/src/tools/gcc.lua
+++ b/src/tools/gcc.lua
@@ -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
diff --git a/tests/actions/make/test_make_linking.lua b/tests/actions/make/test_make_linking.lua
new file mode 100644
index 0000000..dd9b26d
--- /dev/null
+++ b/tests/actions/make/test_make_linking.lua
@@ -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
diff --git a/tests/premake4.lua b/tests/premake4.lua
index 83b35ad..be606ae 100644
--- a/tests/premake4.lua
+++ b/tests/premake4.lua
@@ -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")