Port VC 200x user files to new indentation APIs, fix a few indentation bugs from previous commit

This commit is contained in:
Jason Perkins 2014-01-31 14:29:58 -05:00
parent 93949df3fc
commit 46e3a06330
5 changed files with 58 additions and 57 deletions

View File

@ -180,7 +180,7 @@
_p(3,'<Link>%s</Link>', path.translate(link))
end
if #contents > 0 then
io.printf("%s", contents)
_p("%s", contents)
end
_p(2,'</%s>', info.action)
else

View File

@ -103,6 +103,7 @@
if thisName == testName then
m.configuration(cfg)
m.tools(cfg)
p.pop('</Configuration>')
-- Otherwise, check the list of valid configurations I built
-- earlier. If this configuration is in the list, then I will
@ -113,10 +114,9 @@
elseif not isRealConfig[testName] then
-- this is a fake config to make VS happy
m.emptyConfiguration(cfg, arch)
p.pop('</Configuration>')
end
p.pop('</Configuration>')
end
end

View File

@ -4,32 +4,33 @@
-- Copyright (c) 2011-2013 Jason Perkins and the Premake project
--
local p = premake
local vstudio = premake.vstudio
local vc200x = premake.vstudio.vc200x
local project = premake.project
local project = p.project
local m = p.vstudio.vc200x
--
-- Generate a Visual Studio 200x C++ user file, with support for the new platforms API.
--
function vc200x.generate_user(prj)
vc200x.xmlElement()
_p('<VisualStudioUserFile')
_p(1,'ProjectType="Visual C++"')
vc200x.version()
_p(1,'ShowAllFiles="false"')
_p(1,'>')
function m.generate_user(prj)
m.xmlElement()
p.push('<VisualStudioUserFile')
p.w('ProjectType="Visual C++"')
m.version()
p.w('ShowAllFiles="false"')
p.w('>')
_p(1,'<Configurations>')
p.push('<Configurations>')
for cfg in project.eachconfig(prj) do
vc200x.userconfiguration(cfg)
vc200x.debugdir(cfg)
_p(2,'</Configuration>')
m.userconfiguration(cfg)
m.debugdir(cfg)
p.pop('</Configuration>')
end
_p(1,'</Configurations>')
_p('</VisualStudioUserFile>')
p.pop('</Configurations>')
p.pop('</VisualStudioUserFile>')
end
@ -38,10 +39,10 @@
-- build configuration/platform pairing.
--
function vc200x.userconfiguration(cfg)
_p(2,'<Configuration')
_x(3,'Name="%s"', vstudio.projectConfig(cfg))
_p(3,'>')
function m.userconfiguration(cfg)
p.push('<Configuration')
p.x('Name="%s"', vstudio.projectConfig(cfg))
p.w('>')
end
@ -49,29 +50,29 @@
-- Write out the debug settings for this project.
--
function vc200x.debugdir(cfg)
_p(3,'<DebugSettings')
function m.debugdir(cfg)
p.push('<DebugSettings')
if cfg.debugcommand then
local command = project.getrelative(cfg.project, cfg.debugcommand)
_x(4,'Command="%s"', path.translate(command))
p.x('Command="%s"', path.translate(command))
end
if cfg.debugdir then
local debugdir = project.getrelative(cfg.project, cfg.debugdir)
_x(4,'WorkingDirectory="%s"', path.translate(debugdir))
p.x('WorkingDirectory="%s"', path.translate(debugdir))
end
if #cfg.debugargs > 0 then
_x(4,'CommandArguments="%s"', table.concat(cfg.debugargs, " "))
p.x('CommandArguments="%s"', table.concat(cfg.debugargs, " "))
end
if #cfg.debugenvs > 0 then
_p(4,'Environment="%s"', table.concat(premake.esc(cfg.debugenvs), "&#x0A;"))
p.x('Environment="%s"', table.concat(cfg.debugenvs, "\n"))
if cfg.flags.DebugEnvsDontMerge then
_p(4,'EnvironmentMerge="false"')
p.x('EnvironmentMerge="false"')
end
end
_p(3,'/>')
p.pop('/>')
end

View File

@ -384,7 +384,7 @@
end)
if #contents > 0 then
_p(2,'<Lib>')
io.printf("%s", contents)
_p("%s", contents)
_p(2,'</Lib>')
end
end
@ -530,7 +530,7 @@
if #contents > 0 then
_x(2,'<ClCompile Include=\"%s\">', path.translate(file.relpath))
io.printf("%s", contents)
_p("%s", contents)
_p(2,'</ClCompile>')
else
_x(2,'<ClCompile Include=\"%s\" />', path.translate(file.relpath))

View File

@ -33,8 +33,8 @@
function suite.emptyBlock_onNoSettings()
prepare()
test.capture [[
<DebugSettings
/>
<DebugSettings
/>
]]
end
@ -49,9 +49,9 @@
debugcommand "bin/emulator.exe"
prepare()
test.capture [[
<DebugSettings
Command="..\bin\emulator.exe"
/>
<DebugSettings
Command="..\bin\emulator.exe"
/>
]]
end
@ -66,9 +66,9 @@
debugdir "bin/debug"
prepare()
test.capture [[
<DebugSettings
WorkingDirectory="..\bin\debug"
/>
<DebugSettings
WorkingDirectory="..\bin\debug"
/>
]]
end
@ -81,9 +81,9 @@
debugargs { "arg1", "arg2" }
prepare()
test.capture [[
<DebugSettings
CommandArguments="arg1 arg2"
/>
<DebugSettings
CommandArguments="arg1 arg2"
/>
]]
end
@ -96,9 +96,9 @@
debugenvs { "key=value" }
prepare()
test.capture [[
<DebugSettings
Environment="key=value"
/>
<DebugSettings
Environment="key=value"
/>
]]
end
@ -111,9 +111,9 @@
debugenvs { 'key="value"' }
prepare()
test.capture [[
<DebugSettings
Environment="key=&quot;value&quot;"
/>
<DebugSettings
Environment="key=&quot;value&quot;"
/>
]]
end
@ -127,9 +127,9 @@
debugenvs { "key=value", "foo=bar" }
prepare()
test.capture [[
<DebugSettings
Environment="key=value&#x0A;foo=bar"
/>
<DebugSettings
Environment="key=value&#x0A;foo=bar"
/>
]]
end
@ -144,9 +144,9 @@
flags { "DebugEnvsDontMerge" }
prepare()
test.capture [[
<DebugSettings
Environment="key=value"
EnvironmentMerge="false"
/>
<DebugSettings
Environment="key=value"
EnvironmentMerge="false"
/>
]]
end