diff options
| author | ruki <[email protected]> | 2017-07-04 16:57:24 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2017-07-04 16:57:24 +0800 |
| commit | 347b05c2c2b249c482f746ae2d7b4d72861e7501 (patch) | |
| tree | 90c86e1b2ffd15591490dc9a5325f06ad325fb1a | |
| parent | fd8e051b5920bc73354b12d90088591b72e40ee9 (diff) | |
fix symbolfile for vs201x plugin
| -rw-r--r-- | xmake/core/base/os.lua | 14 | ||||
| -rw-r--r-- | xmake/core/project/project.lua | 8 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/interpreter/os.lua | 26 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/os.lua | 2 | ||||
| -rw-r--r-- | xmake/modules/core/tools/link.lua | 3 | ||||
| -rw-r--r-- | xmake/plugins/project/vstudio/impl/vs201x.lua | 3 | ||||
| -rw-r--r-- | xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua | 76 |
7 files changed, 81 insertions, 51 deletions
diff --git a/xmake/core/base/os.lua b/xmake/core/base/os.lua index 93f910c48..6616c2849 100644 --- a/xmake/core/base/os.lua +++ b/xmake/core/base/os.lua @@ -700,18 +700,24 @@ end -- get the program directory function os.programdir() - - -- get it return xmake._PROGRAM_DIR end -- get the program file function os.programfile() - - -- get it return xmake._PROGRAM_FILE end +-- get the project directory +function os.projectdir() + return xmake._PROJECT_DIR +end + +-- get the project file +function os.projectfile() + return xmake._PROJECT_FILE +end + -- get version info function os.versioninfo() diff --git a/xmake/core/project/project.lua b/xmake/core/project/project.lua index 89728889e..4368a7220 100644 --- a/xmake/core/project/project.lua +++ b/xmake/core/project/project.lua @@ -364,16 +364,12 @@ end -- get the project file function project.file() - - -- get it - return xmake._PROJECT_FILE + return os.projectfile() end -- get the project directory function project.directory() - - -- get it - return xmake._PROJECT_DIR + return os.projectdir() end -- get the project info from the given name diff --git a/xmake/core/sandbox/modules/interpreter/os.lua b/xmake/core/sandbox/modules/interpreter/os.lua index b11e6bcb4..b956726eb 100644 --- a/xmake/core/sandbox/modules/interpreter/os.lua +++ b/xmake/core/sandbox/modules/interpreter/os.lua @@ -30,17 +30,21 @@ local string = require("base/string") local sandbox_os = sandbox_os or {} -- export some readonly interfaces -sandbox_os.date = os.date -sandbox_os.time = os.time -sandbox_os.mtime = os.mtime -sandbox_os.mclock = os.mclock -sandbox_os.getenv = os.getenv -sandbox_os.isdir = os.isdir -sandbox_os.isfile = os.isfile -sandbox_os.exists = os.exists -sandbox_os.curdir = os.curdir -sandbox_os.tmpdir = os.tmpdir -sandbox_os.uuid = os.uuid +sandbox_os.date = os.date +sandbox_os.time = os.time +sandbox_os.mtime = os.mtime +sandbox_os.mclock = os.mclock +sandbox_os.getenv = os.getenv +sandbox_os.isdir = os.isdir +sandbox_os.isfile = os.isfile +sandbox_os.exists = os.exists +sandbox_os.curdir = os.curdir +sandbox_os.tmpdir = os.tmpdir +sandbox_os.programdir = os.programdir +sandbox_os.programfile = os.programfile +sandbox_os.projectdir = os.projectdir +sandbox_os.projectfile = os.projectfile +sandbox_os.uuid = os.uuid -- match files function sandbox_os.files(pattern, ...) diff --git a/xmake/core/sandbox/modules/os.lua b/xmake/core/sandbox/modules/os.lua index 089f42d7e..7f53818e4 100644 --- a/xmake/core/sandbox/modules/os.lua +++ b/xmake/core/sandbox/modules/os.lua @@ -48,6 +48,8 @@ sandbox_os.nuldev = os.nuldev sandbox_os.emptydir = os.emptydir sandbox_os.programdir = os.programdir sandbox_os.programfile = os.programfile +sandbox_os.projectdir = os.projectdir +sandbox_os.projectfile = os.projectfile sandbox_os.versioninfo = os.versioninfo -- copy file or directory diff --git a/xmake/modules/core/tools/link.lua b/xmake/modules/core/tools/link.lua index 6d11d3a94..f41a093d4 100644 --- a/xmake/modules/core/tools/link.lua +++ b/xmake/modules/core/tools/link.lua @@ -71,7 +71,8 @@ function nf_symbol(self, level, target) -- debug? generate *.pdb file local flags = "" - if level == "debug" then + local targetkind = target:get("kind") + if level == "debug" and (targetkind == "binary" or targetkind == "shared") then if target and target.symbolfile then flags = "-debug -pdb:" .. target:symbolfile() else 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("<ItemDefinitionGroup Condition=\"\'%$(Configuration)|%$(Platform)\'==\'%s|%s\'\">", 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("<Link>") + 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("<AdditionalOptions>%s %%(AdditionalOptions)</AdditionalOptions>", flags) + -- remove "-pdb:*.pdb" + flags = flags:gsub("[%-/]pdb:.+%.pdb", "") + + -- remove "-debug" + flags = flags:gsub("[%-/]debug", "") - -- generate debug infomation? + -- make AdditionalOptions + vcxprojfile:print("<AdditionalOptions>%s %%(AdditionalOptions)</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("<GenerateDebugInformation>%s</GenerateDebugInformation>", tostring(debug)) - -- make SubSystem + -- make *.pdb file path + local symbolfile = targetinfo.symbolfile + if symbolfile then + vcxprojfile:print("<ProgramDatabaseFile>%s</ProgramDatabaseFile>", path.relative(path.absolute(symbolfile), vcxprojdir)) + end + end + + -- make SubSystem + if targetinfo.targetkind == "binary" then vcxprojfile:print("<SubSystem>Console</SubSystem>") - - -- make TargetMachine - vcxprojfile:print("<TargetMachine>%s</TargetMachine>", ifelse(targetinfo.arch == "x64", "MachineX64", "MachineX86")) + end + + -- make TargetMachine + vcxprojfile:print("<TargetMachine>%s</TargetMachine>", ifelse(targetinfo.arch == "x64", "MachineX64", "MachineX86")) - -- make OutputFile - vcxprojfile:print("<OutputFile>%s</OutputFile>", path.relative(path.absolute(targetinfo.targetfile), vcxprojdir)) + -- make OutputFile + vcxprojfile:print("<OutputFile>%s</OutputFile>", path.relative(path.absolute(targetinfo.targetfile), vcxprojdir)) - vcxprojfile:leave("</Link>") - end + vcxprojfile:leave("</%s>", linkerkinds[targetinfo.targetkind]) -- for compiler? vcxprojfile:enter("<ClCompile>") @@ -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("<ProgramDataBaseFileName></ProgramDataBaseFileName>") + -- make *.pdb file path + local symbolfile = targetinfo.symbolfile + if symbolfile then + vcxprojfile:print("<ProgramDatabaseFile>%s</ProgramDatabaseFile>", path.relative(path.absolute(symbolfile), vcxprojdir)) + end vcxprojfile:leave("</ClCompile>") |
