Fixed various issues with escaping in CodeLite generator
This commit is contained in:
parent
5913b0ebaa
commit
4531b0de4a
@ -26,10 +26,19 @@
|
|||||||
return cfgname
|
return cfgname
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Element text is not escaped the same as element attributes
|
||||||
|
function codelite.escElementText(value)
|
||||||
|
local result = value:gsub('&', '&')
|
||||||
|
result = result:gsub('<', '<')
|
||||||
|
result = result:gsub('>', '>')
|
||||||
|
return result
|
||||||
|
end
|
||||||
|
|
||||||
function codelite.esc(value)
|
function codelite.esc(value)
|
||||||
local result = value:gsub('&', '&')
|
local result = value:gsub('&', '&')
|
||||||
result = result:gsub('<', '<')
|
result = result:gsub('<', '<')
|
||||||
result = result:gsub('>', '>')
|
result = result:gsub('>', '>')
|
||||||
|
result = result:gsub('"', '\\"')
|
||||||
return result
|
return result
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -207,7 +207,7 @@
|
|||||||
_x(4, '<IncludePath Value="%s"/>', project.getrelative(cfg.project, includedir))
|
_x(4, '<IncludePath Value="%s"/>', project.getrelative(cfg.project, includedir))
|
||||||
end
|
end
|
||||||
for _, define in ipairs(cfg.defines) do
|
for _, define in ipairs(cfg.defines) do
|
||||||
_x(4, '<Preprocessor Value="%s"/>', p.esc(define))
|
_p(4, '<Preprocessor Value="%s"/>', p.esc(define):gsub(' ', '\\ '))
|
||||||
end
|
end
|
||||||
_p(3, '</Compiler>')
|
_p(3, '</Compiler>')
|
||||||
end
|
end
|
||||||
@ -287,7 +287,7 @@
|
|||||||
local envs = table.concat(cfg.debugenvs, "\n")
|
local envs = table.concat(cfg.debugenvs, "\n")
|
||||||
|
|
||||||
_p(3, '<Environment EnvVarSetName="<Use Defaults>" DbgSetName="<Use Defaults>">')
|
_p(3, '<Environment EnvVarSetName="<Use Defaults>" DbgSetName="<Use Defaults>">')
|
||||||
_x(4, '<![CDATA[%s]]>', envs)
|
_p(4, '<![CDATA[%s]]>', envs)
|
||||||
_p(3, '</Environment>')
|
_p(3, '</Environment>')
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -295,17 +295,23 @@
|
|||||||
|
|
||||||
_p(3, '<Debugger IsRemote="%s" RemoteHostName="%s" RemoteHostPort="%s" DebuggerPath="" IsExtended="%s">', iif(cfg.debugremotehost, "yes", "no"), cfg.debugremotehost or "", iif(cfg.debugport, tostring(cfg.debugport), ""), iif(cfg.debugextendedprotocol, "yes", "no"))
|
_p(3, '<Debugger IsRemote="%s" RemoteHostName="%s" RemoteHostPort="%s" DebuggerPath="" IsExtended="%s">', iif(cfg.debugremotehost, "yes", "no"), cfg.debugremotehost or "", iif(cfg.debugport, tostring(cfg.debugport), ""), iif(cfg.debugextendedprotocol, "yes", "no"))
|
||||||
if #cfg.debugsearchpaths > 0 then
|
if #cfg.debugsearchpaths > 0 then
|
||||||
|
p.escaper(codelite.escElementText)
|
||||||
_p(4, '<DebuggerSearchPaths>%s</DebuggerSearchPaths>', table.concat(p.esc(project.getrelative(cfg.project, cfg.debugsearchpaths)), "\n"))
|
_p(4, '<DebuggerSearchPaths>%s</DebuggerSearchPaths>', table.concat(p.esc(project.getrelative(cfg.project, cfg.debugsearchpaths)), "\n"))
|
||||||
|
p.escaper(codelite.esc)
|
||||||
else
|
else
|
||||||
_p(4, '<DebuggerSearchPaths/>')
|
_p(4, '<DebuggerSearchPaths/>')
|
||||||
end
|
end
|
||||||
if #cfg.debugconnectcommands > 0 then
|
if #cfg.debugconnectcommands > 0 then
|
||||||
|
p.escaper(codelite.escElementText)
|
||||||
_p(4, '<PostConnectCommands>%s</PostConnectCommands>', table.concat(p.esc(cfg.debugconnectcommands), "\n"))
|
_p(4, '<PostConnectCommands>%s</PostConnectCommands>', table.concat(p.esc(cfg.debugconnectcommands), "\n"))
|
||||||
|
p.escaper(codelite.esc)
|
||||||
else
|
else
|
||||||
_p(4, '<PostConnectCommands/>')
|
_p(4, '<PostConnectCommands/>')
|
||||||
end
|
end
|
||||||
if #cfg.debugstartupcommands > 0 then
|
if #cfg.debugstartupcommands > 0 then
|
||||||
|
p.escaper(codelite.escElementText)
|
||||||
_p(4, '<StartupCommands>%s</StartupCommands>', table.concat(p.esc(cfg.debugstartupcommands), "\n"))
|
_p(4, '<StartupCommands>%s</StartupCommands>', table.concat(p.esc(cfg.debugstartupcommands), "\n"))
|
||||||
|
p.escaper(codelite.esc)
|
||||||
else
|
else
|
||||||
_p(4, '<StartupCommands/>')
|
_p(4, '<StartupCommands/>')
|
||||||
end
|
end
|
||||||
@ -316,9 +322,11 @@
|
|||||||
if #cfg.prebuildcommands > 0 then
|
if #cfg.prebuildcommands > 0 then
|
||||||
_p(3, '<PreBuild>')
|
_p(3, '<PreBuild>')
|
||||||
local commands = os.translateCommandsAndPaths(cfg.prebuildcommands, cfg.project.basedir, cfg.project.location)
|
local commands = os.translateCommandsAndPaths(cfg.prebuildcommands, cfg.project.basedir, cfg.project.location)
|
||||||
|
p.escaper(codelite.escElementText)
|
||||||
for _, command in ipairs(commands) do
|
for _, command in ipairs(commands) do
|
||||||
_x(4, '<Command Enabled="yes">%s</Command>', command)
|
_x(4, '<Command Enabled="yes">%s</Command>', command)
|
||||||
end
|
end
|
||||||
|
p.escaper(codelite.esc)
|
||||||
_p(3, '</PreBuild>')
|
_p(3, '</PreBuild>')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -327,9 +335,11 @@
|
|||||||
if #cfg.postbuildcommands > 0 then
|
if #cfg.postbuildcommands > 0 then
|
||||||
_p(3, '<PostBuild>')
|
_p(3, '<PostBuild>')
|
||||||
local commands = os.translateCommandsAndPaths(cfg.postbuildcommands, cfg.project.basedir, cfg.project.location)
|
local commands = os.translateCommandsAndPaths(cfg.postbuildcommands, cfg.project.basedir, cfg.project.location)
|
||||||
|
p.escaper(codelite.escElementText)
|
||||||
for _, command in ipairs(commands) do
|
for _, command in ipairs(commands) do
|
||||||
_x(4, '<Command Enabled="yes">%s</Command>', command)
|
_x(4, '<Command Enabled="yes">%s</Command>', command)
|
||||||
end
|
end
|
||||||
|
p.escaper(codelite.esc)
|
||||||
_p(3, '</PostBuild>')
|
_p(3, '</PostBuild>')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -68,13 +68,15 @@
|
|||||||
end
|
end
|
||||||
|
|
||||||
function suite.OnProjectCfg_Defines()
|
function suite.OnProjectCfg_Defines()
|
||||||
defines { "TEST", "DEF" }
|
defines { "TEST", "DEF", "VAL=1", "ESCAPE=\"WITH SPACE\"" }
|
||||||
prepare()
|
prepare()
|
||||||
codelite.project.compiler(cfg)
|
codelite.project.compiler(cfg)
|
||||||
test.capture [[
|
test.capture [[
|
||||||
<Compiler Options="" C_Options="" Assembler="" Required="yes" PreCompiledHeader="" PCHInCommandLine="no" UseDifferentPCHFlags="no" PCHFlags="">
|
<Compiler Options="" C_Options="" Assembler="" Required="yes" PreCompiledHeader="" PCHInCommandLine="no" UseDifferentPCHFlags="no" PCHFlags="">
|
||||||
<Preprocessor Value="TEST"/>
|
<Preprocessor Value="TEST"/>
|
||||||
<Preprocessor Value="DEF"/>
|
<Preprocessor Value="DEF"/>
|
||||||
|
<Preprocessor Value="VAL=1"/>
|
||||||
|
<Preprocessor Value="ESCAPE=\"WITH\ SPACE\""/>
|
||||||
</Compiler>
|
</Compiler>
|
||||||
]]
|
]]
|
||||||
end
|
end
|
||||||
@ -154,6 +156,17 @@
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function suite.OnProjectCfg_EnvironmentEscaping()
|
||||||
|
debugenvs { "\"ENV\"=<&>" }
|
||||||
|
prepare()
|
||||||
|
codelite.project.environment(cfg)
|
||||||
|
test.capture(
|
||||||
|
' <Environment EnvVarSetName="<Use Defaults>" DbgSetName="<Use Defaults>">\n' ..
|
||||||
|
' <![CDATA["ENV"=<&>]]>\n' ..
|
||||||
|
' </Environment>'
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
function suite.OnProjectCfg_Debugger()
|
function suite.OnProjectCfg_Debugger()
|
||||||
prepare()
|
prepare()
|
||||||
codelite.project.debugger(cfg)
|
codelite.project.debugger(cfg)
|
||||||
@ -187,7 +200,25 @@ cmd2</StartupCommands>
|
|||||||
]]
|
]]
|
||||||
end
|
end
|
||||||
|
|
||||||
function suite.OnProject_PreBuild()
|
function suite.OnProjectCfg_DebuggerOptsEscaping()
|
||||||
|
debugremotehost "localhost"
|
||||||
|
debugport(2345)
|
||||||
|
debugextendedprotocol(true)
|
||||||
|
debugsearchpaths { "\"search\" && <path>" }
|
||||||
|
debugconnectcommands { "\"connect\" && <cmd>" }
|
||||||
|
debugstartupcommands { "\"start\" && <cmd>" }
|
||||||
|
prepare()
|
||||||
|
codelite.project.debugger(cfg)
|
||||||
|
test.capture [[
|
||||||
|
<Debugger IsRemote="yes" RemoteHostName="localhost" RemoteHostPort="2345" DebuggerPath="" IsExtended="yes">
|
||||||
|
<DebuggerSearchPaths>"search" && <path></DebuggerSearchPaths>
|
||||||
|
<PostConnectCommands>"connect" && <cmd></PostConnectCommands>
|
||||||
|
<StartupCommands>"start" && <cmd></StartupCommands>
|
||||||
|
</Debugger>
|
||||||
|
]]
|
||||||
|
end
|
||||||
|
|
||||||
|
function suite.OnProjectCfg_PreBuild()
|
||||||
prebuildcommands { "cmd0", "cmd1" }
|
prebuildcommands { "cmd0", "cmd1" }
|
||||||
prepare()
|
prepare()
|
||||||
codelite.project.preBuild(prj)
|
codelite.project.preBuild(prj)
|
||||||
@ -199,7 +230,7 @@ cmd2</StartupCommands>
|
|||||||
]]
|
]]
|
||||||
end
|
end
|
||||||
|
|
||||||
function suite.OnProject_PreBuild_Escaped()
|
function suite.OnProjectCfg_PreBuild_Escaped()
|
||||||
prebuildcommands {
|
prebuildcommands {
|
||||||
"touch \"./build/copyright\" && echo OK",
|
"touch \"./build/copyright\" && echo OK",
|
||||||
"cat \"./lib/copyright\" >> \"./build/copyright\""
|
"cat \"./lib/copyright\" >> \"./build/copyright\""
|
||||||
@ -214,7 +245,7 @@ cmd2</StartupCommands>
|
|||||||
]]
|
]]
|
||||||
end
|
end
|
||||||
|
|
||||||
function suite.OnProject_PostBuild()
|
function suite.OnProjectCfg_PostBuild()
|
||||||
postbuildcommands { "cmd0", "cmd1" }
|
postbuildcommands { "cmd0", "cmd1" }
|
||||||
prepare()
|
prepare()
|
||||||
codelite.project.postBuild(prj)
|
codelite.project.postBuild(prj)
|
||||||
@ -226,7 +257,7 @@ cmd2</StartupCommands>
|
|||||||
]]
|
]]
|
||||||
end
|
end
|
||||||
|
|
||||||
function suite.OnProject_PostBuild_Escaped()
|
function suite.OnProjectCfg_PostBuild_Escaped()
|
||||||
postbuildcommands {
|
postbuildcommands {
|
||||||
"touch \"./build/copyright\" && echo OK",
|
"touch \"./build/copyright\" && echo OK",
|
||||||
"cat \"./lib/copyright\" >> \"./build/copyright\""
|
"cat \"./lib/copyright\" >> \"./build/copyright\""
|
||||||
@ -244,7 +275,7 @@ cmd2</StartupCommands>
|
|||||||
-- TODO: test custom build
|
-- TODO: test custom build
|
||||||
|
|
||||||
|
|
||||||
function suite.OnProject_AdditionalRules()
|
function suite.OnProjectCfg_AdditionalRules()
|
||||||
prepare()
|
prepare()
|
||||||
codelite.project.additionalRules(prj)
|
codelite.project.additionalRules(prj)
|
||||||
test.capture [[
|
test.capture [[
|
||||||
@ -255,7 +286,7 @@ cmd2</StartupCommands>
|
|||||||
]]
|
]]
|
||||||
end
|
end
|
||||||
|
|
||||||
function suite.OnProject_Completion()
|
function suite.OnProjectCfg_Completion()
|
||||||
language "C++"
|
language "C++"
|
||||||
cppdialect "C++11"
|
cppdialect "C++11"
|
||||||
prepare()
|
prepare()
|
||||||
@ -270,11 +301,6 @@ cmd2</StartupCommands>
|
|||||||
]]
|
]]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
---------------------------------------------------------------------------
|
|
||||||
-- Setup/Teardown
|
|
||||||
---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
function suite.OnProjectCfg_UnsignedCharOn()
|
function suite.OnProjectCfg_UnsignedCharOn()
|
||||||
unsignedchar "On"
|
unsignedchar "On"
|
||||||
prepare()
|
prepare()
|
||||||
|
Reference in New Issue
Block a user