From c220d594863e33ecbba83c46dcd3c64ddd721c2d Mon Sep 17 00:00:00 2001 From: ruki Date: Mon, 20 Mar 2017 11:06:56 +0800 Subject: fix some bug for vs201x project --- .../project/vstudio/impl/vs201x_vcxproj.lua | 84 ++++++++++++++-------- xmake/tools/cl.lua | 7 +- 2 files changed, 56 insertions(+), 35 deletions(-) diff --git a/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua b/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua index fcb41cf11..2da7da53c 100644 --- a/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua +++ b/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua @@ -270,14 +270,52 @@ function _make_common_item(vcxprojfile, vsinfo, targetinfo, vcxprojdir) vcxprojfile:print("%s %%(AdditionalOptions)", flags) -- make Optimization - if flags:find("[%-|/]Od") then - vcxprojfile:print("Disabled") - elseif flags:find("[%-|/]Os") or flags:find("[%-|/]O1") then + if flags:find("[%-|/]Os") or flags:find("[%-|/]O1") then vcxprojfile:print("MinSpace") elseif flags:find("[%-|/]O2") or flags:find("[%-|/]Ot") then vcxprojfile:print("MaxSpeed") elseif flags:find("[%-|/]Ox") then vcxprojfile:print("Full") + else + vcxprojfile:print("Disabled") + end + + -- make WarningLevel + if flags:find("[%-|/]W1") then + vcxprojfile:print("Level1") + elseif flags:find("[%-|/]W2") then + vcxprojfile:print("Level2") + elseif flags:find("[%-|/]W3") then + vcxprojfile:print("Level3") + elseif flags:find("[%-|/]Wall") then + vcxprojfile:print("EnableAllWarnings") + else + vcxprojfile:print("TurnOffAllWarnings") + end + if flags:find("[%-|/]WX") then + vcxprojfile:print("true") + end + + -- make DebugInformationFormat + if flags:find("[%-|/]Zi") then + vcxprojfile:print("ProgramDatabase") + elseif flags:find("[%-|/]ZI") then + vcxprojfile:print("EditAndContinue") + elseif flags:find("[%-|/]Z7") then + vcxprojfile:print("OldStyle") + else + vcxprojfile:print("None") + end + + -- make RuntimeLibrary + if flags:find("[%-|/]MDd") then + vcxprojfile:print("MultiThreadedDebugDLL") + elseif flags:find("[%-|/]MD") then + vcxprojfile:print("MultiThreadedDLL") + elseif flags:find("[%-|/]MTd") then + vcxprojfile:print("MultiThreadedDebug") + elseif flags:find("[%-|/]MT") then + vcxprojfile:print("MultiThreaded") end -- make ProgramDataBaseFileName (default: empty) @@ -358,41 +396,25 @@ end -- make source file function _make_source_file(vcxprojfile, vsinfo, sourcefile, sourceinfo, vcxprojdir) - -- no AdditionalOptions? - local additional = false - local objectfile = nil - for _, info in ipairs(sourceinfo) do - if table.concat(info.flags, " "):trim() ~= "" or (objectfile and info.objectfile ~= objectfile) then - additional = true - break - end - objectfile = info.objectfile - end - -- add source file vcxprojfile:enter("", path.relative(path.absolute(sourcefile), vcxprojdir)) - if additional then - for _, info in ipairs(sourceinfo) do + for _, info in ipairs(sourceinfo) do - -- get source flags - local flags = table.concat(info.flags, " "):trim() + -- get source flags + local flags = table.concat(info.flags, " "):trim() - -- make AdditionalOptions - if flags ~= "" then - vcxprojfile:print("%s %%(AdditionalOptions)", info.mode, info.arch, flags) - end + -- make AdditionalOptions + if flags ~= "" then + vcxprojfile:print("%s %%(AdditionalOptions)", info.mode, info.arch, flags) + end - -- make ObjectFileName - vcxprojfile:print("%s", info.mode, info.arch, path.relative(path.absolute(info.objectfile), vcxprojdir)) + -- make ObjectFileName + vcxprojfile:print("%s", info.mode, info.arch, path.relative(path.absolute(info.objectfile), vcxprojdir)) - -- complie as c++ if exists flag: /TP - if flags:find("[%-|/]TP") then - vcxprojfile:print("CompileAsCpp", info.mode, info.arch) - end + -- complie as c++ if exists flag: /TP + if flags:find("[%-|/]TP") then + vcxprojfile:print("CompileAsCpp", info.mode, info.arch) end - else - -- make ObjectFileName - vcxprojfile:print("%s", path.relative(path.absolute(objectfile), vcxprojdir)) end vcxprojfile:leave("") end diff --git a/xmake/tools/cl.lua b/xmake/tools/cl.lua index 591e40f7d..f67f072ab 100644 --- a/xmake/tools/cl.lua +++ b/xmake/tools/cl.lua @@ -23,7 +23,6 @@ -- -- imports -import("core.project.config") import("core.project.project") -- init it @@ -137,10 +136,10 @@ function nf_warning(level) -- the maps local maps = { - none = "-w" + none = "-W0" , less = "-W1" , more = "-W3" - , all = "-W3" + , all = "-W3" -- = "-Wall" will enable too more warnings , error = "-WX" } @@ -197,7 +196,7 @@ function nf_language(stdname) -- select maps local maps = cmaps - if _g.kind == "cxx" or _g.kind == "mxx" or config.get("vs") >= "2015" then + if _g.kind == "cxx" or _g.kind == "mxx" then maps = {} end -- cgit v1.3.1