summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOpportunityLiu <[email protected]>2019-08-18 10:49:22 +0800
committerOpportunityLiu <[email protected]>2019-08-18 10:49:22 +0800
commitb4fd8763e8cd72e521b668bf75a0f37061f5762d (patch)
tree4cf1b2b8f6baafda99440936b3c4d568eff77aa3
parent2c5d7d443fcda38f50dae1a0050eca5ff6ef531f (diff)
fix #533
-rw-r--r--xmake/core/base/table.lua30
-rw-r--r--xmake/plugins/project/vsxmake/getinfo.lua10
2 files changed, 35 insertions, 5 deletions
diff --git a/xmake/core/base/table.lua b/xmake/core/base/table.lua
index 1f3e79add..1917d827a 100644
--- a/xmake/core/base/table.lua
+++ b/xmake/core/base/table.lua
@@ -309,5 +309,35 @@ function table.values(tab)
return valueset, n
end
+-- map values to a new table
+function table.map(tab, mapper)
+
+ assert(tab)
+ if mapper == nil then
+ return table.copy(tab)
+ end
+
+ 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)
+ if mapper == nil then
+ return table.copy(arr)
+ end
+
+ 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..240d93881 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.map(target.sourcefiles, function(_, v) return path.relative(v, root) end)
+ target.headerfiles = table.map(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] =
{