Commits

Jason Perkins committed 05f212d

Prevent duplicate config blocks in VC200x projects; clean up tests and remove old solution implementations

Comments (0)

Files changed (6)

src/actions/vstudio/vs2005_solution.lua

 
 
 --
--- Write out the contents of the SolutionConfigurationPlatforms section, which
--- lists all of the configuration/platform pairs that exist in the solution.
---
-
-	function sln2005.solutionConfigurationPlatforms(sln)
-		_p(1,'GlobalSection(SolutionConfigurationPlatforms) = preSolution')
-		for cfg in solution.eachconfig(sln) do
-			local ident = vstudio.solutionconfig(cfg)
-			_p(2,'%s = %s', ident, ident)
-		end
-		_p(1,'EndGlobalSection')
-	end
-
-
---
--- Write out the contents of the ProjectConfigurationPlatforms section, which maps
--- the configuration/platform pairs into each project of the solution.
---
-
-	function sln2005.projectConfigurationPlatforms(sln)
-		_p(1,'GlobalSection(ProjectConfigurationPlatforms) = postSolution')
-		for prj in solution.eachproject_ng(sln) do
-			for slncfg in solution.eachconfig(sln) do
-				local prjcfg = project.getconfig(prj, slncfg.buildcfg, slncfg.platform)
-				if prjcfg then
-					local slnident = vstudio.solutionconfig(slncfg)
-					local prjplatform = vstudio.projectPlatform(prjcfg)
-					local architecture = vstudio.archFromConfig(prjcfg)
-					
-					_p(2,'{%s}.%s.ActiveCfg = %s|%s', prj.uuid, slnident, prjplatform, architecture)
-					_p(2,'{%s}.%s.Build.0 = %s|%s', prj.uuid, slnident, prjplatform, architecture)
-				end
-			end		
-		end
-		_p(1,'EndGlobalSection')
-	end
-
-
---
 -- Write out contents of the SolutionProperties section; currently unused.
 --
 

src/actions/vstudio/vs200x_vcproj.lua

 
 		vc200x.xmldeclaration()
 		vc200x.visualStudioProject(prj)
+		
+		-- output the list of configuration/architecture pairs used by
+		-- the project; sends back list of unique architectures
 		local architectures = vc200x.platforms(prj)
 		
 		if _ACTION > "vs2003" then
 			_p(1,'</ToolFiles>')
 		end
 
+		-- Visual Studio requires each configuration to be paired up with each
+		-- architecture, even if the pairing doesn't make any sense (i.e. Win32
+		-- DLL DCRT|PS3). I already have a list of all the unique architectures;
+		-- make a list of configuration-architecture pairs used by the project.
+		local prjcfgs = {}
+		for cfg in project.eachconfig(prj) do
+			local cfgname = vstudio.projectConfig(cfg)
+			prjcfgs[cfgname] = cfgname
+		end
+		
 		_p(1,'<Configurations>')
 		for cfg in project.eachconfig(prj) do
-			-- Visual Studio requires each project configuration to have an
-			-- entry for every project architecture. Those that are not 
-			-- actually part of the solution, use a skeleton configuration.
-			local cfgarch = vstudio.archFromConfig(cfg, true)
-			for _, prjarch in ipairs(architectures) do
-				if cfgarch == prjarch then
+			local prjcfg = vstudio.projectConfig(cfg)
+			for _, arch in ipairs(architectures) do
+				local tstcfg = vstudio.projectConfig(cfg, arch)
+				if prjcfg == tstcfg then
+					-- this is a real project configuration
 					vc200x.configuration(cfg)
 					vc200x.tools(cfg)
 					_p(2,'</Configuration>')
-				else
+				elseif not prjcfgs[tstcfg] then
+					-- this is a fake config to make VS happy					
 					vc200x.emptyconfiguration(cfg, prjarch)
 				end
-			end
+			end		
 		end
 		_p(1,'</Configurations>')
 

tests/actions/vstudio/sln2005/test_platforms.lua

 --
 
 	function suite.onSingleCpp_withPlatformsMatchingArch_noArchs()
