diff options
| author | ruki <[email protected]> | 2017-03-20 11:06:56 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2017-03-20 11:06:56 +0800 |
| commit | c220d594863e33ecbba83c46dcd3c64ddd721c2d (patch) | |
| tree | d0da43c541854664fc0314b653ef5cb85aca62df | |
| parent | 3efb4e5bb65e0d39f2f3571ca0eaaf76c8af8cc7 (diff) | |
fix some bug for vs201x project
| -rw-r--r-- | xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua | 84 | ||||
| -rw-r--r-- | 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("<AdditionalOptions>%s %%(AdditionalOptions)</AdditionalOptions>", flags) -- make Optimization - if flags:find("[%-|/]Od") then - vcxprojfile:print("<Optimization>Disabled</Optimization>") - elseif flags:find("[%-|/]Os") or flags:find("[%-|/]O1") then + if flags:find("[%-|/]Os") or flags:find("[%-|/]O1") then vcxprojfile:print("<Optimization>MinSpace</Optimization>") elseif flags:find("[%-|/]O2") or flags:find("[%-|/]Ot") then vcxprojfile:print("<Optimization>MaxSpeed</Optimization>") elseif flags:find("[%-|/]Ox") then vcxprojfile:print("<Optimization>Full</Optimization>") + else + vcxprojfile:print("<Optimization>Disabled</Optimization>") + end + + -- make WarningLevel + if flags:find("[%-|/]W1") then + vcxprojfile:print("<WarningLevel>Level1</WarningLevel>") + elseif flags:find("[%-|/]W2") then + vcxprojfile:print("<WarningLevel>Level2</WarningLevel>") + elseif flags:find("[%-|/]W3") then + vcxprojfile:print("<WarningLevel>Level3</WarningLevel>") + elseif flags:find("[%-|/]Wall") then + vcxprojfile:print("<WarningLevel>EnableAllWarnings</WarningLevel>") + else + vcxprojfile:print("<WarningLevel>TurnOffAllWarnings</WarningLevel>") + end + if flags:find("[%-|/]WX") then + vcxprojfile:print("<TreatWarningAsError>true</TreatWarningAsError>") + end + + -- make DebugInformationFormat + if flags:find("[%-|/]Zi") then + vcxprojfile:print("<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>") + elseif flags:find("[%-|/]ZI") then + vcxprojfile:print("<DebugInformationFormat>EditAndContinue</DebugInformationFormat>") + elseif flags:find("[%-|/]Z7") then + vcxprojfile:print("<DebugInformationFormat>OldStyle</DebugInformationFormat>") + else + vcxprojfile:print("<DebugInformationFormat>None</DebugInformationFormat>") + end + + -- make RuntimeLibrary + if flags:find("[%-|/]MDd") then + vcxprojfile:print("<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>") + elseif flags:find("[%-|/]MD") then + vcxprojfile:print("<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>") + elseif flags:find("[%-|/]MTd") then + vcxprojfile:print("<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>") + elseif flags:find("[%-|/]MT") then + vcxprojfile:print("<RuntimeLibrary>MultiThreaded</RuntimeLibrary>") 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("<ClCompile Include=\"%s\">", 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("<AdditionalOptions Condition=\"\'%$(Configuration)|%$(Platform)\'==\'%s|%s\'\">%s %%(AdditionalOptions)</AdditionalOptions>", info.mode, info.arch, flags) - end + -- make AdditionalOptions + if flags ~= "" then + vcxprojfile:print("<AdditionalOptions Condition=\"\'%$(Configuration)|%$(Platform)\'==\'%s|%s\'\">%s %%(AdditionalOptions)</AdditionalOptions>", info.mode, info.arch, flags) + end - -- make ObjectFileName - vcxprojfile:print("<ObjectFileName Condition=\"\'%$(Configuration)|%$(Platform)\'==\'%s|%s\'\">%s</ObjectFileName>", info.mode, info.arch, path.relative(path.absolute(info.objectfile), vcxprojdir)) + -- make ObjectFileName + vcxprojfile:print("<ObjectFileName Condition=\"\'%$(Configuration)|%$(Platform)\'==\'%s|%s\'\">%s</ObjectFileName>", 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("<CompileAs Condition=\"\'%$(Configuration)|%$(Platform)\'==\'%s|%s\'\">CompileAsCpp</CompileAs>", info.mode, info.arch) - end + -- complie as c++ if exists flag: /TP + if flags:find("[%-|/]TP") then + vcxprojfile:print("<CompileAs Condition=\"\'%$(Configuration)|%$(Platform)\'==\'%s|%s\'\">CompileAsCpp</CompileAs>", info.mode, info.arch) end - else - -- make ObjectFileName - vcxprojfile:print("<ObjectFileName>%s</ObjectFileName>", path.relative(path.absolute(objectfile), vcxprojdir)) end vcxprojfile:leave("</ClCompile>") 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 |
