Only output VC'200x .user file if there is something to put in it
This commit is contained in:
parent
26fb3cb240
commit
2fdddbee85
@ -34,7 +34,12 @@
|
||||
premake.generate(prj, ".csproj.user", vstudio.cs2005.generateUser)
|
||||
elseif premake.project.iscpp(prj) then
|
||||
premake.generate(prj, ".vcproj", vstudio.vc200x.generate)
|
||||
premake.generate(prj, ".vcproj.user", vstudio.vc200x.generateUser)
|
||||
|
||||
-- Skip generation of empty user files
|
||||
local user = p.capture(function() vstudio.vc200x.generateUser(prj) end)
|
||||
if #user > 0 then
|
||||
p.generate(prj, ".vcproj.user", function() p.out(user) end)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -21,18 +21,38 @@
|
||||
|
||||
function m.generateUser(prj)
|
||||
p.indent("\t")
|
||||
m.xmlElement()
|
||||
m.visualStudioUserFile()
|
||||
|
||||
p.push('<Configurations>')
|
||||
-- Only want output if there is something to configure
|
||||
local contents = {}
|
||||
local generate = false
|
||||
|
||||
for cfg in p.project.eachconfig(prj) do
|
||||
m.userConfiguration(cfg)
|
||||
p.callArray(m.elements.user, cfg)
|
||||
p.pop('</Configuration>')
|
||||
contents[cfg] = p.capture(function()
|
||||
p.push(4)
|
||||
p.callArray(m.elements.user, cfg)
|
||||
p.pop(4)
|
||||
end)
|
||||
if #contents[cfg] > 0 then
|
||||
generate = true
|
||||
end
|
||||
end
|
||||
p.pop('</Configurations>')
|
||||
|
||||
p.pop('</VisualStudioUserFile>')
|
||||
if generate then
|
||||
m.xmlElement()
|
||||
m.visualStudioUserFile()
|
||||
p.push('<Configurations>')
|
||||
for cfg in p.project.eachconfig(prj) do
|
||||
m.userConfiguration(cfg)
|
||||
p.push('<DebugSettings')
|
||||
if #contents[cfg] > 0 then
|
||||
p.outln(contents[cfg])
|
||||
end
|
||||
p.pop('/>')
|
||||
p.pop('</Configuration>')
|
||||
end
|
||||
p.pop('</Configurations>')
|
||||
p.pop('</VisualStudioUserFile>')
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@ -78,9 +98,7 @@
|
||||
end
|
||||
|
||||
function m.debugSettings(cfg)
|
||||
p.push('<DebugSettings')
|
||||
p.callArray(m.elements.debugSettings, cfg)
|
||||
p.pop('/>')
|
||||
end
|
||||
|
||||
|
||||
|
@ -92,6 +92,7 @@ return {
|
||||
"actions/vstudio/vc200x/test_project.lua",
|
||||
"actions/vstudio/vc200x/test_project_refs.lua",
|
||||
"actions/vstudio/vc200x/test_resource_compiler.lua",
|
||||
"actions/vstudio/vc200x/test_user_file.lua",
|
||||
|
||||
-- Visual Studio 2010 C/C++ projects
|
||||
"actions/vstudio/vc2010/test_assembly_refs.lua",
|
||||
@ -116,9 +117,9 @@ return {
|
||||
"actions/vstudio/vc2010/test_project_configs.lua",
|
||||
"actions/vstudio/vc2010/test_project_refs.lua",
|
||||
"actions/vstudio/vc2010/test_prop_sheet.lua",
|
||||
"actions/vstudio/vc2010/test_user_file.lua",
|
||||
"actions/vstudio/vc2010/test_resource_compile.lua",
|
||||
"actions/vstudio/vc2010/test_rule_vars.lua",
|
||||
"actions/vstudio/vc2010/test_user_file.lua",
|
||||
|
||||
-- Makefile tests
|
||||
"actions/make/test_make_escaping.lua",
|
||||
|
@ -32,10 +32,7 @@
|
||||
|
||||
function suite.emptyBlock_onNoSettings()
|
||||
prepare()
|
||||
test.capture [[
|
||||
<DebugSettings
|
||||
/>
|
||||
]]
|
||||
test.isemptycapture()
|
||||
end
|
||||
|
||||
|
||||
@ -49,9 +46,7 @@
|
||||
debugcommand "bin/emulator.exe"
|
||||
prepare()
|
||||
test.capture [[
|
||||
<DebugSettings
|
||||
Command="..\bin\emulator.exe"
|
||||
/>
|
||||
Command="..\bin\emulator.exe"
|
||||
]]
|
||||
end
|
||||
|
||||
@ -66,9 +61,7 @@
|
||||
debugdir "bin/debug"
|
||||
prepare()
|
||||
test.capture [[
|
||||
<DebugSettings
|
||||
WorkingDirectory="..\bin\debug"
|
||||
/>
|
||||
WorkingDirectory="..\bin\debug"
|
||||
]]
|
||||
end
|
||||
|
||||
@ -81,9 +74,7 @@
|
||||
debugargs { "arg1", "arg2" }
|
||||
prepare()
|
||||
test.capture [[
|
||||
<DebugSettings
|
||||
CommandArguments="arg1 arg2"
|
||||
/>
|
||||
CommandArguments="arg1 arg2"
|
||||
]]
|
||||
end
|
||||
|
||||
@ -96,9 +87,7 @@
|
||||
debugenvs { "key=value" }
|
||||
prepare()
|
||||
test.capture [[
|
||||
<DebugSettings
|
||||
Environment="key=value"
|
||||
/>
|
||||
Environment="key=value"
|
||||
]]
|
||||
end
|
||||
|
||||
@ -111,9 +100,7 @@
|
||||
debugenvs { 'key="value"' }
|
||||
prepare()
|
||||
test.capture [[
|
||||
<DebugSettings
|
||||
Environment="key="value""
|
||||
/>
|
||||
Environment="key="value""
|
||||
]]
|
||||
end
|
||||
|
||||
@ -127,9 +114,7 @@
|
||||
debugenvs { "key=value", "foo=bar" }
|
||||
prepare()
|
||||
test.capture [[
|
||||
<DebugSettings
|
||||
Environment="key=value
foo=bar"
|
||||
/>
|
||||
Environment="key=value
foo=bar"
|
||||
]]
|
||||
end
|
||||
|
||||
@ -144,9 +129,7 @@
|
||||
flags { "DebugEnvsDontMerge" }
|
||||
prepare()
|
||||
test.capture [[
|
||||
<DebugSettings
|
||||
Environment="key=value"
|
||||
EnvironmentMerge="false"
|
||||
/>
|
||||
Environment="key=value"
|
||||
EnvironmentMerge="false"
|
||||
]]
|
||||
end
|
||||
|
49
tests/actions/vstudio/vc200x/test_user_file.lua
Normal file
49
tests/actions/vstudio/vc200x/test_user_file.lua
Normal file
@ -0,0 +1,49 @@
|
||||
--
|
||||
-- tests/actions/vstudio/vc200x/test_user_file.lua
|
||||
-- Verify handling of empty and non-empty .user files for VC'200x.
|
||||
-- Copyright (c) 2015 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
local suite = test.declare("vstudio_vs200x_user_file")
|
||||
local vc200x = premake.vstudio.vc200x
|
||||
local project = premake.project
|
||||
|
||||
|
||||
--
|
||||
-- Setup
|
||||
--
|
||||
|
||||
local sln
|
||||
|
||||
function suite.setup()
|
||||
_ACTION = "vs2008"
|
||||
sln = test.createsolution()
|
||||
end
|
||||
|
||||
local function prepare()
|
||||
local prj = test.getproject(sln, 1)
|
||||
vc200x.generateUser(prj)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- If no debugger settings have been specified, then the .user
|
||||
-- file should not be written at all.
|
||||
--
|
||||
|
||||
function suite.noOutput_onNoSettings()
|
||||
prepare()
|
||||
test.isemptycapture()
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- If a debugger setting has been specified, output.
|
||||
--
|
||||
|
||||
function suite.doesOutput_onDebugSettings()
|
||||
debugcommand "bin/emulator.exe"
|
||||
prepare()
|
||||
test.hasoutput()
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user