diff options
Diffstat (limited to 'xmake/scripts/base/linker.lua')
| -rw-r--r-- | xmake/scripts/base/linker.lua | 29 |
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 |
