feature + tests
This commit is contained in:
parent
99bf0bc8cd
commit
82473183a5
@ -297,7 +297,6 @@
|
||||
end
|
||||
|
||||
-- The "-l" flag is fine for system libraries
|
||||
|
||||
local links = config.getlinks(cfg, "system", "fullpath")
|
||||
for _, link in ipairs(links) do
|
||||
if path.isframework(link) then
|
||||
@ -305,7 +304,20 @@
|
||||
elseif path.isobjectfile(link) then
|
||||
table.insert(result, link)
|
||||
else
|
||||
table.insert(result, "-l" .. path.getname(link))
|
||||
local endswith = function(s, ptrn)
|
||||
return ptrn == string.sub(s, -string.len(ptrn))
|
||||
end
|
||||
local name = path.getname(link)
|
||||
-- Check link mode preference and set flags for linker accordingly
|
||||
if endswith(name, ":static") then
|
||||
name = string.sub(name, 0, -8)
|
||||
table.insert(result, "-Wl,-Bstatic -l" .. name .. " -Wl,-Bdynamic")
|
||||
elseif endswith(name, ":shared") then
|
||||
name = string.sub(name, 0, -8)
|
||||
table.insert(result, "-Wl,-Bdynamic -l" .. name)
|
||||
else
|
||||
table.insert(result, "-l" .. name)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -360,4 +372,3 @@
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
|
@ -510,3 +510,25 @@
|
||||
prepare()
|
||||
test.contains("-flto", gcc.getldflags(cfg))
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Check link mode preference for system libraries.
|
||||
--
|
||||
function suite.linksModePreference_onAllStatic()
|
||||
links { "fs_stub:static", "net_stub:static" }
|
||||
prepare()
|
||||
test.contains({ "-Wl,-Bstatic -lfs_stub -Wl,-Bdynamic", "-Wl,-Bstatic -lnet_stub -Wl,-Bdynamic" }, gcc.getlinks(cfg))
|
||||
end
|
||||
|
||||
function suite.linksModePreference_onStaticThenShared()
|
||||
links { "fs_stub:static", "net_stub" }
|
||||
prepare()
|
||||
test.contains({ "-Wl,-Bstatic -lfs_stub -Wl,-Bdynamic", "-lnet_stub" }, gcc.getlinks(cfg))
|
||||
end
|
||||
|
||||
function suite.linksModePreference_onSharedThenStatic()
|
||||
links { "fs_stub:shared", "net_stub:static" }
|
||||
prepare()
|
||||
test.contains({ "-Wl,-Bdynamic -lfs_stub", "-Wl,-Bstatic -lnet_stub -Wl,-Bdynamic" }, gcc.getlinks(cfg))
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user