More reconciliation with Visual Studio project formats:
- sort solution configurations by case-insensitive names - add trailing CR-LF to custom build steps - remove empty Filter attributes from folder filter elements
This commit is contained in:
parent
ff8d8029fd
commit
e0e4b23a5d
@ -131,26 +131,43 @@
|
||||
--
|
||||
|
||||
function sln2005.configurationPlatforms(sln)
|
||||
-- build a VS cfg descriptor for each solution configuration
|
||||
|
||||
-- Build a VS cfg descriptor for each solution configuration.
|
||||
|
||||
local slncfg = {}
|
||||
for cfg in solution.eachconfig(sln) do
|
||||
local platform = vstudio.solutionPlatform(cfg)
|
||||
slncfg[cfg] = string.format("%s|%s", cfg.buildcfg, platform)
|
||||
end
|
||||
|
||||
_p(1,'GlobalSection(SolutionConfigurationPlatforms) = preSolution')
|
||||
for cfg in solution.eachconfig(sln) do
|
||||
_p(2,'%s = %s', slncfg[cfg], slncfg[cfg])
|
||||
end
|
||||
_p(1,'EndGlobalSection')
|
||||
-- Make a working list of each solution configuration, and sort it into
|
||||
-- Visual Studio's desired ordering. If I don't this, Visual Studio will
|
||||
-- reshuffle everything on the first save.
|
||||
|
||||
_p(1,'GlobalSection(ProjectConfigurationPlatforms) = postSolution')
|
||||
local sorted = {}
|
||||
for cfg in solution.eachconfig(sln) do
|
||||
table.insert(sorted, cfg)
|
||||
end
|
||||
|
||||
table.sort(sorted, function(a,b)
|
||||
return slncfg[a]:lower() < slncfg[b]:lower()
|
||||
end)
|
||||
|
||||
-- Now use the sorted list to output the configuration maps.
|
||||
|
||||
_p(1,'GlobalSection(SolutionConfigurationPlatforms) = preSolution')
|
||||
table.foreachi(sorted, function (cfg)
|
||||
_p(2,'%s = %s', slncfg[cfg], slncfg[cfg])
|
||||
end)
|
||||
_p(1,"EndGlobalSection")
|
||||
|
||||
_p(1,"GlobalSection(ProjectConfigurationPlatforms) = postSolution")
|
||||
local tr = solution.grouptree(sln)
|
||||
tree.traverse(tr, {
|
||||
onleaf = function(n)
|
||||
local prj = n.project
|
||||
|
||||
for cfg in solution.eachconfig(sln) do
|
||||
table.foreachi(sorted, function (cfg)
|
||||
local prjcfg = project.getconfig(prj, cfg.buildcfg, cfg.platform)
|
||||
if prjcfg then
|
||||
local prjplatform = vstudio.projectPlatform(prjcfg)
|
||||
@ -159,10 +176,10 @@
|
||||
_p(2,'{%s}.%s.ActiveCfg = %s|%s', prj.uuid, slncfg[cfg], prjplatform, architecture)
|
||||
_p(2,'{%s}.%s.Build.0 = %s|%s', prj.uuid, slncfg[cfg], prjplatform, architecture)
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
})
|
||||
_p(1,'EndGlobalSection')
|
||||
_p(1,"EndGlobalSection")
|
||||
end
|
||||
|
||||
|
||||
|
@ -643,7 +643,7 @@
|
||||
_p(3,'<Tool')
|
||||
_p(4,'Name="%s"', name)
|
||||
if #steps > 0 then
|
||||
_x(4,'CommandLine="%s"', table.implode(steps, "", "", "\r\n"))
|
||||
_x(4,'CommandLine="%s"', table.implode(steps, "", "\r\n", ""))
|
||||
end
|
||||
_p(3,'/>')
|
||||
end
|
||||
@ -724,7 +724,6 @@
|
||||
onbranchenter = function(node, depth)
|
||||
_p(depth, '<Filter')
|
||||
_p(depth, '\tName="%s"', node.name)
|
||||
_p(depth, '\tFilter=""')
|
||||
_p(depth, '\t>')
|
||||
end,
|
||||
|
||||
|
@ -63,7 +63,7 @@
|
||||
|
||||
vc2010.import(prj)
|
||||
|
||||
_p('</Project>')
|
||||
io.printf('</Project>')
|
||||
end
|
||||
|
||||
|
||||
|
@ -351,7 +351,7 @@
|
||||
|
||||
-- If I'm building a list of link directories, include libdirs
|
||||
|
||||
if part == "directory" and kind == "all" then
|
||||
if part == "directory" then
|
||||
table.foreachi(cfg.libdirs, function(dir)
|
||||
table.insert(result, project.getrelative(cfg.project, dir))
|
||||
end)
|
||||
|
@ -1,7 +1,7 @@
|
||||
--
|
||||
-- tests/actions/vstudio/sln2005/test_platforms.lua
|
||||
-- Test the Visual Studio 2005-2010 platform mapping blocks.
|
||||
-- Copyright (c) 2009-2012 Jason Perkins and the Premake project
|
||||
-- Copyright (c) 2009-2013 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
T.vstudio_sln2005_platforms = { }
|
||||
@ -495,20 +495,20 @@
|
||||
prepare()
|
||||
test.capture [[
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x86 = Debug|x86
|
||||
Debug|x64 = Debug|x64
|
||||
Release|x86 = Release|x86
|
||||
Debug|x86 = Debug|x86
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Debug|x86.Build.0 = Debug|x86
|
||||
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Debug|x64.Build.0 = Debug|x64
|
||||
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Release|x86.ActiveCfg = Release|x86
|
||||
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Release|x86.Build.0 = Release|x86
|
||||
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Debug|x86.Build.0 = Debug|x86
|
||||
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Release|x64.ActiveCfg = Release|x64
|
||||
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Release|x64.Build.0 = Release|x64
|
||||
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Release|x86.ActiveCfg = Release|x86
|
||||
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Release|x86.Build.0 = Release|x86
|
||||
EndGlobalSection
|
||||
]]
|
||||
end
|
||||
@ -523,28 +523,28 @@
|
||||
prepare()
|
||||
test.capture [[
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x86 = Debug|x86
|
||||
Debug|x64 = Debug|x64
|
||||
Release|x86 = Release|x86
|
||||
Debug|x86 = Debug|x86
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{52AD9329-0D74-4F66-A213-E649D8CCD737}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{52AD9329-0D74-4F66-A213-E649D8CCD737}.Debug|x86.Build.0 = Debug|x86
|
||||
{52AD9329-0D74-4F66-A213-E649D8CCD737}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{52AD9329-0D74-4F66-A213-E649D8CCD737}.Debug|x64.Build.0 = Debug|x64
|
||||
{52AD9329-0D74-4F66-A213-E649D8CCD737}.Release|x86.ActiveCfg = Release|x86
|
||||
{52AD9329-0D74-4F66-A213-E649D8CCD737}.Release|x86.Build.0 = Release|x86
|
||||
{52AD9329-0D74-4F66-A213-E649D8CCD737}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{52AD9329-0D74-4F66-A213-E649D8CCD737}.Debug|x86.Build.0 = Debug|x86
|
||||
{52AD9329-0D74-4F66-A213-E649D8CCD737}.Release|x64.ActiveCfg = Release|x64
|
||||
{52AD9329-0D74-4F66-A213-E649D8CCD737}.Release|x64.Build.0 = Release|x64
|
||||
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Debug|x86.Build.0 = Debug|Win32
|
||||
{52AD9329-0D74-4F66-A213-E649D8CCD737}.Release|x86.ActiveCfg = Release|x86
|
||||
{52AD9329-0D74-4F66-A213-E649D8CCD737}.Release|x86.Build.0 = Release|x86
|
||||
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Debug|x64.Build.0 = Debug|x64
|
||||
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Release|x86.ActiveCfg = Release|Win32
|
||||
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Release|x86.Build.0 = Release|Win32
|
||||
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Debug|x86.Build.0 = Debug|Win32
|
||||
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Release|x64.ActiveCfg = Release|x64
|
||||
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Release|x64.Build.0 = Release|x64
|
||||
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Release|x86.ActiveCfg = Release|Win32
|
||||
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Release|x86.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
]]
|
||||
end
|
||||
@ -616,3 +616,32 @@
|
||||
EndGlobalSection
|
||||
]]
|
||||
end
|
||||
|
||||
|
||||
---
|
||||
-- Check the sort order of the configurations.
|
||||
---
|
||||
|
||||
function suite.sortsByBuildCfgAndPlatform()
|
||||
platforms { "Windows", "PS3" }
|
||||
project "MyProject"
|
||||
prepare()
|
||||
test.capture [[
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|PS3 = Debug|PS3
|
||||
Debug|Windows = Debug|Windows
|
||||
Release|PS3 = Release|PS3
|
||||
Release|Windows = Release|Windows
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Debug|PS3.ActiveCfg = Debug PS3|Win32
|
||||
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Debug|PS3.Build.0 = Debug PS3|Win32
|
||||
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Debug|Windows.ActiveCfg = Debug Windows|Win32
|
||||
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Debug|Windows.Build.0 = Debug Windows|Win32
|
||||
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Release|PS3.ActiveCfg = Release PS3|Win32
|
||||
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Release|PS3.Build.0 = Release PS3|Win32
|
||||
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Release|Windows.ActiveCfg = Release Windows|Win32
|
||||
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Release|Windows.Build.0 = Release Windows|Win32
|
||||
EndGlobalSection
|
||||
]]
|
||||
end
|
||||
|
54
tests/actions/vstudio/vc200x/test_build_steps.lua
Normal file
54
tests/actions/vstudio/vc200x/test_build_steps.lua
Normal file
@ -0,0 +1,54 @@
|
||||
--
|
||||
-- tests/actions/vstudio/vc200x/test_build_steps.lua
|
||||
-- Test generation of custom build step elements.
|
||||
-- Copyright (c) 2013 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
local suite = test.declare("vs200x_build_steps")
|
||||
local vc200x = premake.vstudio.vc200x
|
||||
|
||||
|
||||
--
|
||||
-- Setup/teardown
|
||||
--
|
||||
|
||||
local sln, prj, cfg
|
||||
|
||||
function suite.setup()
|
||||
sln, prj = test.createsolution()
|
||||
end
|
||||
|
||||
local function prepare()
|
||||
cfg = premake5.project.getconfig(prj, "Debug")
|
||||
vc200x.VCPreBuildEventTool(cfg)
|
||||
end
|
||||
|
||||
|
||||
---
|
||||
-- Should output empty element wrapper on no build steps.
|
||||
---
|
||||
|
||||
function suite.noCommandLine_onNoBuildSteps()
|
||||
prepare()
|
||||
test.capture [[
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
]]
|
||||
end
|
||||
|
||||
|
||||
---
|
||||
-- Should insert CR-LF at end of each command line.
|
||||
---
|
||||
|
||||
function suite.addsCRLF()
|
||||
prebuildcommands { "command_1", "command_2" }
|
||||
prepare()
|
||||
test.capture [[
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
CommandLine="command_1
command_2
"
|
||||
/>
|
||||
]]
|
||||
end
|
@ -54,7 +54,6 @@
|
||||
</File>
|
||||
<Filter
|
||||
Name="src"
|
||||
Filter=""
|
||||
>
|
||||
<File
|
||||
RelativePath="src\hello.cpp"
|
||||
@ -79,11 +78,9 @@
|
||||
</File>
|
||||
<Filter
|
||||
Name="src"
|
||||
Filter=""
|
||||
>
|
||||
<Filter
|
||||
Name="greetings"
|
||||
Filter=""
|
||||
>
|
||||
<File
|
||||
RelativePath="src\greetings\hello.cpp"
|
||||
@ -106,7 +103,6 @@
|
||||
test.capture [[
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter=""
|
||||
>
|
||||
<File
|
||||
RelativePath="src\hello.cpp"
|
||||
@ -322,7 +318,6 @@
|
||||
test.capture [[
|
||||
<Filter
|
||||
Name="greetings"
|
||||
Filter=""
|
||||
>
|
||||
<File
|
||||
RelativePath="greetings\hello.cpp"
|
||||
|
@ -113,6 +113,7 @@
|
||||
|
||||
-- Visual Studio 2002-2008 C/C++ projects
|
||||
dofile("actions/vstudio/vc200x/test_assembly_refs.lua")
|
||||
dofile("actions/vstudio/vc200x/test_build_steps.lua")
|
||||
dofile("actions/vstudio/vc200x/test_configuration.lua")
|
||||
dofile("actions/vstudio/vc200x/test_compiler_block.lua")
|
||||
dofile("actions/vstudio/vc200x/test_debug_settings.lua")
|
||||
|
Reference in New Issue
Block a user