Merge pull request #503 from Blizzard/linkgroups-api

https://github.com/premake/premake-core/wiki/linkgroups
This commit is contained in:
Tom van Dijck 2016-06-10 10:42:03 -07:00 committed by GitHub
commit 5b24ad2c94
4 changed files with 38 additions and 8 deletions

View File

@ -709,6 +709,16 @@
tokens = true,
}
api.register {
name = "linkgroups",
scope = "config",
kind = "string",
allowed = {
"Off",
"On",
}
}
api.register {
name = "locale",
scope = "config",

View File

@ -239,11 +239,8 @@
-- A list of libraries to link, decorated for the linker.
--
function clang.getlinks(cfg, systemOnly)
-- Just pass through to GCC for now
return gcc.getlinksonly(cfg, systemOnly)
function clang.getlinks(cfg, systemonly)
return gcc.getlinks(cfg, systemonly)
end

View File

@ -314,10 +314,8 @@
function gcc.getlinks(cfg, systemonly)
-- we don't want libraries to be order dependent.
local result = gcc.getlinksonly(cfg, systemonly)
if #result > 1 then
if (#result > 1) and (cfg.linkgroups == p.ON) then
local res = {}
table.insert(res, '-Wl,--start-group')
table.insertflat(res, result)

View File

@ -178,6 +178,31 @@
prepare { "ldFlags", "libs", "ldDeps" }
test.capture [[
ALL_LDFLAGS += $(LDFLAGS) -s
LIBS += build/bin/Debug/libMyProject2.a build/bin/Debug/libMyProject3.a
LDDEPS += build/bin/Debug/libMyProject2.a build/bin/Debug/libMyProject3.a
]]
end
--
-- Check a linking multiple siblings with link groups enabled.
--
function suite.links_onSiblingStaticLibWithLinkGroups()
links "MyProject2"
links "MyProject3"
linkgroups "On"
test.createproject(wks)
kind "StaticLib"
location "build"
test.createproject(wks)
kind "StaticLib"
location "build"
prepare { "ldFlags", "libs", "ldDeps" }
test.capture [[
ALL_LDFLAGS += $(LDFLAGS) -s
LIBS += -Wl,--start-group build/bin/Debug/libMyProject2.a build/bin/Debug/libMyProject3.a -Wl,--end-group
LDDEPS += build/bin/Debug/libMyProject2.a build/bin/Debug/libMyProject3.a
]]