diff options
| author | ruki <[email protected]> | 2019-03-06 00:32:20 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2019-03-05 21:14:05 +0800 |
| commit | 6cfc62866ceb1e70ce759ac22baecd15805666f3 (patch) | |
| tree | e19b30ad50973268e91b9981a3b84ba32018ce02 | |
| parent | f8753e436dc75203361a6a5256235f2796701e6f (diff) | |
improve vs201x
| -rw-r--r-- | xmake/plugins/project/vstudio/impl/vs201x.lua | 4 | ||||
| -rw-r--r-- | xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua | 25 |
2 files changed, 24 insertions, 5 deletions
diff --git a/xmake/plugins/project/vstudio/impl/vs201x.lua b/xmake/plugins/project/vstudio/impl/vs201x.lua index e8e9dc4a2..1fcbe1acd 100644 --- a/xmake/plugins/project/vstudio/impl/vs201x.lua +++ b/xmake/plugins/project/vstudio/impl/vs201x.lua @@ -77,7 +77,7 @@ function _make_targetinfo(mode, arch, target) -- save compiler flags and cmds local firstcompflags = nil targetinfo.compflags = {} - targetinfo.compcmds = {} + targetinfo.compargvs = {} for sourcekind, sourcebatch in pairs(target:sourcebatches()) do if not sourcebatch.rulename then for idx, sourcefile in ipairs(sourcebatch.sourcefiles) do @@ -86,7 +86,7 @@ function _make_targetinfo(mode, arch, target) firstcompflags = compflags end targetinfo.compflags[sourcefile] = compflags - targetinfo.compcmds[sourcefile] = compiler.compcmd("__sourcefile__", "__objectfile__", {sourcekind = sourcekind, target = target}) + targetinfo.compargvs[sourcefile] = table.join(compiler.compargv("__sourcefile__", "__objectfile__", {sourcekind = sourcekind, target = target})) end end end diff --git a/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua b/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua index 6ed72b75e..6914c805a 100644 --- a/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua +++ b/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua @@ -87,6 +87,25 @@ function _get_platform_sdkver(target, vsinfo) return sdkver or sdkvers["vs" .. vsinfo.vstudio_version] end +-- make compiling command +function _make_compcmd(compargv, sourcefile, objectfile, vcxprojdir) + local argv = {} + for _, v in ipairs(compargv) do + v = v:gsub("__sourcefile__", sourcefile) + v = v:gsub("__objectfile__", objectfile) + -- -Idir or /Idir + v = v:gsub("[%-/]I(.*)", function (dir) + dir = path.translate(dir:trim()) + if not path.is_absolute(dir) then + dir = path.relative(path.absolute(dir), vcxprojdir) + end + return "/I" .. dir + end) + table.insert(argv, v) + end + return table.concat(argv, " ") +end + -- make compiling flags function _make_compflags(sourcefile, targetinfo, vcxprojdir) @@ -541,7 +560,7 @@ function _make_source_file_forall(vcxprojfile, vsinfo, target, sourcefile, sourc vcxprojfile:print("<FileType>Document</FileType>") for _, info in ipairs(sourceinfo) do local objectfile = path.relative(path.absolute(info.objectfile), vcxprojdir) - local compcmd = info.compcmd:gsub("__objectfile__", objectfile):gsub("__sourcefile__", sourcefile) + local compcmd = _make_compcmd(info.compargv, sourcefile, objectfile, vcxprojdir) vcxprojfile:print("<Outputs Condition=\"\'%$(Configuration)|%$(Platform)\'==\'%s\'\">%s</Outputs>", info.mode .. '|' .. info.arch, objectfile) vcxprojfile:print("<Command Condition=\"\'%$(Configuration)|%$(Platform)\'==\'%s\'\">%s</Command>", info.mode .. '|' .. info.arch, compcmd) end @@ -654,7 +673,7 @@ function _make_source_file_forspec(vcxprojfile, vsinfo, target, sourcefile, sour -- for *.asm files local objectfile = path.relative(path.absolute(info.objectfile), vcxprojdir) if info.sourcekind == "as" then - local compcmd = info.compcmd:gsub("__objectfile__", objectfile):gsub("__sourcefile__", sourcefile) + local compcmd = _make_compcmd(info.compargv, sourcefile, objectfile, vcxprojdir) vcxprojfile:print("<ExcludedFromBuild>false</ExcludedFromBuild>") vcxprojfile:print("<FileType>Document</FileType>") vcxprojfile:print("<Outputs>%s</Outputs>", objectfile) @@ -725,7 +744,7 @@ function _make_source_files(vcxprojfile, vsinfo, target, vcxprojdir) local objectfile = objectfiles[idx] local flags = targetinfo.sourceflags[sourcefile] sourceinfos[sourcefile] = sourceinfos[sourcefile] or {} - table.insert(sourceinfos[sourcefile], {mode = targetinfo.mode, arch = targetinfo.arch, sourcekind = sourcekind, objectfile = objectfile, flags = flags, compcmd = targetinfo.compcmds[sourcefile]}) + table.insert(sourceinfos[sourcefile], {mode = targetinfo.mode, arch = targetinfo.arch, sourcekind = sourcekind, objectfile = objectfile, flags = flags, compargv = targetinfo.compargvs[sourcefile]}) end end end |
