diff options
author | Jason Perkins <starkos@industriousone.com> | 2011-04-11 22:33:49 +0400 |
---|---|---|
committer | Jason Perkins <starkos@industriousone.com> | 2011-04-11 22:33:49 +0400 |
commit | e650d20fc6b8ef0911b77b70498900c2149d10bf (patch) | |
tree | 4b49c4466ecabfeaf2929e6b5934f57e7bbfbf5b | |
parent | c0fa50f0a8cc256140b03f5ddad05a90f9fa2abb (diff) | |
parent | b5fb32446ca74fdef8b119a7235da821ca3adab8 (diff) |
Merged changes from stable
-rw-r--r-- | CHANGES.txt | 3 | ||||
-rw-r--r-- | src/tools/gcc.lua | 20 | ||||
-rw-r--r-- | tests/actions/make/test_make_linking.lua | 96 | ||||
-rw-r--r-- | tests/premake4.lua | 1 |
4 files changed, 119 insertions, 1 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index e0a1f41..a4fa841 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -23,6 +23,9 @@ * 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 +* 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) + ------- 4.3 diff --git a/src/tools/gcc.lua b/src/tools/gcc.lua index 7adb9a0..c55fcb0 100644 --- a/src/tools/gcc.lua +++ b/src/tools/gcc.lua @@ -184,7 +184,25 @@ function premake.gcc.getlinkflags(cfg) local result = { } - for _, value in ipairs(premake.getlinks(cfg, "all", "basename")) do + + 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) + else + --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 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..5404bc1 --- /dev/null +++ b/tests/actions/make/test_make_linking.lua @@ -0,0 +1,96 @@ + + T.gcc_linking = { } + local suite = T.gcc_linking + + local staticPrj + local linksToStaticProj + local sln + + 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 + sln = nil + end + + local get_buffer = function(projectName) + io.capture() + premake.buildconfigs() + 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(linksToStaticProj) + local format_exspected = 'LIBS %+%= bar/libstaticPrj.a' + test.string_contains(buffer,format_exspected) + end + + T.link_suite= { } + local firstProject = nil + local linksToFirstProject = nil + + function T.link_suite.setup() + _ACTION = "gmake" + solution('dontCareSolution') + 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' + + linksToFirstProject = project 'linksToFirstProject' + kind 'ConsoleApp' + language 'C' + 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' + + 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 + + diff --git a/tests/premake4.lua b/tests/premake4.lua index 09c7b65..60d51e0 100644 --- a/tests/premake4.lua +++ b/tests/premake4.lua @@ -94,6 +94,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") |