From 35d3d81d6d397907c838698bd3a18ae37b861bc0 Mon Sep 17 00:00:00 2001 From: ruki Date: Fri, 19 Mar 2021 00:00:07 +0800 Subject: fix vs generator --- xmake/modules/core/tools/cl.lua | 2 +- .../project/vstudio/impl/vs201x_vcxproj.lua | 24 ++++++++++++++++++---- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/xmake/modules/core/tools/cl.lua b/xmake/modules/core/tools/cl.lua index 7b7ef3f9f..110c6f3f5 100644 --- a/xmake/modules/core/tools/cl.lua +++ b/xmake/modules/core/tools/cl.lua @@ -260,7 +260,7 @@ end -- make the includedir flag function nf_includedir(self, dir) - return {"-I", path.translate(dir)} + return {"-I" .. path.translate(dir)} end -- make the sysincludedir flag diff --git a/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua b/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua index b5691a5fa..b1bd6f764 100644 --- a/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua +++ b/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua @@ -62,7 +62,11 @@ function _make_compcmd(compargv, sourcefile, objectfile, vcxprojdir) v = v:gsub("__objectfile__", objectfile) -- -Idir or /Idir v = v:gsub("([%-/]I)(.*)", function (I, dir) - dir = path.translate(dir:trim()) + dir = dir:trim() + if #dir == 0 then + return "" + end + dir = path.translate(dir) if not path.is_absolute(dir) then dir = path.relative(path.absolute(dir), vcxprojdir) end @@ -82,7 +86,11 @@ function _make_compflags(sourcefile, targetinfo, vcxprojdir) -- -Idir or /Idir flag = flag:gsub("[%-/]I(.*)", function (dir) - dir = path.translate(dir:trim()) + dir = dir:trim() + if #dir == 0 then + return "" + end + dir = path.translate(dir) if not path.is_absolute(dir) then dir = path.relative(path.absolute(dir), vcxprojdir) end @@ -110,7 +118,11 @@ function _make_linkflags(targetinfo, vcxprojdir) -- replace -libpath:dir or /libpath:dir flag = flag:gsub(string.ipattern("[%-/]libpath:(.*)"), function (dir) - dir = path.translate(dir:trim()) + dir = dir:trim() + if #dir == 0 then + return "" + end + dir = path.translate(dir) if not path.is_absolute(dir) then dir = path.relative(path.absolute(dir), vcxprojdir) end @@ -119,7 +131,11 @@ function _make_linkflags(targetinfo, vcxprojdir) -- replace -def:dir or /def:dir flag = flag:gsub(string.ipattern("[%-/]def:(.*)"), function (dir) - dir = path.translate(dir:trim()) + dir = dir:trim() + if #dir == 0 then + return "" + end + dir = path.translate(dir) if not path.is_absolute(dir) then dir = path.relative(path.absolute(dir), vcxprojdir) end -- cgit v1.3.1