diff options
| author | ruki <[email protected]> | 2024-05-30 11:08:16 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-05-30 11:08:16 +0800 |
| commit | e13085ea9f4e9f45cb1a96555921ffce0076b4a3 (patch) | |
| tree | 2f07c54cc1c078ab00cfde1a47c978e2ab6b4df8 /xmake/core/tool/builder.lua | |
| parent | 02ea6962aeabced2117938181db5e8f48185cb05 (diff) | |
| parent | 6e957e6a5ac524d86d2b300b8c4249c07608c7ce (diff) | |
Merge pull request #5169 from xmake-io/mapflags
Improve mapflags
Diffstat (limited to 'xmake/core/tool/builder.lua')
| -rw-r--r-- | xmake/core/tool/builder.lua | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/xmake/core/tool/builder.lua b/xmake/core/tool/builder.lua index 4ef3e8576..92a17b68b 100644 --- a/xmake/core/tool/builder.lua +++ b/xmake/core/tool/builder.lua @@ -773,12 +773,32 @@ end function builder:map_flags(name, values, opt) local flags = {} local mapper = self:_tool()["nf_" .. name] + local multival = false + if name:endswith("s") then + multival = true + elseif not mapper then + mapper = self:_tool()["nf_" .. name .. "s"] + if mapper then + multival = true + end + end if mapper then opt = opt or {} - for _, value in ipairs(table.wrap(values)) do - local flag = mapper(self:_tool(), value, opt.target, opt.targetkind) - if flag and flag ~= "" and (not opt.check or self:has_flags(flag)) then - table.join2(flags, flag) + if multival then + local extra = self:_extraconf(opt.extras, values) + local results = mapper(self:_tool(), values, {target = opt.target, targetkind = opt.targetkind, extra = extra}) + for _, flag in ipairs(table.wrap(results)) do + if flag and flag ~= "" and (not opt.check or self:has_flags(flag)) then + table.insert(flags, flag) + end + end + else + for _, value in ipairs(table.wrap(values)) do + local extra = self:_extraconf(opt.extras, value) + local flag = mapper(self:_tool(), value, {target = opt.target, targetkind = opt.targetkind, extra = extra}) + if flag and flag ~= "" and (not opt.check or self:has_flags(flag)) then + table.join2(flags, flag) + end end end end |
