summaryrefslogtreecommitdiff
path: root/xmake/scripts/base/linker.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2015-06-07 16:18:45 +0800
committerruki <[email protected]>2015-06-07 16:18:45 +0800
commitf254d7f88fbbb159593cdfbadffe98498b14870c (patch)
tree0b589224a02ca43f9851d110b206aee6b94f345e /xmake/scripts/base/linker.lua
parent70aafd951297294b4f6e8e3ec8ee5058461fa59a (diff)
add symbols, language, strip and vectorexts
Diffstat (limited to 'xmake/scripts/base/linker.lua')
-rw-r--r--xmake/scripts/base/linker.lua29
1 files changed, 27 insertions, 2 deletions
diff --git a/xmake/scripts/base/linker.lua b/xmake/scripts/base/linker.lua
index 5cf83964c..9d23c9d38 100644
--- a/xmake/scripts/base/linker.lua
+++ b/xmake/scripts/base/linker.lua
@@ -44,8 +44,9 @@ function linker._mapflag(module, flag)
-- find and replace it using pattern
for k, v in pairs(module.mapflags) do
- if flag:find(k) then
- return flag:gsub(k, v)
+ local flag_mapped, count = flag:gsub(k, v)
+ if flag_mapped and count ~= 0 then
+ return utils.ifelse(#flag_mapped ~= 0, flag_mapped, nil)
end
end
@@ -81,6 +82,25 @@ function linker._mapflags(module, flags)
return flags_mapped
end
+-- get the linker flags from names
+function linker._getflags(module, names, flags)
+
+ -- check
+ assert(flags)
+
+ -- the mapped flags
+ local flags_mapped = {}
+
+ -- wrap it first
+ names = utils.wrap(names)
+ for _, name in ipairs(names) do
+ table.join2(flags_mapped, linker._mapflags(module, flags[name]))
+ end
+
+ -- get it
+ return flags_mapped
+end
+
-- make the link command
function linker.make(module, target, objfiles, targetfile)
@@ -127,6 +147,11 @@ function linker.make(module, target, objfiles, targetfile)
-- append the flags from the configure
table.join2(flags, linker._mapflags(module, config.get(flag_name)))
+ -- append the strip flags from the current project
+ table.join2(flags, linker._getflags(module, target.strip, { debug = "-S"
+ , all = "-s"
+ }))
+
-- make the link command
return module.command_link(table.concat(objfiles, " "), targetfile, table.concat(flags, " "):trim())
end