Merge pull request #746 from LORgames/ssurtees/vs2010EscapeFixes

Fixed erroneous escape usages in VS2010+
This commit is contained in:
Tom van Dijck 2017-04-24 12:52:19 -07:00 committed by GitHub
commit 53d83dffbe
3 changed files with 36 additions and 5 deletions

View File

@ -1799,7 +1799,7 @@
function m.nmakePreprocessorDefinitions(cfg)
if cfg.kind ~= p.NONE and #cfg.defines > 0 then
local defines = table.concat(cfg.defines, ";")
defines = p.esc(defines) .. ";$(NMakePreprocessorDefinitions)"
defines = defines .. ";$(NMakePreprocessorDefinitions)"
m.element('NMakePreprocessorDefinitions', nil, defines)
end
end
@ -1914,7 +1914,7 @@
if escapeQuotes then
defines = defines:gsub('"', '\\"')
end
defines = p.esc(defines) .. ";%%(PreprocessorDefinitions)"
defines = defines .. ";%%(PreprocessorDefinitions)"
m.element('PreprocessorDefinitions', condition, defines)
end
end
@ -1926,7 +1926,7 @@
if escapeQuotes then
undefines = undefines:gsub('"', '\\"')
end
undefines = p.esc(undefines) .. ";%%(UndefinePreprocessorDefinitions)"
undefines = undefines .. ";%%(UndefinePreprocessorDefinitions)"
m.element('UndefinePreprocessorDefinitions', condition, undefines)
end
end
@ -2144,7 +2144,7 @@
function m.disableSpecificWarnings(cfg, condition)
if #cfg.disablewarnings > 0 then
local warnings = table.concat(cfg.disablewarnings, ";")
warnings = p.esc(warnings) .. ";%%(DisableSpecificWarnings)"
warnings = warnings .. ";%%(DisableSpecificWarnings)"
m.element('DisableSpecificWarnings', condition, warnings)
end
end
@ -2153,7 +2153,7 @@
function m.treatSpecificWarningsAsErrors(cfg, condition)
if #cfg.fatalwarnings > 0 then
local fatal = table.concat(cfg.fatalwarnings, ";")
fatal = p.esc(fatal) .. ";%%(TreatSpecificWarningsAsErrors)"
fatal = fatal .. ";%%(TreatSpecificWarningsAsErrors)"
m.element('TreatSpecificWarningsAsErrors', condition, fatal)
end
end

View File

@ -270,6 +270,24 @@
end
--
-- If defines are specified with escapable characters, they should be escaped.
--
function suite.preprocessorDefinitions_onDefines()
premake.escaper(premake.vstudio.vs2010.esc)
defines { "&", "<", ">" }
prepare()
test.capture [[
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<PreprocessorDefinitions>&amp;;&lt;;&gt;;%(PreprocessorDefinitions)</PreprocessorDefinitions>
]]
premake.escaper(nil)
end
--
-- If undefines are specified, the <UndefinePreprocessorDefinitions> element should be added.
--

View File

@ -126,6 +126,19 @@ command 2</NMakeBuildCommandLine>
]]
end
function suite.onEscapedDefines()
premake.escaper(premake.vstudio.vs2010.esc)
defines { "&", "<", ">" }
prepare()
test.capture [[
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<NMakeOutput>$(OutDir)MyProject</NMakeOutput>
<NMakePreprocessorDefinitions>&amp;;&lt;;&gt;;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>
</PropertyGroup>
]]
premake.escaper(nil)
end
function suite.onIncludeDirs()
includedirs { "include/lua", "include/zlib" }
prepare()