Modernize the VC# user file exporter

This commit is contained in:
Jason Perkins 2015-03-11 15:52:51 -04:00
parent 2fdddbee85
commit 058f1a4916
4 changed files with 23 additions and 22 deletions

View File

@ -1,52 +1,55 @@
--
-- vs2005_csproj_user.lua
-- Generate a Visual Studio 2005/2008 C# .user file.
-- Copyright (c) 2009-2014 Jason Perkins and the Premake project
-- Copyright (c) 2009-2015 Jason Perkins and the Premake project
--
local p = premake
local cs2005 = p.vstudio.cs2005
local project = p.project
local m = p.vstudio.cs2005
--
-- Generate a Visual Studio 200x C# user file, with support for the new platforms API.
-- Generate a Visual Studio 200x C# user file.
--
function cs2005.generateUser(prj)
function m.generateUser(prj)
p.vstudio.projectElement()
_p(1,'<PropertyGroup>')
p.push('<PropertyGroup>')
-- Per-configuration reference paths aren't supported (are they?) so just
-- use the first configuration in the project
local cfg = project.getfirstconfig(prj)
local cfg = p.project.getfirstconfig(prj)
local refpaths = path.translate(project.getrelative(prj, cfg.libdirs))
_p(2,'<ReferencePath>%s</ReferencePath>', table.concat(refpaths, ";"))
local refpaths = path.translate(p.project.getrelative(prj, cfg.libdirs))
p.w('<ReferencePath>%s</ReferencePath>', table.concat(refpaths, ";"))
_p(' </PropertyGroup>')
p.pop('</PropertyGroup>')
for cfg in project.eachconfig(prj) do
for cfg in p.project.eachconfig(prj) do
local contents = p.capture(function()
cs2005.debugsettings(cfg)
p.push()
m.debugsettings(cfg)
p.pop()
end)
if #contents > 0 then
_p(1,'<PropertyGroup %s>', cs2005.condition(cfg))
p.push('<PropertyGroup %s>', m.condition(cfg))
p.outln(contents)
_p(1,'</PropertyGroup>')
p.pop('</PropertyGroup>')
end
end
_p('</Project>')
p.outln('</Project>')
end
function cs2005.debugsettings(cfg)
cs2005.localDebuggerCommandArguments(cfg)
function m.debugsettings(cfg)
m.localDebuggerCommandArguments(cfg)
end
function cs2005.localDebuggerCommandArguments(cfg)
function m.localDebuggerCommandArguments(cfg)
if #cfg.debugargs > 0 then
_x(2,'<StartArguments>%s</StartArguments>', table.concat(cfg.debugargs, " "))
p.x('<StartArguments>%s</StartArguments>', table.concat(cfg.debugargs, " "))
end
end

View File

@ -70,7 +70,7 @@
cs2005.debugsettings(cfg)
test.capture [[
<StartArguments>foobar</StartArguments>
<StartArguments>foobar</StartArguments>
]]
end

View File

@ -6,7 +6,6 @@
local suite = test.declare("vstudio_vs200x_user_file")
local vc200x = premake.vstudio.vc200x
local project = premake.project
--

View File

@ -6,7 +6,6 @@
local suite = test.declare("vstudio_vs2010_user_file")
local vc2010 = premake.vstudio.vc2010
local project = premake.project
--