From e9aabdfe08c0dd9657d1a67f7504293fddd40c5b Mon Sep 17 00:00:00 2001 From: ruki Date: Tue, 9 Aug 2016 14:23:06 +0800 Subject: modify pdb path for vcproj --- .../plugins/project/vstudio/impl/vs200x_vcproj.lua | 58 +++++++++++++++++++--- 1 file changed, 51 insertions(+), 7 deletions(-) diff --git a/xmake/plugins/project/vstudio/impl/vs200x_vcproj.lua b/xmake/plugins/project/vstudio/impl/vs200x_vcproj.lua index 78f96d934..fe81c962e 100755 --- a/xmake/plugins/project/vstudio/impl/vs200x_vcproj.lua +++ b/xmake/plugins/project/vstudio/impl/vs200x_vcproj.lua @@ -32,9 +32,11 @@ function _make_compflags(sourcefile, target, vcprojdir) -- make the compiling flags local _, compflags = compiler.compflags(sourcefile, target) - -- replace -Idir or /Idir + -- replace -Idir or /Idir, -Fdsymbol.pdb or /Fdsymbol.pdb local flags = {} for _, flag in ipairs(compflags) do + + -- replace -Idir or /Idir flag = flag:gsub("[%-|/]I(.*)", function (dir) dir = dir:trim() if not path.is_absolute(dir) then @@ -42,9 +44,20 @@ function _make_compflags(sourcefile, target, vcprojdir) end return "/I" .. dir end) + + -- replace -Fdsymbol.pdb or /Fdsymbol.pdb + flag = flag:gsub("[%-|/]Fd(.*)", function (dir) + dir = dir:trim() + if not path.is_absolute(dir) then + dir = path.relative(path.absolute(dir), vcprojdir) + end + return "/Fd" .. dir + end) + + -- save flag table.insert(flags, flag) end - + -- concat flags flags = table.concat(flags, " "):trim() @@ -61,9 +74,11 @@ function _make_linkflags(target, vcprojdir) -- make the linking flags local _, linkflags = linker.linkflags(target) - -- replace -libpath:dir or /libpath:dir + -- replace -libpath:dir or /libpath:dir, -pdb:symbol.pdb or /pdb:symbol.pdb local flags = {} for _, flag in ipairs(linkflags) do + + -- replace -libpath:dir or /libpath:dir flag = flag:gsub("[%-|/]libpath:(.*)", function (dir) dir = dir:trim() if not path.is_absolute(dir) then @@ -71,6 +86,17 @@ function _make_linkflags(target, vcprojdir) end return "/libpath:" .. dir end) + + -- replace -pdb:symbol.pdb or /pdb:symbol.pdb + flag = flag:gsub("[%-|/]pdb:(.*)", function (dir) + dir = dir:trim() + if not path.is_absolute(dir) then + dir = path.relative(path.absolute(dir), vcprojdir) + end + return "/pdb:" .. dir + end) + + -- save flag table.insert(flags, flag) end @@ -155,6 +181,7 @@ end function _make_VCCLCompilerTool(vcprojfile, vsinfo, target) vcprojfile:enter("") end @@ -336,7 +363,17 @@ end -- /> -- -- -function _make_file(vcprojfile, vsinfo, target, sourcefile, vcprojdir) +function _make_file(vcprojfile, vsinfo, target, sourcefile, objectfile, vcprojdir) + + -- get the target key + local key = tostring(target) + + -- make flags cache + _g.flags = _g.flags or {} + + -- make flags + local flags = _g.flags[key] or _make_compflags(sourcefile, target, vcprojdir) + _g.flags[key] = flags -- enter file vcprojfile:enter("") vcprojfile:leave("") @@ -401,8 +444,9 @@ function _make_files(vcprojfile, vsinfo, target, vcprojdir) vcprojfile:print(">") -- add files - for _, sourcefile in ipairs(target:sourcefiles()) do - _make_file(vcprojfile, vsinfo, target, sourcefile, vcprojdir) + local objectfiles = target:objectfiles() + for idx, sourcefile in ipairs(target:sourcefiles()) do + _make_file(vcprojfile, vsinfo, target, sourcefile, objectfiles[idx], vcprojdir) end -- leave files -- cgit v1.3.1