Commits

Yuriy O'Donnell committed 6d70117 Merge

Merge

Comments (0)

Files changed (54)

 bin
 obj
 release
+ipch
 src/host/scripts.c
 
 Makefile
   4.4  (in progress)
 -------
 
+* Added support for Haiku OS (Yuriy O'Donnell)
 * Patch 2963313: Enable setting .NET framework version (Justen Hyde)
 * Switched PS3 builds from GCC to SNC
 * Ignore NoRTTI flag for Managed C++ projects (Nick Darnell)
 
 
 -------
- 4.3.1
+ 4.3.1 (in progress)
 -------
 
 * Bug 3119793: Fixed ClCompile blocks with vs10 and PCH (Dan Dunham)
 * Bug 2920784: Symbol visibility in Xcode3 libraries (burnson2)
 * Bug 3133743: Sets ONLY_ACTIVE_ARCH = YES in Xcode debug builds (James Wynn)
 * Properly pass return codes back to shell in release builds
-
+* Bug 3135734: Remove WholeProgramOptimization setting in vs10 (doug)
 
 -------
   4.3
-Copyright (c) 2003-2010 Jason Perkins and individual contributors.
+Copyright (c) 2003-2011 Jason Perkins and individual contributors.
 All rights reserved.
 
 Redistribution and use in source and binary forms, with or without modification,
 PREMAKE
 A build configuration tool
 
- Copyright (C) 2002-2010 by Jason Perkins
+ Copyright (C) 2002-2011 by Jason Perkins
  Distributed under the terms of the BSD License, see LICENSE.txt
 
  The Lua language and runtime library is (C) TeCGraf, PUC-Rio.
 			buildoptions { "-mmacosx-version-min=10.1" }
 			linkoptions { "-lstdc++-static", "-mmacosx-version-min=10.1" }
 
-		configuration { "not windows", "not solaris" }
+		configuration { "linux", "bsd", "macosx" }
 			linkoptions { "-rdynamic" }
 			
 		configuration { "solaris" }

src/actions/vstudio/_vstudio.lua

 --
 -- _vstudio.lua
 -- Define the Visual Studio 200x actions.
--- Copyright (c) 2008-2010 Jason Perkins and the Premake project
+-- Copyright (c) 2008-2011 Jason Perkins and the Premake project
 --
 
-	_VS = { }  -- deprecated, will remove eventually
-
 	premake.vstudio = { }
 	local vstudio = premake.vstudio
 
 -- Studio specific "any" and "mixed" to make solution generation easier.
 --
 
-	premake.vstudio_platforms = { 
+	vstudio.platforms = { 
 		any     = "Any CPU", 
 		mixed   = "Mixed Platforms", 
 		Native  = "Win32",
 
 --
 -- Returns the architecture identifier for a project.
+-- Used by the solutions.
 --
 
-	function _VS.arch(prj)
+	function vstudio.arch(prj)
 		if (prj.language == "C#") then
 			if (_ACTION < "vs2005") then
 				return ".NET"
 	
 
 --
--- Return the version-specific text for a boolean value.
--- (this should probably go in vs200x_vcproj.lua)
---
-
-	function _VS.bool(value)
-		if (_ACTION < "vs2005") then
-			return iif(value, "TRUE", "FALSE")
-		else
-			return iif(value, "true", "false")
-		end
-	end
-
-
---
 -- Process the solution's list of configurations and platforms, creates a list
 -- of build configuration/platform pairs in a Visual Studio compatible format.
 --
--- @param sln
---    The solution containing the configuration and platform lists.
--- @param with_pseudo
---    If true, Visual Studio's "Any CPU" and "Mixed Platforms" platforms will
---    be added for .NET and mixed mode solutions.
---
 
---
--- Process the solution's list of configurations and platforms, creates a list
--- of build configuration/platform pairs in a Visual Studio compatible format.
---
--- @param sln
---    The solution containing the configuration and platform lists.
---
-
-	function premake.vstudio_buildconfigs(sln)
+	function vstudio.buildconfigs(sln)
 		local cfgs = { }
 		
-		local platforms = premake.filterplatforms(sln, premake.vstudio_platforms, "Native")
+		local platforms = premake.filterplatforms(sln, vstudio.platforms, "Native")
 
 		-- .NET projects add "Any CPU", mixed mode solutions add "Mixed Platforms"
 		local hascpp    = premake.hascppproject(sln)
 				-- configuration than a platform from Visual Studio's point of view				
 				if platform ~= "PS3" then
 					entry.buildcfg = buildcfg
-					entry.platform = premake.vstudio_platforms[platform]
+					entry.platform = vstudio.platforms[platform]
 				else
 					entry.buildcfg = platform .. " " .. buildcfg
 					entry.platform = "Win32"
 
 
 --
--- Return a configuration type index.
--- (this should probably go in vs200x_vcproj.lua)
---
-
-	function _VS.cfgtype(cfg)
-		if (cfg.kind == "SharedLib") then
-			return 2
-		elseif (cfg.kind == "StaticLib") then
-			return 4
-		else
-			return 1
-		end
-	end
-	
-	
-
---
 -- Clean Visual Studio files
 --
 
-	function premake.vstudio.cleansolution(sln)
+	function vstudio.cleansolution(sln)
 		premake.clean.file(sln, "%%.sln")
 		premake.clean.file(sln, "%%.suo")
 		premake.clean.file(sln, "%%.ncb")
 		premake.clean.file(sln, "%%.usertasks")
 	end
 	
-	function premake.vstudio.cleanproject(prj)
+	function vstudio.cleanproject(prj)
 		local fname = premake.project.getfilename(prj, "%%")
 
 		os.remove(fname .. ".vcproj")
 		os.remove(fname .. ".sdf")
 	end
 
-	function premake.vstudio.cleantarget(name)
+	function vstudio.cleantarget(name)
 		os.remove(name .. ".pdb")
 		os.remove(name .. ".idb")
 		os.remove(name .. ".ilk")
 	
 
 --
--- Write out entries for the files element; called from premake.walksources().
--- (this should probably go in vs200x_vcproj.lua)
---
-
-	local function output(indent, value)
-		-- io.write(indent .. value .. "\r\n")
-		_p(indent .. value)
-	end
-	
-	local function attrib(indent, name, value)
-		-- io.write(indent .. "\t" .. name .. '="' .. value .. '"\r\n')
-		_p(indent .. "\t" .. name .. '="' .. value .. '"')
-	end
-	
-	function _VS.files(prj, fname, state, nestlevel)
-		local indent = string.rep("\t", nestlevel + 2)
-		
-		if (state == "GroupStart") then
-			output(indent, "<Filter")
-			attrib(indent, "Name", path.getname(fname))
-			attrib(indent, "Filter", "")
-			output(indent, "\t>")
-
-		elseif (state == "GroupEnd") then
-			output(indent, "</Filter>")
-
-		else
-			output(indent, "<File")
-			attrib(indent, "RelativePath", path.translate(fname, "\\"))
-			output(indent, "\t>")
-			
-			for _, cfginfo in ipairs(prj.solution.vstudio_configs) do
-				if cfginfo.isreal then
-					local cfg = premake.getconfig(prj, cfginfo.src_buildcfg, cfginfo.src_platform)
-					local usePCH = (not prj.flags.NoPCH and prj.pchsource == fname)
-					if (usePCH) then
-						output(indent, "\t<FileConfiguration")
-						attrib(indent, "\tName", cfginfo.name)
-						output(indent, "\t\t>")
-						output(indent, "\t\t<Tool")
-						attrib(indent, "\t\tName", iif(cfg.system == "Xbox360", "VCCLX360CompilerTool", "VCCLCompilerTool"))
-
-						if (usePCH) then
-			                if (cfg.system == "PS3") then
-								-- TODO: do we really need all the build flags here?  Or can we just
-								-- add the additional option --create_pch, and let the rest of the
-								-- flags get picked up from the main compiler config block?
-			                    local buildoptions = table.join(premake.snc.getcflags(cfg), premake.snc.getcxxflags(cfg), cfg.buildoptions)
-		                        local additionalOptions = table.concat(buildoptions, " ");
-			                    additionalOptions = additionalOptions .. ' --create_pch="$(IntDir)/$(TargetName).pch"'			                    
-			                    attrib(indent, "\t\tAdditionalOptions", premake.esc(additionalOptions))
-			                else
-			                    attrib(indent, "\t\tUsePrecompiledHeader", "1")
-			                end
-			            end
-
-						output(indent, "\t\t/>")
-						output(indent, "\t</FileConfiguration>")
-					end
-				end
-			end
-			output(indent, "</File>")
-		end
-	end
-	
-	
-	
---
--- Return the optimization code.
--- (this should probably go in vs200x_vcproj.lua)
---
-
-	function _VS.optimization(cfg)
-		local result = 0
-		for _, value in ipairs(cfg.flags) do
-			if (value == "Optimize") then
-				result = 3
-			elseif (value == "OptimizeSize") then
-				result = 1
-			elseif (value == "OptimizeSpeed") then
-				result = 2
-			end
-		end
-		return result
-	end
-
-
-
---
 -- Assemble the project file name.
 --
 
-	function _VS.projectfile(prj)
+	function vstudio.projectfile(prj)
 		local extension
 		if (prj.language == "C#") then
 			extension = ".csproj"
 -- Returns the Visual Studio tool ID for a given project type.
 --
 
-	function _VS.tool(prj)
+	function vstudio.tool(prj)
 		if (prj.language == "C#") then
 			return "FAE04EC0-301F-11D3-BF4B-00C04F79EFBC"
 		else
 		},
 
 		onsolution = function(sln)
-			premake.generate(sln, "%%.sln", premake.vs2002_solution)
+			premake.generate(sln, "%%.sln", vstudio.sln2002.generate)
 		end,
 		
 		onproject = function(prj)
 			if premake.isdotnetproject(prj) then
-				premake.generate(prj, "%%.csproj", premake.vs2002_csproj)
-				premake.generate(prj, "%%.csproj.user", premake.vs2002_csproj_user)
+				premake.generate(prj, "%%.csproj", vstudio.cs2002.generate)
+				premake.generate(prj, "%%.csproj.user", vstudio.cs2002.generate_user)
 			else
-				premake.generate(prj, "%%.vcproj", premake.vs200x_vcproj)
+				premake.generate(prj, "%%.vcproj", vstudio.vc200x.generate)
 			end
 		end,
 		
 		},
 
 		onsolution = function(sln)
-			premake.generate(sln, "%%.sln", premake.vs2003_solution)
+			premake.generate(sln, "%%.sln", vstudio.sln2003.generate)
 		end,
 		
 		onproject = function(prj)
 			if premake.isdotnetproject(prj) then
-				premake.generate(prj, "%%.csproj", premake.vs2002_csproj)
-				premake.generate(prj, "%%.csproj.user", premake.vs2002_csproj_user)
+				premake.generate(prj, "%%.csproj", vstudio.cs2002.generate)
+				premake.generate(prj, "%%.csproj.user", vstudio.cs2002.generate_user)
 			else
-				premake.generate(prj, "%%.vcproj", premake.vs200x_vcproj)
+				premake.generate(prj, "%%.vcproj", vstudio.vc200x.generate)
 			end
 		end,
 		
 		},
 
 		onsolution = function(sln)
