diff --git a/src/actions/vstudio/_vstudio.lua b/src/actions/vstudio/_vstudio.lua index 7235db67..c4bfe787 100644 --- a/src/actions/vstudio/_vstudio.lua +++ b/src/actions/vstudio/_vstudio.lua @@ -52,8 +52,10 @@ -- function vstudio.architecture(cfg) - local architecture = cfg.architecture or "Win32" - return architecture + if cfg.architecture == "x32" then + return "Win32" + end + return cfg.architecture or "Win32" end diff --git a/src/actions/vstudio/vs200x_vcproj.lua b/src/actions/vstudio/vs200x_vcproj.lua index f6d8e84b..e7dcce9c 100644 --- a/src/actions/vstudio/vs200x_vcproj.lua +++ b/src/actions/vstudio/vs200x_vcproj.lua @@ -10,6 +10,7 @@ -- premake.vstudio.vc200x = { } + local vstudio = premake.vstudio local vc200x = premake.vstudio.vc200x local tree = premake.tree @@ -72,7 +73,41 @@ -- -- Write out the element. -- + + function vc200x.configuration(cfg) + _p(2,'') + end + + -- TODO: REMOVE, OBSOLETE function vc200x.Configuration(name, cfg) _p(2,' element; ensures that each target platform --- is listed only once. Skips over .NET's pseudo-platforms (like "Any CPU"). +-- Write out the element, listing each architecture used +-- by the project's configurations. -- + function vc200x.platforms(prj) + _p(1,'') + + architectures = { } + for cfg in premake5.project.eachconfig(prj) do + local arch = vstudio.architecture(cfg) + if not architectures[arch] then + _p(2,'') + architectures[arch] = true + end + end + + _p(1,'') + end + + -- TODO: REMOVE, OBSOLETE function vc200x.Platforms(prj) local used = { } _p(1,'') @@ -805,4 +858,18 @@ end +-- +-- Enumerate the project's configurations. +-- + function vc200x.configurations(prj) + _p(1,'') + for cfg in premake5.project.eachconfig(prj) do + -- write the opening element + vc200x.configuration(cfg) + + + _p(2,'') + end + _p(1,'') + end diff --git a/tests/actions/vstudio/sln2005/test_project_platforms.lua b/tests/actions/vstudio/sln2005/test_project_platforms.lua index 6f3222e8..21850407 100755 --- a/tests/actions/vstudio/sln2005/test_project_platforms.lua +++ b/tests/actions/vstudio/sln2005/test_project_platforms.lua @@ -32,19 +32,19 @@ -- configurations should be listed, and the architecture should default to Win32. -- - function suite.buildCfgAndWin32Used_onNoPlatformsSet() - prepare() - test.capture [[ - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {C9135098-6047-8142-B10E-D27E7F73FCB3}.Debug|Win32.ActiveCfg = Debug|Win32 - {C9135098-6047-8142-B10E-D27E7F73FCB3}.Debug|Win32.Build.0 = Debug|Win32 - {C9135098-6047-8142-B10E-D27E7F73FCB3}.Release|Win32.ActiveCfg = Release|Win32 - {C9135098-6047-8142-B10E-D27E7F73FCB3}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - ]] - end - - + function suite.buildCfgAndWin32Used_onNoPlatformsSet() + prepare() + test.capture [[ + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {C9135098-6047-8142-B10E-D27E7F73FCB3}.Debug|Win32.ActiveCfg = Debug|Win32 + {C9135098-6047-8142-B10E-D27E7F73FCB3}.Debug|Win32.Build.0 = Debug|Win32 + {C9135098-6047-8142-B10E-D27E7F73FCB3}.Release|Win32.ActiveCfg = Release|Win32 + {C9135098-6047-8142-B10E-D27E7F73FCB3}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + ]] + end + + -- -- When a platform is specified, it should be listed instead of the default Win32 -- in the solution platform. Solution platforms should map to the correct project @@ -55,47 +55,47 @@ platforms { "Static" } prepare() test.capture [[ - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {C9135098-6047-8142-B10E-D27E7F73FCB3}.Debug|Static.ActiveCfg = Debug Static|Win32 - {C9135098-6047-8142-B10E-D27E7F73FCB3}.Debug|Static.Build.0 = Debug Static|Win32 - {C9135098-6047-8142-B10E-D27E7F73FCB3}.Release|Static.ActiveCfg = Release Static|Win32 - {C9135098-6047-8142-B10E-D27E7F73FCB3}.Release|Static.Build.0 = Release Static|Win32 - EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {C9135098-6047-8142-B10E-D27E7F73FCB3}.Debug|Static.ActiveCfg = Debug Static|Win32 + {C9135098-6047-8142-B10E-D27E7F73FCB3}.Debug|Static.Build.0 = Debug Static|Win32 + {C9135098-6047-8142-B10E-D27E7F73FCB3}.Release|Static.ActiveCfg = Release Static|Win32 + {C9135098-6047-8142-B10E-D27E7F73FCB3}.Release|Static.Build.0 = Release Static|Win32 + EndGlobalSection ]] end - - + + -- -- The x32 architecture should get mapped to "Win32". -- - function suite.buildCfgAndWin32Used_onNoPlatformsSet() - platforms { "x32" } - prepare() - test.capture [[ - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {C9135098-6047-8142-B10E-D27E7F73FCB3}.Debug|x32.ActiveCfg = Debug x32|Win32 - {C9135098-6047-8142-B10E-D27E7F73FCB3}.Debug|x32.Build.0 = Debug x32|Win32 - {C9135098-6047-8142-B10E-D27E7F73FCB3}.Release|x32.ActiveCfg = Release x32|Win32 - {C9135098-6047-8142-B10E-D27E7F73FCB3}.Release|x32.Build.0 = Release x32|Win32 - EndGlobalSection - ]] - end - - + function suite.buildCfgAndWin32Used_onNoPlatformsSet() + platforms { "x32" } + prepare() + test.capture [[ + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {C9135098-6047-8142-B10E-D27E7F73FCB3}.Debug|x32.ActiveCfg = Debug x32|Win32 + {C9135098-6047-8142-B10E-D27E7F73FCB3}.Debug|x32.Build.0 = Debug x32|Win32 + {C9135098-6047-8142-B10E-D27E7F73FCB3}.Release|x32.ActiveCfg = Release x32|Win32 + {C9135098-6047-8142-B10E-D27E7F73FCB3}.Release|x32.Build.0 = Release x32|Win32 + EndGlobalSection + ]] + end + + -- -- The x64 architecture should remain "x64". -- - function suite.buildCfgAndWin32Used_onNoPlatformsSet() - platforms { "x64" } - prepare() - test.capture [[ - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {C9135098-6047-8142-B10E-D27E7F73FCB3}.Debug|x64.ActiveCfg = Debug x64|x64 - {C9135098-6047-8142-B10E-D27E7F73FCB3}.Debug|x64.Build.0 = Debug x64|x64 - {C9135098-6047-8142-B10E-D27E7F73FCB3}.Release|x64.ActiveCfg = Release x64|x64 - {C9135098-6047-8142-B10E-D27E7F73FCB3}.Release|x64.Build.0 = Release x64|x64 - EndGlobalSection - ]] - end + function suite.buildCfgAndWin32Used_onNoPlatformsSet() + platforms { "x64" } + prepare() + test.capture [[ + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {C9135098-6047-8142-B10E-D27E7F73FCB3}.Debug|x64.ActiveCfg = Debug x64|x64 + {C9135098-6047-8142-B10E-D27E7F73FCB3}.Debug|x64.Build.0 = Debug x64|x64 + {C9135098-6047-8142-B10E-D27E7F73FCB3}.Release|x64.ActiveCfg = Release x64|x64 + {C9135098-6047-8142-B10E-D27E7F73FCB3}.Release|x64.Build.0 = Release x64|x64 + EndGlobalSection + ]] + end diff --git a/tests/actions/vstudio/test_vs200x_vcproj.lua b/tests/actions/vstudio/test_vs200x_vcproj.lua index 4d57bbde..b30824dd 100644 --- a/tests/actions/vstudio/test_vs200x_vcproj.lua +++ b/tests/actions/vstudio/test_vs200x_vcproj.lua @@ -235,46 +235,6 @@ end --- --- Test multiple platforms --- - - function suite.Platforms_OnMultiplePlatforms() - platforms { "x32", "x64" } - prepare() - - vc200x.generate(prj) - local result = io.endcapture() - test.istrue(result:find ' - - - - ]] - end - - - -- -- Test Xbox360 handling -- diff --git a/tests/actions/vstudio/vc200x/test_configuration.lua b/tests/actions/vstudio/vc200x/test_configuration.lua new file mode 100755 index 00000000..de91b7c3 --- /dev/null +++ b/tests/actions/vstudio/vc200x/test_configuration.lua @@ -0,0 +1,74 @@ +-- +-- tests/actions/vstudio/vc200x/test_configuration.lua +-- Test the Visual Studio 2002-2008 project's Configuration block +-- Copyright (c) 2009-2012 Jason Perkins and the Premake project +-- + + T.vstudio_vc200x_configuration = { } + local suite = T.vstudio_vc200x_configuration + local vc200x = premake.vstudio.vc200x + + +-- +-- Setup +-- + + local sln, prj + + function suite.setup() + _ACTION = "vs2008" + sln, prj = test.createsolution() + end + + local function prepare() + local it = premake5.project.eachconfig(prj) + local cfg = it() + vc200x.configuration(cfg) + end + + +-- +-- Check the results of generating with the default project settings +-- (C++ console application). +-- + + function suite.defaultSettings() + prepare() + test.capture [[ + + ]] + end + + +-- +-- If a platform is specified, it should be included in the platform name. +-- + + function suite.usesWin32_onX32() + platforms { "x32" } + prepare() + test.capture [[ + + + + ]] + end + + +-- +-- If multiple configurations use the same architecture, it should +-- still only be listed once. +-- + + function suite.architectureListedOnlyOnce_onMultipleConfigurations() + platforms { "Static", "Dynamic" } + prepare() + test.capture [[ + + + + ]] + end + + +-- +-- If multiple architectures are used, they should all be listed. +-- + + function suite.allArchitecturesListed_onMultipleArchitectures() + platforms { "x32", "x64" } + prepare() + test.capture [[ + + + + + ]] + end diff --git a/tests/premake4.lua b/tests/premake4.lua index 2d73e744..6ba5ae85 100644 --- a/tests/premake4.lua +++ b/tests/premake4.lua @@ -104,10 +104,12 @@ dofile("actions/vstudio/vc200x/test_compiler_block.lua") dofile("actions/vstudio/vc200x/debugdir.lua") dofile("actions/vstudio/vc200x/header.lua") + dofile("actions/vstudio/vc200x/test_configuration.lua") dofile("actions/vstudio/vc200x/test_files.lua") dofile("actions/vstudio/vc200x/test_filters.lua") dofile("actions/vstudio/vc200x/test_linker_block.lua") dofile("actions/vstudio/vc200x/test_mfc.lua") + dofile("actions/vstudio/vc200x/test_platforms.lua") -- Visual Studio 2010 C/C++ projects dofile("actions/vstudio/vc2010/test_compile_settings.lua")