diff options
| author | ruki <[email protected]> | 2019-08-18 12:37:08 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2019-08-18 12:37:08 +0800 |
| commit | eb6a3e93dae0deaa411f88a06ea9c46d75b501dc (patch) | |
| tree | b8c2e99327599ac565bd80eec6c99f91d5549639 | |
| parent | 870440fe4ff1523e142e0eafae0a38cf3cfe4915 (diff) | |
| parent | bd4181e0321ec9db4dd6b304db51f5cf6566a484 (diff) | |
Merge pull request #534 from OpportunityLiu/dev
fix #533
| -rw-r--r-- | xmake/core/base/table.lua | 26 | ||||
| -rw-r--r-- | xmake/plugins/project/vsxmake/getinfo.lua | 10 |
2 files changed, 31 insertions, 5 deletions
diff --git a/xmake/core/base/table.lua b/xmake/core/base/table.lua index 1f3e79add..c08526c34 100644 --- a/xmake/core/base/table.lua +++ b/xmake/core/base/table.lua @@ -309,5 +309,31 @@ function table.values(tab) return valueset, n end +-- map values to a new table +function table.map(tab, mapper) + + assert(tab) + assert(mapper) + + local newtab = {} + for k, v in pairs(tab) do + newtab[k] = mapper(k, v) + end + return newtab +end + +-- map values to a new array +function table.imap(arr, mapper) + + assert(arr) + assert(mapper) + + local newarr = {} + for k, v in ipairs(arr) do + table.insert(newarr, mapper(k, v)) + end + return newarr +end + -- return module: table return table diff --git a/xmake/plugins/project/vsxmake/getinfo.lua b/xmake/plugins/project/vsxmake/getinfo.lua index 0ee2605c3..d029a8a4b 100644 --- a/xmake/plugins/project/vsxmake/getinfo.lua +++ b/xmake/plugins/project/vsxmake/getinfo.lua @@ -176,10 +176,7 @@ function _make_targetinfo(mode, arch, target) -- save runenvs local runenvs = {} for k, v in pairs(target:get("runenvs")) do - local defs = {} - for _, d in ipairs(v) do - table.insert(defs, vformat(d)) - end + local defs = table.imap(v, function(_, v) return vformat(v) end) table.insert(runenvs, format("%s=%s", k, path.joinenv(defs))) end targetinfo.runenvs = table.concat(runenvs, "\n") @@ -345,7 +342,10 @@ function main(outputdir, vsinfo) for _,target in pairs(targets) do target._sub2 = {} local dirs = {} - for _,f in ipairs(table.join(target.sourcefiles, target.headerfiles)) do + local root = project.directory() + target.sourcefiles = table.imap(target.sourcefiles, function(_, v) return path.relative(v, root) end) + target.headerfiles = table.imap(target.headerfiles, function(_, v) return path.relative(v, root) end) + for _, f in ipairs(table.join(target.sourcefiles, target.headerfiles)) do local dir = path.directory(f) target._sub2[f] = { |