-			premake.generate(sln, "%%.sln", premake.vs2005_solution)
+			premake.generate(sln, "%%.sln", vstudio.sln2005.generate)
 		end,
 		
 		onproject = function(prj)
 			if premake.isdotnetproject(prj) then
-				premake.generate(prj, "%%.csproj", premake.vs2005_csproj)
-				premake.generate(prj, "%%.csproj.user", premake.vs2005_csproj_user)
+				premake.generate(prj, "%%.csproj", vstudio.cs2005.generate)
+				premake.generate(prj, "%%.csproj.user", vstudio.cs2005.generate_user)
 			else
-				premake.generate(prj, "%%.vcproj", premake.vs200x_vcproj)
+				premake.generate(prj, "%%.vcproj", vstudio.vc200x.generate)
 			end
 		end,
 		
-		oncleansolution = premake.vstudio.cleansolution,
-		oncleanproject  = premake.vstudio.cleanproject,
-		oncleantarget   = premake.vstudio.cleantarget
+		oncleansolution = vstudio.cleansolution,
+		oncleanproject  = vstudio.cleanproject,
+		oncleantarget   = vstudio.cleantarget
 	}
 
 	newaction {
 		},
 
 		onsolution = function(sln)
-			premake.generate(sln, "%%.sln", premake.vs2005_solution)
+			premake.generate(sln, "%%.sln", vstudio.sln2005.generate)
 		end,
 		
 		onproject = function(prj)
 			if premake.isdotnetproject(prj) then
-				premake.generate(prj, "%%.csproj", premake.vs2005_csproj)
-				premake.generate(prj, "%%.csproj.user", premake.vs2005_csproj_user)
+				premake.generate(prj, "%%.csproj", vstudio.cs2005.generate)
+				premake.generate(prj, "%%.csproj.user", vstudio.cs2005.generate_user)
 			else
-				premake.generate(prj, "%%.vcproj", premake.vs200x_vcproj)
+				premake.generate(prj, "%%.vcproj", vstudio.vc200x.generate)
 			end
 		end,
 		
-		oncleansolution = premake.vstudio.cleansolution,
-		oncleanproject  = premake.vstudio.cleanproject,
-		oncleantarget   = premake.vstudio.cleantarget
+		oncleansolution = vstudio.cleansolution,
+		oncleanproject  = vstudio.cleanproject,
+		oncleantarget   = vstudio.cleantarget
 	}
 
 		

src/actions/vstudio/vs2002_csproj.lua

 --
 -- vs2002_csproj.lua
 -- Generate a Visual Studio 2002/2003 C# project.
--- Copyright (c) 2009 Jason Perkins and the Premake project
+-- Copyright (c) 2009-2011 Jason Perkins and the Premake project
 --
 
-	--
-	-- Figure out what elements a particular file need in its item block,
-	-- based on its build action and any related files in the project.
-	-- 
+	premake.vstudio.cs2002 = { }
+	local vstudio = premake.vstudio
+	local cs2002 = premake.vstudio.cs2002
+
+	
+--
+-- Figure out what elements a particular file need in its item block,
+-- based on its build action and any related files in the project.
+-- 
+
 	local function getelements(prj, action, fname)
 	
 		if action == "Compile" and fname:endswith(".cs") then
 	end
 
 
+--
+-- Write out the <Files> element.
+--
 
-	function premake.vs2002_csproj(prj)
+	function cs2002.Files(prj)
+		local tr = premake.project.buildsourcetree(prj)
+		premake.tree.traverse(tr, {
+			onleaf = function(node)
+				local action = premake.dotnet.getbuildaction(node.cfg)
+				local fname  = path.translate(premake.esc(node.path), "\\")
+				local elements, dependency = getelements(prj, action, node.path)
+
+				_p(4,'<File')
+				_p(5,'RelPath = "%s"', fname)
+				_p(5,'BuildAction = "%s"', action)
+				if dependency then
+					_p(5,'DependentUpon = "%s"', premake.esc(path.translate(dependency, "\\")))
+				end
+				if elements == "SubTypeCode" then
+					_p(5,'SubType = "Code"')
+				end
+				_p(4,'/>')
+			end
+		}, false)
+	end
+
+
+--
+-- The main function: write the project file.
+--
+
+	function cs2002.generate(prj)
 		io.eol = "\r\n"
 		_p('<VisualStudioProject>')
 
 			_p(4,'<Reference')
 			_p(5,'Name = "%s"', ref.buildtarget.basename)
 			_p(5,'Project = "{%s}"', ref.uuid)
-			_p(5,'Package = "{%s}"', _VS.tool(ref))
+			_p(5,'Package = "{%s}"', vstudio.tool(ref))
 			_p(4,'/>')
 		end
 		for _, linkname in ipairs(premake.getlinks(prj, "system", "fullpath")) do
 		-- List source files
 		_p(2,'<Files>')
 		_p(3,'<Include>')
-		for fcfg in premake.eachfile(prj) do
-			local action = premake.dotnet.getbuildaction(fcfg)
-			local fname  = path.translate(premake.esc(fcfg.name), "\\")
-			local elements, dependency = getelements(prj, action, fcfg.name)
-			
-			_p(4,'<File')
-			_p(5,'RelPath = "%s"', premake.esc(fname))
-			_p(5,'BuildAction = "%s"', action)
-			if dependency then
-				_p(5,'DependentUpon = "%s"', premake.esc(path.translate(dependency, "\\")))
-			end
-			if elements == "SubTypeCode" then
-				_p(5,'SubType = "Code"')
-			end
-			_p(4,'/>')
-		end
+		cs2002.Files(prj)
 		_p(3,'</Include>')
 		_p(2,'</Files>')
 		

src/actions/vstudio/vs2002_csproj_user.lua

 -- Copyright (c) 2009 Jason Perkins and the Premake project
 --
 
-	function premake.vs2002_csproj_user(prj)
+	local cs2002 = premake.vstudio.cs2002
+
+	function cs2002.generate_user(prj)
 		io.eol = "\r\n"
 
 		_p('<VisualStudioProject>')

src/actions/vstudio/vs2002_solution.lua

 --
 -- vs2002_solution.lua
 -- Generate a Visual Studio 2002 solution.
