Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions modules/vstudio/tests/vc2010/test_link.lua
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,55 @@
end


--
-- When using a non-MSC toolset (e.g. clang or gcc), links with native
-- extensions (.a, .so) should be passed through as-is without .lib appended.
--

function suite.additionalDependencies_dotA_onClangToolset()
toolset "clang"
links { "mylib.a" }
prepare()
test.capture [[
<Link>
<SubSystem>Windows</SubSystem>
<AdditionalDependencies>mylib.a;%(AdditionalDependencies)</AdditionalDependencies>
]]
end

function suite.additionalDependencies_dotSo_onClangToolset()
toolset "clang"
links { "mylib.so" }
prepare()
test.capture [[
<Link>
<SubSystem>Windows</SubSystem>
<AdditionalDependencies>mylib.so;%(AdditionalDependencies)</AdditionalDependencies>
]]
end

function suite.additionalDependencies_dotA_onGccToolset()
toolset "gcc"
links { "mylib.a" }
prepare()
test.capture [[
<Link>
<SubSystem>Windows</SubSystem>
<AdditionalDependencies>mylib.a;%(AdditionalDependencies)</AdditionalDependencies>
]]
end

function suite.additionalDependencies_dotSo_onGccToolset()
toolset "gcc"
links { "mylib.so" }
prepare()
test.capture [[
<Link>
<SubSystem>Windows</SubSystem>
<AdditionalDependencies>mylib.so;%(AdditionalDependencies)</AdditionalDependencies>
]]
end

--
-- Additional library directories should be specified, relative to the project.
--
Expand Down
7 changes: 7 additions & 0 deletions src/tools/clang.lua
Original file line number Diff line number Diff line change
Expand Up @@ -402,3 +402,10 @@
function clang.gettooloutputext(tool)
return gcc.gettooloutputext(tool)
end

function clang.getLibraryExtensions()
return {
["a"] = true,
["so"] = true,
}
end
7 changes: 7 additions & 0 deletions src/tools/gcc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -824,3 +824,10 @@
function gcc.gettooloutputext(tool)
return iif(tool == "rc", ".res", ".o")
end

function gcc.getLibraryExtensions()
return {
["a"] = true,
["so"] = true,
}
end
7 changes: 6 additions & 1 deletion src/tools/msc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -483,10 +483,15 @@

-- Then the system libraries, which come undecorated
local system = config.getlinks(cfg, "system", "fullpath")

local toolset = config.toolset(cfg)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After sleeping on this and discussion with @samsinsane, we think it may make more sense to move the logic from msc.lua to the VS project generation file. This here is a bit smelly, since we are already in a toolset file.

Right now, VS is pretty hard coded to msc-isms. This may be a case where we want to be more agnostic in the VS exporter itself, loading in the specified toolset rather than just using MSC.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, worth investigating. I'll put this on pause until I get access to the specific platform that requires this change on our side to validate this approach.

local toolsetExts = toolset and toolset.getLibraryExtensions and toolset.getLibraryExtensions() or {}
local libExts = table.merge(p.tools.msc.getLibraryExtensions(), toolsetExts)

for i = 1, #system do
-- Add extension if required
local link = system[i]
if not p.tools.msc.getLibraryExtensions()[link:match("[^.]+$")] then
if not libExts[link:match("[^.]+$")] then
link = path.appendextension(link, ".lib")
end

Expand Down
Loading