summaryrefslogtreecommitdiff
path: root/xmake/core/tool/linker.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2017-08-10 09:05:03 +0800
committerruki <[email protected]>2017-08-10 09:05:03 +0800
commit3a1d05fd170148a6ae6342bda2e077431bb7570a (patch)
treed1b16fde057219e6934e45d0c103db75ee695f88 /xmake/core/tool/linker.lua
parent467e97b99dc9b16dd3db3a5ad743ea954185d497 (diff)
improve add_files and compile speed
Diffstat (limited to 'xmake/core/tool/linker.lua')
-rw-r--r--xmake/core/tool/linker.lua37
1 files changed, 9 insertions, 28 deletions
diff --git a/xmake/core/tool/linker.lua b/xmake/core/tool/linker.lua
index c9c21f262..118fbd4e3 100644
--- a/xmake/core/tool/linker.lua
+++ b/xmake/core/tool/linker.lua
@@ -179,12 +179,13 @@ end
-- link the target file
function linker:link(objectfiles, targetfile, opt)
- return sandbox.load(self:_tool().link, self:_tool(), table.wrap(objectfiles), self:_targetkind(), targetfile, self:linkflags(opt))
+ opt = opt or {}
+ return sandbox.load(self:_tool().link, self:_tool(), table.wrap(objectfiles), self:_targetkind(), targetfile, opt.linkflags or self:linkflags(opt))
end
-- get the link arguments list
function linker:linkargv(objectfiles, targetfile, opt)
- return self:_tool():linkargv(table.wrap(objectfiles), self:_targetkind(), targetfile, self:linkflags(opt))
+ return self:_tool():linkargv(table.wrap(objectfiles), self:_targetkind(), targetfile, opt.linkflags or self:linkflags(opt))
end
-- get the link command
@@ -195,7 +196,7 @@ end
-- get the link flags
--
-- @param opt the argument options (contain all the linker attributes of target),
--- .e.g {target = ..., targetkind = "static", ldflags = "", links = "", linkdirs = "", ...}
+-- .e.g {target = ..., targetkind = "static", config = {ldflags = "", links = "", linkdirs = "", ...}}
--
function linker:linkflags(opt)
@@ -205,10 +206,6 @@ function linker:linkflags(opt)
-- get target
local target = opt.target
- -- init cache
- self._COMPFLAGS = self._COMPFLAGS or {}
- local cache = self._COMPFLAGS
-
-- get target kind
local targetkind = opt.targetkind
if not targetkind and target then
@@ -219,29 +216,13 @@ function linker:linkflags(opt)
local flags = {}
self:_addflags_from_config(flags)
- -- add flags about target
- if target then
-
- -- get flags from cache first
- local key = tostring(target)
- local targetflags = cache[key]
- if not targetflags then
-
- -- add flags for the target
- targetflags = {}
- self:_addflags_from_target(targetflags, target)
-
- -- add flags (named) from language
- self:_addflags_from_language(targetflags, target)
-
- -- cache it
- cache[key] = targetflags
- end
- table.join2(flags, targetflags)
- end
+ -- add flags for the target
+ self:_addflags_from_target(flags, target)
-- add flags for the argument
- self:_addflags_from_argument(flags, opt)
+ if opt.config then
+ self:_addflags_from_argument(flags, target, opt.config)
+ end
-- add flags from the platform
if target then