--- Copyright (c) 2009 Jason Perkins and the Premake project
+-- Copyright (c) 2009-2011 Jason Perkins and the Premake project
 --
 
-	function premake.vs2002_solution(sln)
+	premake.vstudio.sln2002 = { }
+	local vstudio = premake.vstudio
+	local sln2002 = premake.vstudio.sln2002
+
+	function sln2002.generate(sln)
 		io.eol = '\r\n'
 
 		-- Precompute Visual Studio configurations
-		sln.vstudio_configs = premake.vstudio_buildconfigs(sln)
+		sln.vstudio_configs = premake.vstudio.buildconfigs(sln)
 
 		_p('Microsoft Visual Studio Solution File, Format Version 7.00')
 		
 		-- Write out the list of project entries
 		for prj in premake.solution.eachproject(sln) do
-			local projpath = path.translate(path.getrelative(sln.location, _VS.projectfile(prj)))
-			_p('Project("{%s}") = "%s", "%s", "{%s}"', _VS.tool(prj), prj.name, projpath, prj.uuid)
+			local projpath = path.translate(path.getrelative(sln.location, vstudio.projectfile(prj)))
+			_p('Project("{%s}") = "%s", "%s", "{%s}"', vstudio.tool(prj), prj.name, projpath, prj.uuid)
 			_p('EndProject')
 		end
 
 		_p(1,'GlobalSection(ProjectConfiguration) = postSolution')
 		for prj in premake.solution.eachproject(sln) do
 			for _, cfgname in ipairs(sln.configurations) do
-				_p(2,'{%s}.%s.ActiveCfg = %s|%s', prj.uuid, cfgname, cfgname, _VS.arch(prj))
-				_p(2,'{%s}.%s.Build.0 = %s|%s', prj.uuid, cfgname, cfgname, _VS.arch(prj))
+				_p(2,'{%s}.%s.ActiveCfg = %s|%s', prj.uuid, cfgname, cfgname, vstudio.arch(prj))
+				_p(2,'{%s}.%s.Build.0 = %s|%s', prj.uuid, cfgname, cfgname, vstudio.arch(prj))
 			end
 		end
 		_p(1,'EndGlobalSection')

src/actions/vstudio/vs2003_solution.lua

 --
 -- vs2003_solution.lua
 -- Generate a Visual Studio 2003 solution.
--- Copyright (c) 2009 Jason Perkins and the Premake project
+-- Copyright (c) 2009-2011 Jason Perkins and the Premake project
 --
 
-	function premake.vs2003_solution(sln)
+	premake.vstudio.sln2003 = { }
+	local vstudio = premake.vstudio
+	local sln2003 = premake.vstudio.sln2003
+
+
+	function sln2003.generate(sln)
 		io.eol = '\r\n'
 
 		-- Precompute Visual Studio configurations
-		sln.vstudio_configs = premake.vstudio_buildconfigs(sln)
+		sln.vstudio_configs = premake.vstudio.buildconfigs(sln)
 
 		_p('Microsoft Visual Studio Solution File, Format Version 8.00')
 
 		-- Write out the list of project entries
 		for prj in premake.solution.eachproject(sln) do
-			local projpath = path.translate(path.getrelative(sln.location, _VS.projectfile(prj)))
-			_p('Project("{%s}") = "%s", "%s", "{%s}"', _VS.tool(prj), prj.name, projpath, prj.uuid)
+			local projpath = path.translate(path.getrelative(sln.location, vstudio.projectfile(prj)))
+			_p('Project("{%s}") = "%s", "%s", "{%s}"', vstudio.tool(prj), prj.name, projpath, prj.uuid)
 			
 			local deps = premake.getdependencies(prj)
 			if #deps > 0 then
 		_p('\tGlobalSection(ProjectConfiguration) = postSolution')
 		for prj in premake.solution.eachproject(sln) do
 			for _, cfgname in ipairs(sln.configurations) do
-				_p('\t\t{%s}.%s.ActiveCfg = %s|%s', prj.uuid, cfgname, cfgname, _VS.arch(prj))
-				_p('\t\t{%s}.%s.Build.0 = %s|%s', prj.uuid, cfgname, cfgname, _VS.arch(prj))
+				_p('\t\t{%s}.%s.ActiveCfg = %s|%s', prj.uuid, cfgname, cfgname, vstudio.arch(prj))
+				_p('\t\t{%s}.%s.Build.0 = %s|%s', prj.uuid, cfgname, cfgname, vstudio.arch(prj))
 			end
 		end
 		_p('\tEndGlobalSection')

src/actions/vstudio/vs2005_csproj.lua

 
 
 --
+-- Write out the <Files> element.
+--
+
+	function cs2005.Files(prj)
+		local tr = premake.project.buildsourcetree(prj)
+		premake.tree.traverse(tr, {
+			onleaf = function(node)
+				local action = premake.dotnet.getbuildaction(node.cfg)
+				local fname  = path.translate(premake.esc(node.path), "\\")
+				local elements, dependency = getelements(prj, action, node.path)
+
+				if elements == "None" then
+					_p('    <%s Include="%s" />', action, fname)
+				else
+					_p('    <%s Include="%s">', action, fname)
+					if elements == "AutoGen" then
+						_p('      <AutoGen>True</AutoGen>')
+					elseif elements == "AutoGenerated" then
+						_p('      <SubType>Designer</SubType>')
+						_p('      <Generator>ResXFileCodeGenerator</Generator>')
+						_p('      <LastGenOutput>%s.Designer.cs</LastGenOutput>', premake.esc(path.getbasename(node.name)))
+					elseif elements == "SubTypeDesigner" then
+						_p('      <SubType>Designer</SubType>')
+					elseif elements == "SubTypeForm" then
+						_p('      <SubType>Form</SubType>')
+					elseif elements == "PreserveNewest" then
+						_p('      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>')
+					end
+					if dependency then
+						_p('      <DependentUpon>%s</DependentUpon>', path.translate(premake.esc(dependency), "\\"))
+					end
+					_p('    </%s>', action)
+				end
+			end
+		}, false)
+	end
+
+
+--
 -- Write the opening <Project> element and project level <PropertyGroup> block.
 --
 
 -- The main function: write the project file.
 --
 
-	function premake.vs2005_csproj(prj)
+	function cs2005.generate(prj)
 		io.eol = "\r\n"
 
 		local vsversion, toolversion
 
 		_p('  <ItemGroup>')
 		for _, ref in ipairs(premake.getlinks(prj, "siblings", "object")) do
-			_p('    <ProjectReference Include="%s">', path.translate(path.getrelative(prj.location, _VS.projectfile(ref)), "\\"))
+			_p('    <ProjectReference Include="%s">', path.translate(path.getrelative(prj.location, vstudio.projectfile(ref)), "\\"))
 			_p('      <Project>{%s}</Project>', ref.uuid)
 			_p('      <Name>%s</Name>', premake.esc(ref.name))
 			_p('    </ProjectReference>')
 		_p('  </ItemGroup>')
 
 		_p('  <ItemGroup>')
-		for fcfg in premake.eachfile(prj) do
-			local action = premake.dotnet.getbuildaction(fcfg)
-			local fname  = path.translate(premake.esc(fcfg.name), "\\")
-			local elements, dependency = getelements(prj, action, fcfg.name)
-			if elements == "None" then
-				_p('    <%s Include="%s" />', action, fname)
-			else
-				_p('    <%s Include="%s">', action, fname)
-				if elements == "AutoGen" then
-					_p('      <AutoGen>True</AutoGen>')
-				elseif elements == "AutoGenerated" then
-					_p('      <SubType>Designer</SubType>')
-					_p('      <Generator>ResXFileCodeGenerator</Generator>')
-					_p('      <LastGenOutput>%s.Designer.cs</LastGenOutput>', premake.esc(path.getbasename(fcfg.name)))
-				elseif elements == "SubTypeDesigner" then
-					_p('      <SubType>Designer</SubType>')
-				elseif elements == "SubTypeForm" then
-					_p('      <SubType>Form</SubType>')
-				elseif elements == "PreserveNewest" then
-					_p('      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>')
-				end
-				if dependency then
-					_p('      <DependentUpon>%s</DependentUpon>', path.translate(premake.esc(dependency), "\\"))
-				end
-				_p('    </%s>', action)
-			end
-		end
+		cs2005.Files(prj)
 		_p('  </ItemGroup>')
 
 		_p('  <Import Project="$(MSBuildBinPath)\\Microsoft.CSharp.targets" />')

src/actions/vstudio/vs2005_csproj_user.lua

 -- Copyright (c) 2009 Jason Perkins and the Premake project
 --
 
-	function premake.vs2005_csproj_user(prj)
+	local cs2005 = premake.vstudio.cs2005
+
+
+	function cs2005.generate_user(prj)
 		io.eol = "\r\n"
 		
 		_p('<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">')

