Fixed VC 2010 escaping of custom build steps
This commit is contained in:
parent
48bbde5334
commit
2efe9d780d
@ -17,18 +17,6 @@
|
||||
cs2005.elements = {}
|
||||
|
||||
|
||||
--
|
||||
-- XML escaping for C# projects is a little different than for C++.
|
||||
--
|
||||
|
||||
function cs2005.esc(value)
|
||||
value = value:gsub('&', "&")
|
||||
value = value:gsub('<', "<")
|
||||
value = value:gsub('>', ">")
|
||||
return value
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Generate a Visual Studio 200x C# project, with support for the new platforms API.
|
||||
--
|
||||
@ -45,7 +33,6 @@
|
||||
function cs2005.generate(prj)
|
||||
io.indent = " "
|
||||
io.eol = "\r\n"
|
||||
io.esc = cs2005.esc
|
||||
io.utf8()
|
||||
|
||||
premake.callarray(cs2005, cs2005.elements.project, prj)
|
||||
|
@ -36,6 +36,19 @@
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- The VS 2010 standard for XML escaping in generated project files.
|
||||
--
|
||||
|
||||
function vs2010.esc(value)
|
||||
value = value:gsub('&', "&")
|
||||
value = value:gsub('<', "<")
|
||||
value = value:gsub('>', ">")
|
||||
return value
|
||||
end
|
||||
|
||||
|
||||
|
||||
---
|
||||
-- Define the Visual Studio 2010 export action.
|
||||
---
|
||||
|
@ -27,7 +27,6 @@
|
||||
|
||||
function vc2010.generate(prj)
|
||||
io.indent = " "
|
||||
io.esc = vc2010.esc
|
||||
io.utf8()
|
||||
|
||||
vc2010.xmlDeclaration()
|
||||
@ -71,22 +70,6 @@
|
||||
|
||||
|
||||
|
||||
---
|
||||
-- Apply XML escaping on a value to be included in an
|
||||
-- exported project file.
|
||||
---
|
||||
|
||||
function vc2010.esc(value)
|
||||
value = string.gsub(value, '&', "&")
|
||||
value = value:gsub('<', "<")
|
||||
value = value:gsub('>', ">")
|
||||
value = value:gsub('\r', "
")
|
||||
value = value:gsub('\n', "
")
|
||||
return value
|
||||
end
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- Output the XML declaration and opening <Project> tag.
|
||||
--
|
||||
|
@ -15,7 +15,7 @@
|
||||
local sln, prj, cfg
|
||||
|
||||
function suite.setup()
|
||||
io.esc = cs2005.esc
|
||||
io.esc = premake.vstudio.vs2010.esc
|
||||
sln = test.createsolution()
|
||||
end
|
||||
|
||||
|
101
tests/actions/vstudio/vc2010/test_build_events.lua
Normal file
101
tests/actions/vstudio/vc2010/test_build_events.lua
Normal file
@ -0,0 +1,101 @@
|
||||
--
|
||||
-- tests/actions/vstudio/vc2010/test_build_events.lua
|
||||
-- Check generation of pre- and post-build commands for C++ projects.
|
||||
-- Copyright (c) 2012-2013 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
local suite = test.declare("vstudio_vc2010_build_events")
|
||||
local vc2010 = premake.vstudio.vc2010
|
||||
|
||||
|
||||
--
|
||||
-- Setup
|
||||
--
|
||||
|
||||
local sln, prj, cfg
|
||||
|
||||
function suite.setup()
|
||||
io.esc = premake.vstudio.vs2010.esc
|
||||
sln = test.createsolution()
|
||||
end
|
||||
|
||||
local function prepare(platform)
|
||||
prj = premake.solution.getproject(sln, 1)
|
||||
vc2010.buildEvents(prj)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- If no build steps are specified, nothing should be written.
|
||||
--
|
||||
|
||||
function suite.noOutput_onNoEvents()
|
||||
prepare()
|
||||
test.isemptycapture()
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- If one command set is used and not the other, only the one should be written.
|
||||
--
|
||||
|
||||
function suite.onlyOne_onPreBuildOnly()
|
||||
prebuildcommands { "command1" }
|
||||
prepare()
|
||||
test.capture [[
|
||||
<PreBuildEvent>
|
||||
<Command>command1</Command>
|
||||
</PreBuildEvent>
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.onlyOne_onPostBuildOnly()
|
||||
postbuildcommands { "command1" }
|
||||
prepare()
|
||||
test.capture [[
|
||||
<PostBuildEvent>
|
||||
<Command>command1</Command>
|
||||
</PostBuildEvent>
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.both_onBoth()
|
||||
prebuildcommands { "command1" }
|
||||
postbuildcommands { "command2" }
|
||||
prepare()
|
||||
test.capture [[
|
||||
<PreBuildEvent>
|
||||
<Command>command1</Command>
|
||||
</PreBuildEvent>
|
||||
<PostBuildEvent>
|
||||
<Command>command2</Command>
|
||||
</PostBuildEvent>
|
||||
]]
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Multiple commands should be separated with un-escaped EOLs.
|
||||
--
|
||||
|
||||
function suite.splits_onMultipleCommands()
|
||||
postbuildcommands { "command1", "command2" }
|
||||
prepare()
|
||||
test.capture ("\t\t<PostBuildEvent>\n\t\t\t<Command>command1\r\ncommand2</Command>\n\t\t</PostBuildEvent>\n")
|
||||
end
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- Quotes should not be escaped, other special characters should.
|
||||
--
|
||||
|
||||
function suite.onSpecialChars()
|
||||
postbuildcommands { '\' " < > &' }
|
||||
prepare()
|
||||
test.capture [[
|
||||
<PostBuildEvent>
|
||||
<Command>' " < > &</Command>
|
||||
</PostBuildEvent>
|
||||
]]
|
||||
end
|
@ -16,7 +16,7 @@
|
||||
local sln, prj
|
||||
|
||||
function suite.setup()
|
||||
io.esc = vc2010.esc
|
||||
io.esc = premake.vstudio.vs2010.esc
|
||||
sln, prj = test.createsolution()
|
||||
end
|
||||
|
||||
|
@ -142,6 +142,7 @@
|
||||
|
||||
-- Visual Studio 2010 C/C++ projects
|
||||
dofile("actions/vstudio/vc2010/test_assembly_refs.lua")
|
||||
dofile("actions/vstudio/vc2010/test_build_events.lua")
|
||||
dofile("actions/vstudio/vc2010/test_compile_settings.lua")
|
||||
dofile("actions/vstudio/vc2010/test_config_props.lua")
|
||||
dofile("actions/vstudio/vc2010/test_debug_settings.lua")
|
||||
|
Reference in New Issue
Block a user