From 347b05c2c2b249c482f746ae2d7b4d72861e7501 Mon Sep 17 00:00:00 2001 From: ruki Date: Tue, 4 Jul 2017 16:57:24 +0800 Subject: fix symbolfile for vs201x plugin --- xmake/plugins/project/vstudio/impl/vs201x.lua | 3 + .../project/vstudio/impl/vs201x_vcxproj.lua | 76 +++++++++++++--------- 2 files changed, 50 insertions(+), 29 deletions(-) (limited to 'xmake/plugins/project/vstudio/impl') diff --git a/xmake/plugins/project/vstudio/impl/vs201x.lua b/xmake/plugins/project/vstudio/impl/vs201x.lua index cddf6daca..566c45470 100644 --- a/xmake/plugins/project/vstudio/impl/vs201x.lua +++ b/xmake/plugins/project/vstudio/impl/vs201x.lua @@ -55,6 +55,9 @@ function _make_targetinfo(mode, arch, target) -- save target file targetinfo.targetfile = target:targetfile() + -- save symbol file + targetinfo.symbolfile = target:symbolfile() + -- save sourcebatches targetinfo.sourcebatches = target:sourcebatches() diff --git a/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua b/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua index 638390795..2972e5562 100644 --- a/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua +++ b/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua @@ -66,7 +66,7 @@ end -- make linking flags function _make_linkflags(targetinfo, vcxprojdir) - -- replace -libpath:dir or /libpath:dir, -pdb:symbol.pdb or /pdb:symbol.pdb + -- replace -libpath:dir or /libpath:dir local flags = {} for _, flag in ipairs(targetinfo.linkflags) do @@ -79,15 +79,6 @@ function _make_linkflags(targetinfo, vcxprojdir) 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), vcxprojdir) - end - return "/pdb:" .. dir - end) - -- save flag table.insert(flags, flag) end @@ -315,20 +306,36 @@ function _make_common_item(vcxprojfile, vsinfo, targetinfo, vcxprojdir) -- enter ItemDefinitionGroup vcxprojfile:enter("", targetinfo.mode, targetinfo.arch) + -- init the linker kinds + local linkerkinds = + { + binary = "Link" + , static = "Lib" + , shared = "Link" + } + -- for linker? - if targetinfo.targetkind == "binary" then - vcxprojfile:enter("") + vcxprojfile:enter("<%s>", linkerkinds[targetinfo.targetkind]) - -- make linker flags - local flags = table.concat(_make_linkflags(targetinfo, vcxprojdir), " "):trim() + -- make linker flags + local flags = table.concat(_make_linkflags(targetinfo, vcxprojdir), " "):trim() - -- remove "-machine:[x86|x64]" - flags = flags:gsub("[%-/]machine:.+", "") + -- remove "-machine:[x86|x64]" + flags = flags:gsub("[%-/]machine:%w+", "") - -- make AdditionalOptions - vcxprojfile:print("%s %%(AdditionalOptions)", flags) + -- remove "-pdb:*.pdb" + flags = flags:gsub("[%-/]pdb:.+%.pdb", "") + + -- remove "-debug" + flags = flags:gsub("[%-/]debug", "") - -- generate debug infomation? + -- make AdditionalOptions + vcxprojfile:print("%s %%(AdditionalOptions)", flags) + + -- generate debug infomation? + if linkerkinds[targetinfo.targetkind] == "Link" then + + -- enable debug infomation? local debug = false for _, symbol in ipairs(targetinfo.symbols) do if symbol == "debug" then @@ -338,17 +345,25 @@ function _make_common_item(vcxprojfile, vsinfo, targetinfo, vcxprojdir) end vcxprojfile:print("%s", tostring(debug)) - -- make SubSystem + -- make *.pdb file path + local symbolfile = targetinfo.symbolfile + if symbolfile then + vcxprojfile:print("%s", path.relative(path.absolute(symbolfile), vcxprojdir)) + end + end + + -- make SubSystem + if targetinfo.targetkind == "binary" then vcxprojfile:print("Console") - - -- make TargetMachine - vcxprojfile:print("%s", ifelse(targetinfo.arch == "x64", "MachineX64", "MachineX86")) + end + + -- make TargetMachine + vcxprojfile:print("%s", ifelse(targetinfo.arch == "x64", "MachineX64", "MachineX86")) - -- make OutputFile - vcxprojfile:print("%s", path.relative(path.absolute(targetinfo.targetfile), vcxprojdir)) + -- make OutputFile + vcxprojfile:print("%s", path.relative(path.absolute(targetinfo.targetfile), vcxprojdir)) - vcxprojfile:leave("") - end + vcxprojfile:leave("", linkerkinds[targetinfo.targetkind]) -- for compiler? vcxprojfile:enter("") @@ -356,8 +371,11 @@ function _make_common_item(vcxprojfile, vsinfo, targetinfo, vcxprojdir) -- make source options _make_source_options(vcxprojfile, targetinfo.commonflags) - -- make ProgramDataBaseFileName (default: empty) - vcxprojfile:print("") + -- make *.pdb file path + local symbolfile = targetinfo.symbolfile + if symbolfile then + vcxprojfile:print("%s", path.relative(path.absolute(symbolfile), vcxprojdir)) + end vcxprojfile:leave("") -- cgit v1.3.1