src/actions/vstudio/vs2005_solution.lua

 --
 -- vs2005_solution.lua
 -- Generate a Visual Studio 2005 or 2008 solution.
--- Copyright (c) 2009 Jason Perkins and the Premake project
+-- Copyright (c) 2009-2011 Jason Perkins and the Premake project
 --
 
-
-	function premake.vs2005_solution(sln)
+	premake.vstudio.sln2005 = { }
+	local vstudio = premake.vstudio
+	local sln2005 = premake.vstudio.sln2005
+	
+	function sln2005.generate(sln)
 		io.eol = '\r\n'
 
 		-- Precompute Visual Studio configurations
-		sln.vstudio_configs = premake.vstudio_buildconfigs(sln)
+		sln.vstudio_configs = premake.vstudio.buildconfigs(sln)
 		
 		-- Mark the file as Unicode
 		_p('\239\187\191')
 		-- Write out the list of project entries
 		for prj in premake.solution.eachproject(sln) do
 			-- Build a relative path from the solution file to the project file
-			local projpath = path.translate(path.getrelative(sln.location, _VS.projectfile(prj)), "\\")
+			local projpath = path.translate(path.getrelative(sln.location, vstudio.projectfile(prj)), "\\")
 			
-			_p('Project("{%s}") = "%s", "%s", "{%s}"', _VS.tool(prj), prj.name, projpath, prj.uuid)
+			_p('Project("{%s}") = "%s", "%s", "{%s}"', vstudio.tool(prj), prj.name, projpath, prj.uuid)
 			local deps = premake.getdependencies(prj)
 			if #deps > 0 then
 				_p('\tProjectSection(ProjectDependencies) = postProject')
 		end
 
 		_p('Global')
-		premake.vs2005_solution_platforms(sln)
-		premake.vs2005_solution_project_platforms(sln)
-		premake.vs2005_solution_properties(sln)
+		sln2005.platforms(sln)
+		sln2005.project_platforms(sln)
+		sln2005.properties(sln)
 		_p('EndGlobal')
 	end
 	
 -- lists all of the configuration/platform pairs that exist in the solution.
 --
 
-	function premake.vs2005_solution_platforms(sln)
+	function sln2005.platforms(sln)
 		_p('\tGlobalSection(SolutionConfigurationPlatforms) = preSolution')
 		for _, cfg in ipairs(sln.vstudio_configs) do
 			_p('\t\t%s = %s', cfg.name, cfg.name)
 -- the configuration/platform pairs into each project of the solution.
 --
 
-	function premake.vs2005_solution_project_platforms(sln)
+	function sln2005.project_platforms(sln)
 		_p('\tGlobalSection(ProjectConfigurationPlatforms) = postSolution')
 		for prj in premake.solution.eachproject(sln) do
 			for _, cfg in ipairs(sln.vstudio_configs) do
 -- Write out contents of the SolutionProperties section; currently unused.
 --
 
-	function premake.vs2005_solution_properties(sln)	
+	function sln2005.properties(sln)	
 		_p('\tGlobalSection(SolutionProperties) = preSolution')
 		_p('\t\tHideSolutionNode = FALSE')
 		_p('\tEndGlobalSection')

src/actions/vstudio/vs200x_vcproj.lua

 --
 -- vs200x_vcproj.lua
 -- Generate a Visual Studio 2002-2008 C/C++ project.
--- Copyright (c) 2009, 2010 Jason Perkins and the Premake project
+-- Copyright (c) 2009-2011 Jason Perkins and the Premake project
 --
 
-premake.vstudio.vcproj = { }
-local vcproj = premake.vstudio.vcproj
+
+--
+-- Set up a namespace for this file
+--
+
+	premake.vstudio.vc200x = { }
+	local vc200x = premake.vstudio.vc200x
+	local tree = premake.tree
+
+
+--
+-- Return the version-specific text for a boolean value.
+--
+
+	local function bool(value)
+		if (_ACTION < "vs2005") then
+			return iif(value, "TRUE", "FALSE")
+		else
+			return iif(value, "true", "false")
+		end
+	end
+
+
+--
+-- Return the optimization code.
+-- (this should probably go in vs200x_vcproj.lua)
+--
+
+	function vc200x.optimization(cfg)
+		local result = 0
+		for _, value in ipairs(cfg.flags) do
+			if (value == "Optimize") then
+				result = 3
+			elseif (value == "OptimizeSize") then
+				result = 1
+			elseif (value == "OptimizeSpeed") then
+				result = 2
+			end
+		end
+		return result
+	end
+
 
 
 --
 -- Write out the <Configuration> element.
 --
 
-	function vcproj.Configuration(name, cfg)
+	function vc200x.Configuration(name, cfg)
 		_p(2,'<Configuration')
 		_p(3,'Name="%s"', premake.esc(name))
 		_p(3,'OutputDirectory="%s"', premake.esc(cfg.buildtarget.directory))
 		_p(3,'IntermediateDirectory="%s"', premake.esc(cfg.objectsdir))
-		_p(3,'ConfigurationType="%s"', _VS.cfgtype(cfg))
+
+		local cfgtype
+		if (cfg.kind == "SharedLib") then
+			cfgtype = 2
+		elseif (cfg.kind == "StaticLib") then
+			cfgtype = 4
+		else
+			cfgtype = 1
+		end
+		_p(3,'ConfigurationType="%s"', cfgtype)
+
 		if (cfg.flags.MFC) then
 			_p(3, 'UseOfMFC="2"')			
 		end				  
 		_p(3,'>')
 	end
 	
+
+--
+-- Write out the <Files> element.
+--
+
+	function vc200x.Files(prj)
+		local tr = premake.project.buildsourcetree(prj)
+		
+		tree.traverse(tr, {
+			-- folders are handled at the internal nodes
+			onbranchenter = function(node, depth)
+				_p(depth, '<Filter')
+				_p(depth, '\tName="%s"', node.name)
+				_p(depth, '\tFilter=""')
+				_p(depth, '\t>')
+			end,
+
+			onbranchexit = function(node, depth)
+				_p(depth, '</Filter>')
+			end,
+
+			-- source files are handled at the leaves
+			onleaf = function(node, depth)
+				_p(depth, '<File')
+				_p(depth, '\tRelativePath="%s"', path.translate(node.path, "\\"))
+				_p(depth, '\t>')
+				depth = depth + 1
+
+				-- handle file configuration stuff. This needs to be cleaned up and simplified.
+				-- configurations are cached, so this isn't as bad as it looks
+				for _, cfginfo in ipairs(prj.solution.vstudio_configs) do
+					if cfginfo.isreal then
+						local cfg = premake.getconfig(prj, cfginfo.src_buildcfg, cfginfo.src_platform)
+						
+						local usePCH = (not prj.flags.NoPCH and prj.pchsource == node.path)
+						if (usePCH) then
+							_p(depth, '<FileConfiguration')
+							_p(depth, '\tName="%s"', cfginfo.name)
+							_p(depth, '\t>')
+							_p(depth, '\t<Tool')
+							_p(depth, '\t\tName="%s"', iif(cfg.system == "Xbox360", "VCCLX360CompilerTool", "VCCLCompilerTool"))
+
+			                if cfg.system == "PS3" then
+			                    local options = table.join(premake.snc.getcflags(cfg), premake.snc.getcxxflags(cfg), cfg.buildoptions)
+		                        options = table.concat(options, " ");
+			                    options = options .. ' --create_pch="$(IntDir)/$(TargetName).pch"'			                    
+			                    _p(depth, '\t\tAdditionalOptions="%s"', premake.esc(options))
+			                else
+			                    _p(depth, '\t\tUsePrecompiledHeader="1"')
+			                end
+
+							_p(depth, '\t/>')
+							_p(depth, '</FileConfiguration>')
+						end
+
+					end
+				end
+
+				depth = depth - 1
+				_p(depth, '</File>')
+			end,
+		}, false, 2)
+
+	end
+
 	
 --
 -- Write out the <Platforms> element; ensures that each target platform
 -- is listed only once. Skips over .NET's pseudo-platforms (like "Any CPU").
 --
 
-	function premake.vs200x_vcproj_platforms(prj)
+	function vc200x.Platforms(prj)
 		local used = { }
 		_p(1,'<Platforms>')
 		for _, cfg in ipairs(prj.solution.vstudio_configs) do
 -- Return the debugging symbols level for a configuration.
 --
 
-	function premake.vs200x_vcproj_symbols(cfg)
+	function vc200x.Symbols(cfg)
 		if (not cfg.flags.Symbols) then
 			return 0
 		else
 			-- Edit-and-continue does't work for some configurations
 			if cfg.flags.NoEditAndContinue or 
