From b5ccf23105b3c18d72b94ffcbd03aa949dada72a Mon Sep 17 00:00:00 2001 From: Sam Surtees Date: Mon, 24 Aug 2015 22:42:37 +1000 Subject: [PATCH] The links API, for visual studio, no longer appends .lib if an extension already exists. Fixes #87 --- src/actions/vstudio/_vstudio.lua | 8 ++++- src/tools/msc.lua | 16 +++++++++- tests/actions/vstudio/vc2010/test_link.lua | 34 ++++++++++++++++++++++ 3 files changed, 56 insertions(+), 2 deletions(-) diff --git a/src/actions/vstudio/_vstudio.lua b/src/actions/vstudio/_vstudio.lua index e48b67ad..1d30967f 100644 --- a/src/actions/vstudio/_vstudio.lua +++ b/src/actions/vstudio/_vstudio.lua @@ -340,7 +340,13 @@ -- Then the system libraries, which come undecorated local system = config.getlinks(cfg, "system", "fullpath") for i = 1, #system do - table.insert(links, path.appendextension(system[i], ".lib")) + -- Add extension if required + local link = system[i] + if not p.tools.msc.getLibraryExtensions()[link:match("[^.]+$")] then + link = path.appendextension(link, ".lib") + end + + table.insert(links, link) end return links diff --git a/src/tools/msc.lua b/src/tools/msc.lua index 73f59adf..482ca362 100644 --- a/src/tools/msc.lua +++ b/src/tools/msc.lua @@ -236,6 +236,17 @@ end +-- +-- Return a list of valid library extensions +-- + + function msc.getLibraryExtensions() + return { + ["lib"] = true, + ["obj"] = true, + } + end + -- -- Return the list of libraries to link, decorated with flags as needed. -- @@ -243,7 +254,10 @@ function msc.getlinks(cfg) local links = config.getlinks(cfg, "system", "fullpath") for i = 1, #links do - links[i] = path.appendextension(links[i], ".lib") + -- Add extension if required + if not msc.getLibraryExtensions()[links[i]:match("[^.]+$")] then + links[i] = path.appendextension(links[i], ".lib") + end end return links end diff --git a/tests/actions/vstudio/vc2010/test_link.lua b/tests/actions/vstudio/vc2010/test_link.lua index ea369fbf..4f9b3768 100644 --- a/tests/actions/vstudio/vc2010/test_link.lua +++ b/tests/actions/vstudio/vc2010/test_link.lua @@ -164,6 +164,40 @@ end +-- +-- Any system libraries specified in links() with valid extensions should +-- be listed with those extensions. +-- + + function suite.additionalDependencies_onSystemLinksExtensions() + links { "lua.obj", "zlib.lib" } + prepare() + test.capture [[ + + Windows + false + lua.obj;zlib.lib;%(AdditionalDependencies) + ]] + end + + +-- +-- Any system libraries specified in links() with multiple dots should +-- only have .lib appended to the end when no valid extension is found +-- + + function suite.additionalDependencies_onSystemLinksExtensionsMultipleDots() + links { "lua.5.3.lib", "lua.5.4" } + prepare() + test.capture [[ + + Windows + false + lua.5.3.lib;lua.5.4.lib;%(AdditionalDependencies) + ]] + end + + -- -- Additional library directories should be specified, relative to the project. --