summaryrefslogtreecommitdiff
path: root/xmake/scripts/base/linker.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2015-06-05 16:06:45 +0800
committerruki <[email protected]>2015-06-05 16:06:45 +0800
commit411e3138ec53ab99c73f0124ef93ac98d746cdc9 (patch)
treed7e719ea57e12402f630deb1ed998a00304510ff /xmake/scripts/base/linker.lua
parentfe68854c321f2e586cab55dce6856b89241b4c20 (diff)
join flags for compiler and linker
Diffstat (limited to 'xmake/scripts/base/linker.lua')
-rw-r--r--xmake/scripts/base/linker.lua23
1 files changed, 8 insertions, 15 deletions
diff --git a/xmake/scripts/base/linker.lua b/xmake/scripts/base/linker.lua
index 2516bbd29..6f3e7c972 100644
--- a/xmake/scripts/base/linker.lua
+++ b/xmake/scripts/base/linker.lua
@@ -25,6 +25,7 @@ local linker = linker or {}
-- load modules
local utils = require("base/utils")
+local table = require("base/table")
local string = require("base/string")
local config = require("base/config")
local tools = require("tools/tools")
@@ -75,17 +76,17 @@ function linker.make(module, target, objfiles, targetfile)
end
-- get the common flags from the current linker
- local flags_common = module[flag_name] or ""
+ local flags = {}
+ table.join2(flags, module[flag_name])
-- get the target flags from the current project
- local flags_target = table.concat(linker._mapflags(module, utils.wrap(target[flag_name])), " ")
- assert(flags_target)
+ table.join2(flags, linker._mapflags(module, utils.wrap(target[flag_name])))
-- get the linkdirs flags from the current project
if module._make_linkdir then
local linkdirs = utils.wrap(target.linkdirs)
for _, linkdir in ipairs(linkdirs) do
- flags_target = flags_target:append(module.flag_linkdir(linkdir), " ")
+ table.join2(flags, module.flag_linkdir(linkdir))
end
end
@@ -93,23 +94,15 @@ function linker.make(module, target, objfiles, targetfile)
if module._make_link then
local links = utils.wrap(target.links)
for _, link in ipairs(links) do
- flags_target = flags_target:append(module.flag_link(link), " ")
+ table.join2(flags, module.flag_link(link))
end
end
-- get the config flags
- local flags_config = table.concat(linker._mapflags(module, utils.wrap(config.get(flag_name))), " ")
- assert(flags_config)
-
- -- make the flags string
- local flags = ""
- flags = flags:append(flags_common, " ")
- flags = flags:append(flags_target, " ")
- flags = flags:append(flags_config, " ")
- flags = flags:trim()
+ table.join2(flags, linker._mapflags(module, utils.wrap(config.get(flag_name))))
-- make the link command
- return module.command_link(table.concat(objfiles, " "), targetfile, flags)
+ return module.command_link(table.concat(objfiles, " "), targetfile, table.concat(flags, " "):trim())
end
-- get the linker from the given kind