-			   _VS.optimization(cfg) ~= 0 or 
+			   vc200x.optimization(cfg) ~= 0 or 
 			   cfg.flags.Managed or 
 			   cfg.platform == "x64" then
 				return 3
 -- Compiler block for Windows and XBox360 platforms.
 --
 
-	function premake.vs200x_vcproj_VCCLCompilerTool(cfg)
+	function vc200x.VCCLCompilerTool(cfg)
 		_p(3,'<Tool')
 		_p(4,'Name="%s"', iif(cfg.platform ~= "Xbox360", "VCCLCompilerTool", "VCCLX360CompilerTool"))
 		
 			_p(4,'AdditionalOptions="%s"', table.concat(premake.esc(cfg.buildoptions), " "))
 		end
 		
-		_p(4,'Optimization="%s"', _VS.optimization(cfg))
+		_p(4,'Optimization="%s"', vc200x.optimization(cfg))
 		
 		if cfg.flags.NoFramePointer then
-			_p(4,'OmitFramePointers="%s"', _VS.bool(true))
+			_p(4,'OmitFramePointers="%s"', bool(true))
 		end
 		
 		if #cfg.includedirs > 0 then
 		end
 		
 		if premake.config.isdebugbuild(cfg) and not cfg.flags.NoMinimalRebuild and not cfg.flags.Managed then
-			_p(4,'MinimalRebuild="%s"', _VS.bool(true))
+			_p(4,'MinimalRebuild="%s"', bool(true))
 		end
 		
 		if cfg.flags.NoExceptions then
 			_p(4,'ExceptionHandling="2"')
 		end
 		
-		if _VS.optimization(cfg) == 0 and not cfg.flags.Managed then
+		if vc200x.optimization(cfg) == 0 and not cfg.flags.Managed then
 			_p(4,'BasicRuntimeChecks="3"')
 		end
-		if _VS.optimization(cfg) ~= 0 then
-			_p(4,'StringPooling="%s"', _VS.bool(true))
+		if vc200x.optimization(cfg) ~= 0 then
+			_p(4,'StringPooling="%s"', bool(true))
 		end
 		
 		local runtime
 		else
 			runtime = iif(cfg.flags.StaticRuntime, 0, 2)
 		end
-		
---		if cfg.flags.StaticRuntime then
---			runtime = iif(cfg.flags.Symbols, 1, 0)
---		else
---			runtime = iif(cfg.flags.Symbols, 3, 2)
---		end
 		_p(4,'RuntimeLibrary="%s"', runtime)
 
-		_p(4,'EnableFunctionLevelLinking="%s"', _VS.bool(true))
+		_p(4,'EnableFunctionLevelLinking="%s"', bool(true))
 
 		if _ACTION > "vs2003" and cfg.platform ~= "Xbox360" and cfg.platform ~= "x64" then
 			if cfg.flags.EnableSSE then
 	
 		if _ACTION < "vs2005" then
 			if cfg.flags.FloatFast then
-				_p(4,'ImproveFloatingPointConsistency="%s"', _VS.bool(false))
+				_p(4,'ImproveFloatingPointConsistency="%s"', bool(false))
 			elseif cfg.flags.FloatStrict then
-				_p(4,'ImproveFloatingPointConsistency="%s"', _VS.bool(true))
+				_p(4,'ImproveFloatingPointConsistency="%s"', bool(true))
 			end
 		else
 			if cfg.flags.FloatFast then
 		end
 		
 		if _ACTION < "vs2005" and not cfg.flags.NoRTTI then
-			_p(4,'RuntimeTypeInfo="%s"', _VS.bool(true))
+			_p(4,'RuntimeTypeInfo="%s"', bool(true))
 		elseif _ACTION > "vs2003" and cfg.flags.NoRTTI and not cfg.flags.Managed then
-			_p(4,'RuntimeTypeInfo="%s"', _VS.bool(false))
+			_p(4,'RuntimeTypeInfo="%s"', bool(false))
 		end
 		
 		if cfg.flags.NativeWChar then
-			_p(4,'TreatWChar_tAsBuiltInType="%s"', _VS.bool(true))
+			_p(4,'TreatWChar_tAsBuiltInType="%s"', bool(true))
 		elseif cfg.flags.NoNativeWChar then
-			_p(4,'TreatWChar_tAsBuiltInType="%s"', _VS.bool(false))
+			_p(4,'TreatWChar_tAsBuiltInType="%s"', bool(false))
 		end
 		
 		if not cfg.flags.NoPCH and cfg.pchheader then
 		_p(4,'WarningLevel="%s"', iif(cfg.flags.ExtraWarnings, 4, 3))
 		
 		if cfg.flags.FatalWarnings then
-			_p(4,'WarnAsError="%s"', _VS.bool(true))
+			_p(4,'WarnAsError="%s"', bool(true))
 		end
 		
 		if _ACTION < "vs2008" and not cfg.flags.Managed then
-			_p(4,'Detect64BitPortabilityProblems="%s"', _VS.bool(not cfg.flags.No64BitChecks))
+			_p(4,'Detect64BitPortabilityProblems="%s"', bool(not cfg.flags.No64BitChecks))
 		end
 		
 		_p(4,'ProgramDataBaseFileName="$(OutDir)\\%s.pdb"', path.getbasename(cfg.buildtarget.name))
-		_p(4,'DebugInformationFormat="%s"', premake.vs200x_vcproj_symbols(cfg))
+		_p(4,'DebugInformationFormat="%s"', vc200x.Symbols(cfg))
 		if cfg.language == "C" then
 			_p(4, 'CompileAs="1"')
 		end
 -- Linker block for Windows and Xbox 360 platforms.
 --
 
-	function premake.vs200x_vcproj_VCLinkerTool(cfg)
+	function vc200x.VCLinkerTool(cfg)
 		_p(3,'<Tool')
 		if cfg.kind ~= "StaticLib" then
 			_p(4,'Name="%s"', iif(cfg.platform ~= "Xbox360", "VCLinkerTool", "VCX360LinkerTool"))
 			
 			if cfg.flags.NoImportLib then
-				_p(4,'IgnoreImportLibrary="%s"', _VS.bool(true))
+				_p(4,'IgnoreImportLibrary="%s"', bool(true))
 			end
 			
 			if #cfg.linkoptions > 0 then
 			end
 			
 			if cfg.flags.NoManifest then
-				_p(4,'GenerateManifest="%s"', _VS.bool(false))
+				_p(4,'GenerateManifest="%s"', bool(false))
 			end
 			
-			_p(4,'GenerateDebugInformation="%s"', _VS.bool(premake.vs200x_vcproj_symbols(cfg) ~= 0))
+			_p(4,'GenerateDebugInformation="%s"', bool(vc200x.Symbols(cfg) ~= 0))
 			
-			if premake.vs200x_vcproj_symbols(cfg) ~= 0 then
+			if vc200x.Symbols(cfg) ~= 0 then
 				_p(4,'ProgramDataBaseFileName="$(OutDir)\\%s.pdb"', path.getbasename(cfg.buildtarget.name))
 			end
 			
 			_p(4,'SubSystem="%s"', iif(cfg.kind == "ConsoleApp", 1, 2))
 			
-			if _VS.optimization(cfg) ~= 0 then
+			if vc200x.optimization(cfg) ~= 0 then
 				_p(4,'OptimizeReferences="2"')
 				_p(4,'EnableCOMDATFolding="2"')
 			end
 -- Compiler and linker blocks for the PS3 platform, which uses Sony's SNC.
 --
 
-	function premake.vs200x_vcproj_VCCLCompilerTool_PS3(cfg)
+	function vc200x.VCCLCompilerTool_PS3(cfg)
 		_p(3,'<Tool')
 		_p(4,'Name="VCCLCompilerTool"')
 
 		_p(3,'/>')
 	end
 
-	function premake.vs200x_vcproj_VCLinkerTool_PS3(cfg)
+
+	function vc200x.VCLinkerTool_PS3(cfg)
 		_p(3,'<Tool')
 		if cfg.kind ~= "StaticLib" then
 			_p(4,'Name="VCLinkerTool"')
 			_p(4,'OutputFile="$(OutDir)\\%s"', cfg.buildtarget.name)
 			_p(4,'LinkIncremental="0"')
 			_p(4,'AdditionalLibraryDirectories="%s"', table.concat(premake.esc(path.translate(cfg.libdirs, '\\')) , ";"))
-			_p(4,'GenerateManifest="%s"', _VS.bool(false))
+			_p(4,'GenerateManifest="%s"', bool(false))
 			_p(4,'ProgramDatabaseFile=""')
 			_p(4,'RandomizedBaseAddress="1"')
 			_p(4,'DataExecutionPrevention="0"')			
 -- Resource compiler block.
 --
 
-	function premake.vs200x_vcproj_VCResourceCompilerTool(cfg)
+	function vc200x.VCResourceCompilerTool(cfg)
 		_p(3,'<Tool')
 		_p(4,'Name="VCResourceCompilerTool"')
 
 -- Manifest block.
 --
 