-		platforms { "x32", "x64" }
+		platforms { "x32", "Xbox360" }
 		project "MyProject"
 		prepare()
 		test.capture [[
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Win32 = Debug|Win32
-		Debug|x64 = Debug|x64
+		Debug|Xbox 360 = Debug|Xbox 360
 		Release|Win32 = Release|Win32
-		Release|x64 = Release|x64
+		Release|Xbox 360 = Release|Xbox 360
 	EndGlobalSection
 	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}.Debug|x64.ActiveCfg = Debug|x64
-		{C9135098-6047-8142-B10E-D27E7F73FCB3}.Debug|x64.Build.0 = Debug|x64
+		{C9135098-6047-8142-B10E-D27E7F73FCB3}.Debug|Xbox 360.ActiveCfg = Debug|Xbox 360
+		{C9135098-6047-8142-B10E-D27E7F73FCB3}.Debug|Xbox 360.Build.0 = Debug|Xbox 360
 		{C9135098-6047-8142-B10E-D27E7F73FCB3}.Release|Win32.ActiveCfg = Release|Win32
 		{C9135098-6047-8142-B10E-D27E7F73FCB3}.Release|Win32.Build.0 = Release|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|Xbox 360.ActiveCfg = Release|Xbox 360
+		{C9135098-6047-8142-B10E-D27E7F73FCB3}.Release|Xbox 360.Build.0 = Release|Xbox 360
 	EndGlobalSection
 		]]
 	end

tests/actions/vstudio/sln2005/test_project_platforms.lua

