--
-- vs2010_vcxproj_user.lua
-- Generate a Visual Studio 201x C/C++ project .user file
-- Copyright (c) Jason Perkins and the Premake project
--
local p = premake
local m = p.vstudio.vc2010
--
-- Generate a Visual Studio 201x C++ user file.
--
m.elements.user = function(cfg)
return {
m.debugSettings,
}
end
function m.generateUser(prj)
-- Only want output if there is something to configure
local contents = {}
local size = 0
for cfg in p.project.eachconfig(prj) do
contents[cfg] = p.capture(function()
p.push(2)
p.callArray(m.elements.user, cfg)
p.pop(2)
end)
size = size + #contents[cfg]
end
if size > 0 then
m.xmlDeclaration()
m.userProject()
for cfg in p.project.eachconfig(prj) do
p.push('', m.condition(cfg))
if #contents[cfg] > 0 then
p.outln(contents[cfg])
end
p.pop('')
end
p.pop('')
end
end
--
-- Output the opening tag.
--
function m.userProject()
local action = p.action.current()
p.push('',
action.vstudio.toolsVersion)
end
m.elements.debugSettings = function(cfg)
return {
m.localDebuggerCommand,
m.localDebuggerWorkingDirectory,
m.debuggerFlavor,
m.localDebuggerCommandArguments,
m.localDebuggerDebuggerType,
m.localDebuggerEnvironment,
m.localDebuggerMergeEnvironment,
}
end
function m.debugSettings(cfg)
p.callArray(m.elements.debugSettings, cfg)
end
function m.debuggerFlavor(cfg)
if cfg.debugdir or cfg.debugcommand then
p.w('WindowsLocalDebugger')
end
end
function m.localDebuggerCommand(cfg)
if cfg.debugcommand then
local dir = path.translate(cfg.debugcommand)
p.w('%s', dir)
end
end
function m.localDebuggerDebuggerType(cfg)
if cfg.debuggertype then
p.w('%s', cfg.debuggertype)
end
end
function m.localDebuggerCommandArguments(cfg)
if #cfg.debugargs > 0 then
local args = os.translateCommandsAndPaths(cfg.debugargs, cfg.project.basedir, cfg.project.location)
p.x('%s', table.concat(args, " "))
end
end
function m.localDebuggerWorkingDirectory(cfg)
if cfg.debugdir then
local dir = p.vstudio.path(cfg, cfg.debugdir)
p.x('%s', dir)
end
end
function m.localDebuggerEnvironment(cfg)
if #cfg.debugenvs > 0 then
local envs = table.concat(cfg.debugenvs, "\n")
if cfg.flags.DebugEnvsInherit then
envs = envs .. "\n$(LocalDebuggerEnvironment)"
end
p.w('%s', envs)
if cfg.flags.DebugEnvsDontMerge then
p.w(2,'false')
end
end
end
function m.localDebuggerMergeEnvironment(cfg)
if #cfg.debugenvs > 0 and cfg.flags.DebugEnvsDontMerge then
p.w(2,'false')
end
end