-	function premake.vs200x_vcproj_VCManifestTool(cfg)
+	function vc200x.VCManifestTool(cfg)
 		-- locate all manifest files
 		local manifests = { }
 		for _, fname in ipairs(cfg.files) do
 -- VCMIDLTool block
 --
 
-	function premake.vs200x_vcproj_VCMIDLTool(cfg)
+	function vc200x.VCMIDLTool(cfg)
 		_p(3,'<Tool')
 		_p(4,'Name="VCMIDLTool"')
 		if cfg.platform == "x64" then
 -- Write out a custom build steps block.
 --
 
-	function premake.vs200x_vcproj_buildstepsblock(name, steps)
+	function vc200x.buildstepsblock(name, steps)
 		_p(3,'<Tool')
 		_p(4,'Name="%s"', name)
 		if #steps > 0 then
 
 	local blockmap = 
 	{
-		VCCLCompilerTool       = premake.vs200x_vcproj_VCCLCompilerTool,
-		VCCLCompilerTool_PS3   = premake.vs200x_vcproj_VCCLCompilerTool_PS3,
-		VCLinkerTool           = premake.vs200x_vcproj_VCLinkerTool,
-		VCLinkerTool_PS3       = premake.vs200x_vcproj_VCLinkerTool_PS3,
-		VCManifestTool         = premake.vs200x_vcproj_VCManifestTool,
-		VCMIDLTool             = premake.vs200x_vcproj_VCMIDLTool,
-		VCResourceCompilerTool = premake.vs200x_vcproj_VCResourceCompilerTool,
+		VCCLCompilerTool       = vc200x.VCCLCompilerTool,
+		VCCLCompilerTool_PS3   = vc200x.VCCLCompilerTool_PS3,
+		VCLinkerTool           = vc200x.VCLinkerTool,
+		VCLinkerTool_PS3       = vc200x.VCLinkerTool_PS3,
+		VCManifestTool         = vc200x.VCManifestTool,
+		VCMIDLTool             = vc200x.VCMIDLTool,
+		VCResourceCompilerTool = vc200x.VCResourceCompilerTool,
 	}
 	
 	
 -- The main function: write the project file.
 --
 
-	function premake.vs200x_vcproj(prj)
+	function vc200x.generate(prj)
 		io.eol = "\r\n"
 		_p('<?xml version="1.0" encoding="Windows-1252"?>')
 		
 		_p(1,'>')
 
 		-- list the target platforms
-		premake.vs200x_vcproj_platforms(prj)
+		vc200x.Platforms(prj)
 
 		if _ACTION > "vs2003" then
 			_p(1,'<ToolFiles>')
 				local cfg = premake.getconfig(prj, cfginfo.src_buildcfg, cfginfo.src_platform)
 		
 				-- Start a configuration
-				vcproj.Configuration(cfginfo.name, cfg)				
+				vc200x.Configuration(cfginfo.name, cfg)				
 				for _, block in ipairs(getsections(_ACTION, cfginfo.src_platform)) do
 				
 					if blockmap[block] then
 		
 					-- Build event blocks --
 					elseif block == "VCPreBuildEventTool" then
-						premake.vs200x_vcproj_buildstepsblock("VCPreBuildEventTool", cfg.prebuildcommands)
+						vc200x.buildstepsblock("VCPreBuildEventTool", cfg.prebuildcommands)
 					elseif block == "VCPreLinkEventTool" then
-						premake.vs200x_vcproj_buildstepsblock("VCPreLinkEventTool", cfg.prelinkcommands)
+						vc200x.buildstepsblock("VCPreLinkEventTool", cfg.prelinkcommands)
 					elseif block == "VCPostBuildEventTool" then
-						premake.vs200x_vcproj_buildstepsblock("VCPostBuildEventTool", cfg.postbuildcommands)
+						vc200x.buildstepsblock("VCPostBuildEventTool", cfg.postbuildcommands)
 					-- End build event blocks --
 					
 					-- Xbox 360 custom sections --
 		_p(1,'</References>')
 		
 		_p(1,'<Files>')
-		premake.walksources(prj, _VS.files)
+		vc200x.Files(prj)
 		_p(1,'</Files>')
 		
 		_p(1,'<Globals>')

src/actions/vstudio/vs2010_vcxproxj.lua

 
-premake.vstudio.vs10_helpers = { }
-local vs10_helpers = premake.vstudio.vs10_helpers
+premake.vstudio.vc2010 = { }
+local vc2010 = premake.vstudio.vc2010
 	
 		
-	function vs10_helpers.remove_relative_path(file)
+	function vc2010.remove_relative_path(file)
 		file = file:gsub("%.%.\\",'')
 		file = file:gsub("%.\\",'')
 		return file
 	end
 		
-	function vs10_helpers.file_path(file)
-		file = vs10_helpers.remove_relative_path(file)
+	function vc2010.file_path(file)
+		file = vc2010.remove_relative_path(file)
 		local path = string.find(file,'\\[%w%.%_%-]+$')
 		if path then
 			return string.sub(file,1,path-1)
 		end
 	end
 	
-	function vs10_helpers.list_of_directories_in_path(path)
+	function vc2010.list_of_directories_in_path(path)
 		local list={}
-		path = vs10_helpers.remove_relative_path(path)
+		path = vc2010.remove_relative_path(path)
 		if path then
 			for dir in string.gmatch(path,"[%w%-%_%.]+\\")do
 				if #list == 0 then
 		return list
 	end
 
-	function vs10_helpers.table_of_file_filters(files)
+	function vc2010.table_of_file_filters(files)
 		local filters ={}
 
 		for _, valueTable in pairs(files) do
 			for _, entry in ipairs(valueTable) do