---
--- tests/actions/vstudio/sln2005/test_project_platforms.lua
--- Test the Visual Studio 2005-2010 ProjectConfigurationPlatforms block.
--- Copyright (c) 2009-2012 Jason Perkins and the Premake project
---
-
-	T.vstudio_sln2005_project_platforms = { }
-	local suite = T.vstudio_sln2005_project_platforms
-	local sln2005 = premake.vstudio.sln2005
-
-
---
--- Setup 
---
-
-	local sln, prj
-	
-	function suite.setup()
-		_ACTION = "vs2008"
-		sln = solution("MySolution")
-		configurations { "Debug", "Release" }
-		
-	end
-	
-	local function prepare(lang)
-		prj = project("MyProject")
-		uuid "C9135098-6047-8142-B10E-D27E7F73FCB3"
-		language (lang or "C++")
-		sln2005.projectConfigurationPlatforms(sln)
-	end
-
-
---
--- Check the mappings when no platforms and no architectures are specified.
---
-
-	function suite.onCpp_noPlatforms_noArch()
-		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.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 appended to the build 
--- configurations to create a unique project platform name.
---
-
-	function suite.onCpp_withPlatforms_noArch()
-		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
-		]]
-	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.projectArch_on32()
-		architecture "x32"
-		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
-
-
---
--- The x64 architecture should remain "x64".
---
-
-	function suite.projectArch_on64()
-		architecture "x64"
-		prepare()
-		test.capture [[
-	GlobalSection(ProjectConfigurationPlatforms) = postSolution
-		{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
-
-
---
--- Verify that solution-project configuration maps are correctly applied.
---
-
-	function suite.configIsMapped_onProjectConfigMapping()
-		configmap { ["Debug"] = "Development" }
-		prepare()
-		test.capture [[
-	GlobalSection(ProjectConfigurationPlatforms) = postSolution
-		{C9135098-6047-8142-B10E-D27E7F73FCB3}.Debug|Win32.ActiveCfg = Development|Win32
-		{C9135098-6047-8142-B10E-D27E7F73FCB3}.Debug|Win32.Build.0 = Development|Win32
-		{C9135098-6047-8142-B10E-D27E7F73FCB3}.Release|Win32.ActiveCfg = Release|Win32
-		{C9135098-6047-8142-B10E-D27E7F73FCB3}.Release|Win32.Build.0 = Release|Win32
-	EndGlobalSection
-		]]
-	end

tests/actions/vstudio/sln2005/test_solution_platforms.lua

---
--- tests/actions/vstudio/sln2005/test_solution_platforms.lua
--- Test the Visual Studio 2005-2010 SolutionConfigurationPlatforms block.
--- Copyright (c) 2009-2012 Jason Perkins and the Premake project
---
-
-	T.vstudio_sln2005_solution_platforms = { }
-	local suite = T.vstudio_sln2005_solution_platforms
-	local sln2005 = premake.vstudio.sln2005
-
-
---
--- Setup 
---
-
-	local sln, prj
-	
-	function suite.setup()
-		_ACTION = "vs2008"
-		sln = solution("MySolution")
-		configurations { "Debug", "Release" }
-	end
-	
-	local function prepare(lang)
-		prj = project("MyProject")
-		language (lang or "C++")
-		sln2005.solutionConfigurationPlatforms(sln)
-	end
-
-
---
--- If no platform or architecture is specified, default the appropriate
--- default for the language.
---
-
-	function suite.correctDefault_onCpp()
-		prepare("C++")
-		test.capture [[
-	GlobalSection(SolutionConfigurationPlatforms) = preSolution
-		Debug|Win32 = Debug|Win32
-		Release|Win32 = Release|Win32
-	EndGlobalSection
-		]]
-	end
-
-	function suite.correctDefault_onCs()
-		prepare("C#")
-		test.capture [[
-	GlobalSection(SolutionConfigurationPlatforms) = preSolution
-		Debug|Any CPU = Debug|Any CPU
-		Release|Any CPU = Release|Any CPU
-	EndGlobalSection
-		]]
-	end
-
-	function suite.correctDefault_onMixedLanguage()
-		project("MyProject2")
-		language "C++"
-		prepare("C#")
-		test.capture [[
-	GlobalSection(SolutionConfigurationPlatforms) = preSolution
-		Debug|Mixed Platforms = Debug|Mixed Platforms
-		Release|Mixed Platforms = Release|Mixed Platforms
-	EndGlobalSection
-		]]
-	end
-
-
---
--- If an architecture is specified, use it.
---
-
-	function suite.usesArch_onx32()
-		architecture "x32"
-		prepare()
-		test.capture [[
-	GlobalSection(SolutionConfigurationPlatforms) = preSolution
-		Debug|Win32 = Debug|Win32
-		Release|Win32 = Release|Win32
-	EndGlobalSection
-		]]
-	end
-
-	function suite.usesArch_onx64()
-		architecture "x64"
-		prepare()
-		test.capture [[
-	GlobalSection(SolutionConfigurationPlatforms) = preSolution
-		Debug|x64 = Debug|x64
-		Release|x64 = Release|x64
-	EndGlobalSection
-		]]
-	end
-
-
---
--- When a platform is specified, it should be listed instead of the architecture default.
---
-
-	function suite.buildCfgAndPlatformUsed_onPlatformsSet_onCpp()
-		platforms { "Static" }
-		prepare()
-		test.capture [[
-	GlobalSection(SolutionConfigurationPlatforms) = preSolution
-		Debug|Static = Debug|Static
-		Release|Static = Release|Static
-	EndGlobalSection
-		]]
-	end
-
-	function suite.buildCfgAndPlatformUsed_onPlatformsSet_onCs()
-		platforms { "Static" }
-		prepare("C#")
-		test.capture [[
-	GlobalSection(SolutionConfigurationPlatforms) = preSolution
-		Debug|Static = Debug|Static
-		Release|Static = Release|Static
-	EndGlobalSection
-		]]
-	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
-
-
---
--- If the platform matches a system or architecture, omit the platform name.
---
-
-	function suite.usesArch_onPlatformMatch()
-		platforms { "x32", "x64", "Xbox360" }
-		prepare()
-		test.capture [[
-	GlobalSection(SolutionConfigurationPlatforms) = preSolution
-		Debug|Win32 = Debug|Win32
-		Debug|x64 = Debug|x64
-		Debug|Xbox 360 = Debug|Xbox 360
-		Release|Win32 = Release|Win32
-		Release|Xbox 360 = Release|Xbox 360
-	EndGlobalSection
-		]]
-	end
-
-
---
--- When multiple platforms are provided, the sort order should match Visual Studio.
---
-
-	function suite.sortOrderIsCorrect_onMultiplePlatforms()
-		platforms { "Static", "Dynamic" }
-		prepare()
-		test.capture [[
-	GlobalSection(SolutionConfigurationPlatforms) = preSolution
-		Debug|Static = Debug|Static
-		Debug|Dynamic = Debug|Dynamic
-		Release|Static = Release|Static
-		Release|Dynamic = Release|Dynamic
-	EndGlobalSection
-		]]
-	end
-

tests/actions/vstudio/vc2010/test_project_configs.lua

 
 
 --
--- If multiple architectures are used, they should all be listed.
+-- Visual Studio requires that all combinations of configurations and
+-- architectures be listed (even if some pairings would make no sense
+-- for our build, i.e. Win32 DLL DCRT|PS3).
 --
 
 	function suite.allArchitecturesListed_onMultipleArchitectures()
 		]]
 	end
 
+
+--
+-- Sometimes unrolling the configuration-architecture combinations
+-- can cause duplicates. Make sure those get removed.
+--
+
 	function suite.allArchitecturesListed_onImplicitArchitectures()
 		platforms { "x32", "x64" }
 		prepare()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.