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

github.com/windirstat/premake-4.x.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLiam Devine <dmail00@gmail.com>2011-03-29 05:27:10 +0400
committerLiam Devine <dmail00@gmail.com>2011-03-29 05:27:10 +0400
commit37432fef37609cf953202def7e0612dbcbb623db (patch)
tree346576205be3abd0daecf8d874bcdadad64a2270
parent5ac9af4c8a8618afcd9978cacf5f2f2aeaf45439 (diff)
gmake correctly links again to SharedLibs and StaticLibs sibling dependencies; yet correctly does not link to a non linkable sibling.
-rw-r--r--src/tools/gcc.lua22
-rw-r--r--tests/actions/make/test_make_linking.lua70
2 files changed, 54 insertions, 38 deletions
diff --git a/src/tools/gcc.lua b/src/tools/gcc.lua
index 79f6758..9713c2e 100644
--- a/src/tools/gcc.lua
+++ b/src/tools/gcc.lua
@@ -174,27 +174,25 @@
function premake.gcc.getlinkflags(cfg)
local result = { }
---[[
- for _, value in ipairs(premake.getlinks(cfg, "dependencies", "object")) do
- -- don't use "-llib" arguments when linking static libraries
+
+ for _, value in ipairs(premake.getlinks(cfg, "siblings", "object")) do
if (value.kind == "StaticLib") then
+ -- don't use "-lname" when linking static libraries
+ -- instead use path/Name.ext so as not to link with a SharedLib of the same name
+ -- if one is present.
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)
- print(pathstyle .. " " .. namestyle .. " " ..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
+ --premake does not support creating frameworks so this is just a SharedLib link
+ --link using -lname
+ table.insert(result, '-l' .. _MAKE.esc(value.linktarget.basename))
end
end
---]]
+
-- "-llib" is fine for system dependencies
- --for _, value in ipairs(premake.getlinks(cfg, "system", "basename")) do
- for _, value in ipairs(premake.getlinks(cfg, "all", "basename")) do
+ 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
index 74acab2..5404bc1 100644
--- a/tests/actions/make/test_make_linking.lua
+++ b/tests/actions/make/test_make_linking.lua
@@ -30,49 +30,67 @@
sln = nil
end
- local get_buffer = function()
+ local get_buffer = function(projectName)
io.capture()
premake.buildconfigs()
- local cfg = premake.getconfig(linksToStaticProj, 'Debug', 'Native')
+ local cfg = premake.getconfig(projectName, '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()
+
+ function suite.projectLinksToStaticPremakeMadeLibrary_linksUsingTheFormat_pathNameExtension()
+ local buffer = get_buffer(linksToStaticProj)
local format_exspected = 'LIBS %+%= bar/libstaticPrj.a'
test.string_contains(buffer,format_exspected)
end
- T.absolute_path_error= { }
- local firstSharedLib = nil
- local linksToFirstSharedLib = nil
- function T.absolute_path_error.setup()
+ T.link_suite= { }
+ local firstProject = nil
+ local linksToFirstProject = nil
+
+ function T.link_suite.setup()
_ACTION = "gmake"
solution('dontCareSolution')
- configurations{'Debug'}
- platforms {}
-
- firstSharedLib = project 'firstSharedLib'
- configuration{'Debug'}
+ configurations{'Debug'}
+ end
+
+ function T.link_suite.tear_down()
+ _ACTION = nil
+ firstProject = nil
+ linksToFirstProject = nil
+ end
+
+ function T.link_suite.projectLinksToSharedPremakeMadeLibrary_linksUsingFormat_dashLName()
+
+ firstProject = project 'firstProject'
kind 'SharedLib'
language 'C'
- --files{'first.c'}
- linksToFirstSharedLib = project 'linksToFirstSharedLib'
- configuration{'Debug'}
- kind 'SharedLib'
+ linksToFirstProject = project 'linksToFirstProject'
+ kind 'ConsoleApp'
language 'C'
- links{'firstSharedLib'}
+ links{'firstProject'}
+
+ local buffer = get_buffer(linksToFirstProject)
+ local format_exspected = 'LIBS %+%= %-lfirstProject'
+ test.string_contains(buffer,format_exspected)
end
+
+ function T.link_suite.projectLinksToPremakeMadeConsoleApp_doesNotLinkToConsoleApp()
+
+ firstProject = project 'firstProject'
+ kind 'ConsoleApp'
+ language 'C'
- function T.absolute_path_error.tear_down()
- firstSharedLib = nil
- linksToFirstSharedLib = nil
+ linksToFirstProject = project 'linksToFirstProject'
+ kind 'ConsoleApp'
+ language 'C'
+ links{'firstProject'}
+
+ local buffer = get_buffer(linksToFirstProject)
+ local format_exspected = 'LIBS %+%=%s+\n'
+ test.string_contains(buffer,format_exspected)
end
- function T.absolute_path_error.setUp_doesNotAssert()
- premake.buildconfigs()
- local cfg = premake.getconfig(linksToFirstSharedLib, 'Debug', 'Native')
- premake.gmake_cpp_config(cfg, premake.gcc)
- end
+