-				local result = vs10_helpers.list_of_directories_in_path(entry)
+				local result = vc2010.list_of_directories_in_path(entry)
 				for __,dir in ipairs(result) do
 					if table.contains(filters,dir) ~= true then
 					filters[#filters +1] = dir
 		return filters
 	end
 	
-	function vs10_helpers.get_file_extension(file)
+	function vc2010.get_file_extension(file)
 		local ext_start,ext_end = string.find(file,"%.[%w_%-]+$")
 		if ext_start then
 			return  string.sub(file,ext_start+1,ext_end)
 
 	
 	--also translates file paths from '/' to '\\'
-	function vs10_helpers.sort_input_files(files,sorted_container)
+	function vc2010.sort_input_files(files,sorted_container)
 		local types = 
 		{	
 			h	= "ClInclude",
 
 		for _, current_file in ipairs(files) do
 			local translated_path = path.translate(current_file, '\\')
-			local ext = vs10_helpers.get_file_extension(translated_path)
+			local ext = vc2010.get_file_extension(translated_path)
 			if ext then
 				local type = types[ext]
 				if type then
 		_p(1,'</PropertyGroup>')
 	end
 	
-	function vs10_helpers.config_type(config)
+	function vc2010.config_type(config)
 		local t =
 		{	
 			SharedLib = "DynamicLibrary",
 			local cfg = premake.getconfig(prj, cfginfo.src_buildcfg, cfginfo.src_platform)
 			_p(1,'<PropertyGroup '..if_config_and_platform() ..' Label="Configuration">'
 					, premake.esc(cfginfo.name))
-				_p(2,'<ConfigurationType>%s</ConfigurationType>',vs10_helpers.config_type(cfg))
+				_p(2,'<ConfigurationType>%s</ConfigurationType>',vc2010.config_type(cfg))
 				_p(2,'<CharacterSet>%s</CharacterSet>',iif(cfg.flags.Unicode,"Unicode","MultiByte"))
 			
 			if cfg.flags.MFC then
 				_p(2,'<UseOfMfc>Dynamic</UseOfMfc>')
 			end
 			
-			local use_debug = "false"
-			if  not premake.config.isoptimizedbuild(cfg.flags) then 
-				use_debug = "true" 
-			else
-				_p(2,'<WholeProgramOptimization>true</WholeProgramOptimization>')
-			end
-				_p(2,'<UseDebugLibraries>%s</UseDebugLibraries>',use_debug)
-				
+			_p(2,'<UseDebugLibraries>%s</UseDebugLibraries>'
+				,iif(optimisation(cfg) == "Disabled","true","false"))				
 			_p(1,'</PropertyGroup>')
 		end
 	end
 							
 			common_link_section(cfg)
 			
-			if vs10_helpers.config_type(cfg) == 'Application' and not cfg.flags.WinMain then
+			if vc2010.config_type(cfg) == 'Application' and not cfg.flags.WinMain then
 				_p(3,'<EntryPointSymbol>mainCRTStartup</EntryPointSymbol>')
 			end
 
 		}
 		
 		cfg = premake.getconfig(prj)
-		vs10_helpers.sort_input_files(cfg.files,sorted)
+		vc2010.sort_input_files(cfg.files,sorted)
 		write_file_type_block(sorted.ClInclude,"ClInclude")
 		write_file_compile_block(sorted.ClCompile,prj,prj.solution.vstudio_configs)
 		write_file_type_block(sorted.None,'None')
 	end
 	
 	local function write_filter_includes(sorted_table)
-		local directories = vs10_helpers.table_of_file_filters(sorted_table)
+		local directories = vc2010.table_of_file_filters(sorted_table)
 		--I am going to take a punt here that the ItemGroup is missing if no files!!!!
 		--there is a test for this see
 		--vs10_filters.noInputFiles_bufferDoesNotContainTagItemGroup
 		if #files > 0  then
 			_p(1,'<ItemGroup>')
 			for _, current_file in ipairs(files) do
-				local path_to_file = vs10_helpers.file_path(current_file)
+				local path_to_file = vc2010.file_path(current_file)
 				if path_to_file then
 					_p(2,'<%s Include=\"%s\">', group_type,path.translate(current_file, "\\"))
 						_p(3,'<Filter>%s</Filter>',path_to_file)
 		}
 		
 		cfg = premake.getconfig(prj)
-		vs10_helpers.sort_input_files(cfg.files,sorted)
+		vc2010.sort_input_files(cfg.files,sorted)
 
 		io.eol = "\r\n"
 		_p(xml_version_and_encoding)
 	end
 	
 
-		
+		

src/actions/vstudio/vs_generic_solution.lua

+
+local vstudio = premake.vstudio
 
 local vs_format_version = function()
 	local t =
 	-- Write out the list of project entries
 	for prj in premake.solution.eachproject(sln) do
 		-- Build a relative path from the solution file to the project file
-		local projpath = path.translate(path.getrelative(sln.location, _VS.projectfile(prj)), "\\")
-		_p('Project("{%s}") = "%s", "%s", "{%s}"', _VS.tool(prj), prj.name, projpath, prj.uuid)	
+		local projpath = path.translate(path.getrelative(sln.location, vstudio.projectfile(prj)), "\\")
+		_p('Project("{%s}") = "%s", "%s", "{%s}"', vstudio.tool(prj), prj.name, projpath, prj.uuid)	
 		
 		local deps = premake.getdependencies(prj)
 		if #deps > 0 then
 
 local vs_write_pre_version = function(sln)
 	io.eol = '\r\n'
-	sln.vstudio_configs = premake.vstudio_buildconfigs(sln)		
+	sln.vstudio_configs = premake.vstudio.buildconfigs(sln)		
 	-- Mark the file as Unicode
 	_p('\239\187\191')
 end
 	vs_write_projects(sln)
 	
 	_p('Global')
-	premake.vs2005_solution_platforms(sln)
-	premake.vs2005_solution_project_platforms(sln)
-	premake.vs2005_solution_properties(sln)
+	vstudio.sln2005.platforms(sln)
+	vstudio.sln2005.project_platforms(sln)
+	vstudio.sln2005.properties(sln)
 	_p('EndGlobal')
 	
 end

src/base/cmdline.lua

 --
 -- cmdline.lua
 -- Functions to define and handle command line actions and options.
--- Copyright (c) 2002-2009 Jason Perkins and the Premake project
+-- Copyright (c) 2002-2011 Jason Perkins and the Premake project
 --
 
 
 		description = "Generate files for a different operating system",
 		allowed = {
 			{ "bsd",      "OpenBSD, NetBSD, or FreeBSD" },
+			{ "haiku",    "Haiku" },
 			{ "linux",    "Linux" },
 			{ "macosx",   "Apple Mac OS X" },
 			{ "solaris",  "Solaris" },

src/base/configs.lua

 		end
 		
 		-- build configuration objects for all files
+		-- TODO: can I build this as a tree instead, and avoid the extra
+		-- step of building it later?
 		cfg.__fileconfigs = { }
 		for _, fname in ipairs(cfg.files) do
 			cfg.terms.required = fname:lower()
 			end
 
 			-- add indexed by name and integer
+			-- TODO: when everything is converted to trees I won't need
+			-- to index by name any longer
 			fcfg.name = fname
 			cfg.__fileconfigs[fname] = fcfg
 			table.insert(cfg.__fileconfigs, fcfg)
 			for prjIx, prj in ipairs(sln.projects) do
 				if(not prj.usage) then
 					for cfgname, cfg in pairs(prj.__configs) do
-						printf("prj '%s', cfg '%s'", prj.name, cfgname);
-						printf("before:");
 						for _, linkName in ipairs(cfg.links) do
 							printf("\t link to '%s'.", linkName)
 						end
 						
 						local usesPrjs = getprojectsconnections(cfg, cfgname);
 						copyusagedata(cfg, cfgname, usesPrjs)
-						printf("after:");
 						for _, linkName in ipairs(cfg.links) do
 							printf("link to '%s'", linkName)
 						end
---
--- os.lua
--- Additions to the OS namespace.
--- Copyright (c) 2002-2010 Jason Perkins and the Premake project
---
-
-
---
--- Same as os.execute(), but accepts string formatting arguments.
---
-
-	function os.executef(cmd, ...)
-		cmd = string.format(cmd, unpack(arg))
-		return os.execute(cmd)
-	end
-
-
---
--- Scan the well-known system locations for a particular library.
---
-
-	function os.findlib(libname)
-		local path, formats
-		
-		-- assemble a search path, depending on the platform
-		if os.is("windows") then
-			formats = { "%s.dll", "%s" }
-			path = os.getenv("PATH")
-		else
-			if os.is("macosx") then
-				formats = { "lib%s.dylib", "%s.dylib" }
-				path = os.getenv("DYLD_LIBRARY_PATH")
-			else
-				formats = { "lib%s.so", "%s.so" }
-				path = os.getenv("LD_LIBRARY_PATH") or ""
-	
-				io.input("/etc/ld.so.conf")
-				if io.input() then
-					for line in io.lines() do
-						path = path .. ":" .. line
-					end
-					io.input():close()
-				end
-			end
-			
-			table.insert(formats, "%s")	
-			path = (path or "") .. ":/lib:/usr/lib:/usr/local/lib"
-		end
-		
-		for _, fmt in ipairs(formats) do
-			local name = string.format(fmt, libname)
-			local result = os.pathsearch(name, path)
-			if result then return result end
-		end
-	end
-	
-	
-	
---
--- Retrieve the current operating system ID string.
---
-
-	function os.get()
-		return _OPTIONS.os or _OS
-	end
-	
-
-	
---
--- Check the current operating system; may be set with the /os command line flag.
---
-
-	function os.is(id)
-		return (os.get():lower() == id:lower())
-	end
-	
-	
-
---
--- The os.matchdirs() and os.matchfiles() functions
---
-	
-	local function domatch(result, mask, wantfiles)
-		-- need to remove extraneous path info from the mask to ensure a match
-		-- against the paths returned by the OS. Haven't come up with a good 
-		-- way to do it yet, so will handle cases as they come up
-		if mask:startswith("./") then
-			mask = mask:sub(3)
-		end
-
-		-- strip off any leading directory information to find out
-		-- where the search should take place
-		local basedir = mask
-		local starpos = mask:find("%*")
-		if starpos then
-			basedir = basedir:sub(1, starpos - 1)
-		end
-		basedir = path.getdirectory(basedir)
-		if (basedir == ".") then basedir = "" end
-
-		-- recurse into subdirectories?
-		local recurse = mask:find("**", nil, true)
-		
-		-- convert mask to a Lua pattern
-		mask = path.wildcards(mask)
-
-		local function matchwalker(basedir)
-			local wildcard = path.join(basedir, "*")
-			
-			-- retrieve files from OS and test against mask
-			local m = os.matchstart(wildcard)
-			while (os.matchnext(m)) do
-				local isfile = os.matchisfile(m)
-				if ((wantfiles and isfile) or (not wantfiles and not isfile)) then
-					local fname = path.join(basedir, os.matchname(m))
-					if fname:match(mask) == fname then
-						table.insert(result, fname)
-					end
-				end
-			end
-			os.matchdone(m)
-
-			-- check subdirectories
-			if recurse then
-				m = os.matchstart(wildcard)
-				while (os.matchnext(m)) do
-					if not os.matchisfile(m) then
-						local dirname = os.matchname(m)
-						matchwalker(path.join(basedir, dirname))
-					end
-				end
-				os.matchdone(m)
-			end
-		end
-
-		matchwalker(basedir)
-	end
-	
-	function os.matchdirs(...)
-		local result = { }
-		for _, mask in ipairs(arg) do
-			domatch(result, mask, false)
-		end
-		return result
-	end
-	
-	function os.matchfiles(...)
-		local result = { }
-		for _, mask in ipairs(arg) do
-			domatch(result, mask, true)
-		end
-		return result
-	end
-	
-	
-	
---
--- An overload of the os.mkdir() function, which will create any missing
--- subdirectories along the path.
---
-
-	local builtin_mkdir = os.mkdir
-	function os.mkdir(p)
-		local dir = iif(p:startswith("/"), "/", "")
-		for part in p:gmatch("[^/]+") do
-			dir = dir .. part
-			
-			if (part ~= "" and not path.isabsolute(part) and not os.isdir(dir)) then
-				local ok, err = builtin_mkdir(dir)
-				if (not ok) then
-					return nil, err
-				end
-			end
-						
-			dir = dir .. "/"
-		end
-		
-		return true
-	end
-
-
---
--- Remove a directory, along with any contained files or subdirectories.
---
-
-	local builtin_rmdir = os.rmdir
-	function os.rmdir(p)
-		-- recursively remove subdirectories
-		local dirs = os.matchdirs(p .. "/*")
-		for _, dname in ipairs(dirs) do
-			os.rmdir(dname)
-		end
-
-		-- remove any files
-		local files = os.matchfiles(p .. "/*")
-		for _, fname in ipairs(files) do
-			os.remove(fname)
-		end
-				
-		-- remove this directory
-		builtin_rmdir(p)
-	end
-	
+--
+-- os.lua
+-- Additions to the OS namespace.
+-- Copyright (c) 2002-2011 Jason Perkins and the Premake project
+--
+
+
+--
+-- Same as os.execute(), but accepts string formatting arguments.
+--
+
+	function os.executef(cmd, ...)
+		cmd = string.format(cmd, unpack(arg))
+		return os.execute(cmd)
+	end
+
+
+--
+-- Scan the well-known system locations for a particular library.
+--
+
+	function os.findlib(libname)
+		local path, formats
+		
+		-- assemble a search path, depending on the platform
+		if os.is("windows") then
+			formats = { "%s.dll", "%s" }
+			path = os.getenv("PATH")
+		elseif os.is("haiku") then
+			formats = { "lib%s.so", "%s.so" }
+			path = os.getenv("LIBRARY_PATH")
+		else
+			if os.is("macosx") then
+				formats = { "lib%s.dylib", "%s.dylib" }
+				path = os.getenv("DYLD_LIBRARY_PATH")
+			else
+				formats = { "lib%s.so", "%s.so" }
+				path = os.getenv("LD_LIBRARY_PATH") or ""
+	
+				io.input("/etc/ld.so.conf")
+				if io.input() then
+					for line in io.lines() do
+						path = path .. ":" .. line
+					end
+					io.input():close()
+				end
+			end
+			
+			table.insert(formats, "%s")	
+			path = (path or "") .. ":/lib:/usr/lib:/usr/local/lib"
+		end
+		
+		for _, fmt in ipairs(formats) do
+			local name = string.format(fmt, libname)
+			local result = os.pathsearch(name, path)
+			if result then return result end
+		end
+	end
+	
+	
+	
+--
+-- Retrieve the current operating system ID string.
+--
+
+	function os.get()
+		return _OPTIONS.os or _OS
+	end
+	
+
+	
+--
+-- Check the current operating system; may be set with the /os command line flag.
+--
+
+	function os.is(id)
+		return (os.get():lower() == id:lower())
+	end
+	
+	
+
+--
+-- The os.matchdirs() and os.matchfiles() functions
+--
+	
+	local function domatch(result, mask, wantfiles)
+		-- need to remove extraneous path info from the mask to ensure a match
+		-- against the paths returned by the OS. Haven't come up with a good 
+		-- way to do it yet, so will handle cases as they come up
+		if mask:startswith("./") then
+			mask = mask:sub(3)
+		end
+
+		-- strip off any leading directory information to find out
+		-- where the search should take place
+		local basedir = mask
+		local starpos = mask:find("%*")
+		if starpos then
+			basedir = basedir:sub(1, starpos - 1)
+		end
+		basedir = path.getdirectory(basedir)
+		if (basedir == ".") then basedir = "" end
+
+		-- recurse into subdirectories?
+		local recurse = mask:find("**", nil, true)
+		
+		-- convert mask to a Lua pattern
+		mask = path.wildcards(mask)
+
+		local function matchwalker(basedir)
+			local wildcard = path.join(basedir, "*")
+			
+			-- retrieve files from OS and test against mask
+			local m = os.matchstart(wildcard)
+			while (os.matchnext(m)) do
+				local isfile = os.matchisfile(m)
+				if ((wantfiles and isfile) or (not wantfiles and not isfile)) then
+					local fname = path.join(basedir, os.matchname(m))
+					if fname:match(mask) == fname then
+						table.insert(result, fname)
+					end
+				end
+			end
+			os.matchdone(m)
+
+			-- check subdirectories
+			if recurse then
+				m = os.matchstart(wildcard)
+				while (os.matchnext(m)) do
+					if not os.matchisfile(m) then
+						local dirname = os.matchname(m)
+						matchwalker(path.join(basedir, dirname))
+					end
+				end
+				os.matchdone(m)
+			end
+		end
+
+		matchwalker(basedir)
+	end
+	
+	function os.matchdirs(...)
+		local result = { }
+		for _, mask in ipairs(arg) do
+			domatch(result, mask, false)
+		end
+		return result
+	end
+	
+	function os.matchfiles(...)
+		local result = { }
+		for _, mask in ipairs(arg) do
+			domatch(result, mask, true)
+		end
+		return result
+	end
+	
+	
+	
+--
+-- An overload of the os.mkdir() function, which will create any missing
+-- subdirectories along the path.
+--
+
+	local builtin_mkdir = os.mkdir
+	function os.mkdir(p)
+		local dir = iif(p:startswith("/"), "/", "")
+		for part in p:gmatch("[^/]+") do
+			dir = dir .. part
+			
+			if (part ~= "" and not path.isabsolute(part) and not os.isdir(dir)) then
+				local ok, err = builtin_mkdir(dir)
+				if (not ok) then
+					return nil, err
+				end
+			end
+						
+			dir = dir .. "/"
+		end
+		
+		return true
+	end
+
+
+--
+-- Remove a directory, along with any contained files or subdirectories.
+--
+
+	local builtin_rmdir = os.rmdir
+	function os.rmdir(p)
+		-- recursively remove subdirectories
+		local dirs = os.matchdirs(p .. "/*")
+		for _, dname in ipairs(dirs) do
+			os.rmdir(dname)
+		end
+
+		-- remove any files
+		local files = os.matchfiles(p .. "/*")
+		for _, fname in ipairs(files) do
+			os.remove(fname)
+		end
+				
+		-- remove this directory
+		builtin_rmdir(p)
+	end
+	

src/base/project.lua

 
 	function premake.project.buildsourcetree(prj)
 		local tr = premake.tree.new(prj.name)
-		for _, fname in ipairs(prj.files) do
-			local node = premake.tree.add(tr, fname)
+		tr.project = prj
+
+		for fcfg in premake.eachfile(prj) do
+			local node = premake.tree.add(tr, fcfg.name)
+			node.cfg = fcfg
 		end
+
 		premake.tree.sort(tr)
-		tr.project = prj
 		return tr
 	end
 

src/base/tree.lua

 -- @param t
 --    The tree to traverse.
 -- @param fn
---    A collection of callback functions, which may contain:
+--    A collection of callback functions, which may contain any or all of the
+--    following entries. Entries are called in this order.
 --
---    onnode(node, depth)   - called on each node encountered
---    onleaf(node, depth)   - called only on leaf nodes
---    onbranch(node, depth) - called only on branch nodes
+--    onnode         - called on each node encountered
+--    onbranchenter  - called on branches, before processing children
+--    onbranch       - called only on branch nodes
+--    onleaf         - called only on leaf nodes
+--    onbranchexit   - called on branches, after processing children
+--
+--    Callbacks receive two arguments: the node being processed, and the
+--    current traversal depth.
 --
 -- @param includeroot
 --    True to include the root node in the traversal, otherwise it will be skipped.
+-- @param initialdepth
+--    An optional starting value for the traversal depth; defaults to zero.
 --
 
-	function premake.tree.traverse(t, fn, includeroot)
+	function premake.tree.traverse(t, fn, includeroot, initialdepth)
 
+		-- forward declare my handlers, which call each other
 		local donode, dochildren
+
+		-- process an individual node
 		donode = function(node, fn, depth)
 			if node.isremoved then 
 				return 
 			end
+
 			if fn.onnode then 
 				fn.onnode(node, depth) 
 			end
+			
 			if #node.children > 0 then
+				if fn.onbranchenter then
+					fn.onbranchenter(node, depth)
+				end
 				if fn.onbranch then