Fixed handling of architectures, including .NET "Any CPU", in VS 2005+ solutions

This commit is contained in:
Jason Perkins 2012-09-25 10:03:21 -04:00
parent 1bdf2f2e31
commit a4d67cea10
4 changed files with 98 additions and 82 deletions

View File

@ -201,8 +201,9 @@
end
arch = arch or vstudio.vs200x_architectures[cfg.architecture] or
vstudio.vs200x_architectures[cfg.system] or "Win32"
vstudio.vs200x_architectures[cfg.system]
arch = arch or iif(premake.isdotnetproject(cfg.project), "Any CPU", "Win32")
return arch
end

View File

@ -1,60 +0,0 @@
--
-- tests/actions/vstudio/sln2005/projectplatforms.lua
-- Validate generation of Visual Studio 2005+ ProjectConfigurationPlatforms block.
-- Copyright (c) 2009-2011 Jason Perkins and the Premake project
--
T.vstudio_sln2005_projectplatforms = { }
local suite = T.vstudio_sln2005_projectplatforms
local sln2005 = premake.vstudio.sln2005
--
-- Setup
--
local sln, prj
function suite.setup()
sln, prj = test.createsolution()
uuid "C9135098-6047-8142-B10E-D27E7F73FCB3"
end
local function prepare(language)
prj.language = language
premake.bake.buildconfigs()
sln.vstudio_configs = premake.vstudio.buildconfigs(sln)
sln2005.project_platforms(sln)
end
function suite.ProjectPlatforms_OnMixedLanguages()
_ACTION = "vs2005"
test.createproject(sln)
uuid "AE61726D-187C-E440-BD07-2556188A6565"
prepare("C#")
test.capture [[
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Debug|Win32.ActiveCfg = Debug|Any CPU
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Release|Any CPU.Build.0 = Release|Any CPU
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Release|Win32.ActiveCfg = Release|Any CPU
{AE61726D-187C-E440-BD07-2556188A6565}.Debug|Any CPU.ActiveCfg = Debug|Win32
{AE61726D-187C-E440-BD07-2556188A6565}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
{AE61726D-187C-E440-BD07-2556188A6565}.Debug|Mixed Platforms.Build.0 = Debug|Win32
{AE61726D-187C-E440-BD07-2556188A6565}.Debug|Win32.ActiveCfg = Debug|Win32
{AE61726D-187C-E440-BD07-2556188A6565}.Debug|Win32.Build.0 = Debug|Win32
{AE61726D-187C-E440-BD07-2556188A6565}.Release|Any CPU.ActiveCfg = Release|Win32
{AE61726D-187C-E440-BD07-2556188A6565}.Release|Mixed Platforms.ActiveCfg = Release|Win32
{AE61726D-187C-E440-BD07-2556188A6565}.Release|Mixed Platforms.Build.0 = Release|Win32
{AE61726D-187C-E440-BD07-2556188A6565}.Release|Win32.ActiveCfg = Release|Win32
{AE61726D-187C-E440-BD07-2556188A6565}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
]]
end

View File

@ -22,20 +22,19 @@
end
local function prepare()
local function prepare(lang)
prj = project("MyProject")
uuid "C9135098-6047-8142-B10E-D27E7F73FCB3"
language "C++"
language (lang or "C++")
sln2005.projectConfigurationPlatforms(sln)
end
--
-- Check the basic form of C++ solution/project mapping: only the specified build
-- configurations should be listed, and the architecture should default to Win32.
-- Check the mappings when no platforms and no architectures are specified.
--
function suite.buildCfgAndWin32Used_onNoPlatformsSet()
function suite.onCpp_noPlatforms_noArch()
prepare()
test.capture [[
GlobalSection(ProjectConfigurationPlatforms) = postSolution
@ -47,14 +46,44 @@
]]
end
function suite.onCs_noPlatforms_noArch()
prepare("C#")
test.capture [[
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
]]
end
function suite.onMixedLanguage_noPlatforms_noArch()
project("MyProject2")
language "C#"
uuid "52AD9329-0D74-4F66-A213-E649D8CCD737"
prepare()
test.capture [[
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{52AD9329-0D74-4F66-A213-E649D8CCD737}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{52AD9329-0D74-4F66-A213-E649D8CCD737}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{52AD9329-0D74-4F66-A213-E649D8CCD737}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{52AD9329-0D74-4F66-A213-E649D8CCD737}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Debug|Mixed Platforms.Build.0 = Debug|Win32
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Release|Mixed Platforms.ActiveCfg = Release|Win32
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Release|Mixed Platforms.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
-- platform. Win32 should be the default architecture.
-- When a platform is specified, it should be appended to the build
-- configurations to create a unique project platform name.
--
function suite.buildCfgAndPlatformUsed_onPlatformsSet()
function suite.onCpp_withPlatforms_noArch()
platforms { "Static" }
prepare()
test.capture [[
@ -67,20 +96,53 @@
]]
end
function suite.onCs_withPlatforms_noArch()
platforms { "Static" }
prepare("C#")
test.capture [[
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Debug|Static.ActiveCfg = Debug Static|Any CPU
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Debug|Static.Build.0 = Debug Static|Any CPU
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Release|Static.ActiveCfg = Release Static|Any CPU
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Release|Static.Build.0 = Release Static|Any CPU
EndGlobalSection
]]
end
function suite.onMixedLanguage_withPlatforms_noArch()
platforms { "Static" }
project("MyProject2")
language "C#"
uuid "52AD9329-0D74-4F66-A213-E649D8CCD737"
prepare()
test.capture [[
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{52AD9329-0D74-4F66-A213-E649D8CCD737}.Debug|Static.ActiveCfg = Debug Static|Any CPU
{52AD9329-0D74-4F66-A213-E649D8CCD737}.Debug|Static.Build.0 = Debug Static|Any CPU
{52AD9329-0D74-4F66-A213-E649D8CCD737}.Release|Static.ActiveCfg = Release Static|Any CPU
{52AD9329-0D74-4F66-A213-E649D8CCD737}.Release|Static.Build.0 = Release Static|Any CPU
{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" }
function suite.projectArch_on32()
architecture "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
{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
@ -90,15 +152,15 @@
-- The x64 architecture should remain "x64".
--
function suite.buildCfgAndWin32Used_onNoPlatformsSet()
platforms { "x64" }
function suite.projectArch_on64()
architecture "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
{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|x64.ActiveCfg = Release|x64
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Release|x64.Build.0 = Release|x64
EndGlobalSection
]]
end

View File

@ -113,6 +113,19 @@
]]
end
function suite.buildCfgAndPlatformUsed_onPlatformsSet_onMixedLanguage()
platforms { "Static" }
project("MyProject2")
language "C++"
prepare("C#")
test.capture [[
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Static = Debug|Static
Release|Static = Release|Static
EndGlobalSection
]]
end
--
-- When multiple platforms are provided, the sort order should match Visual Studio.