Commits

Dimitar Trendafilov committed b13e747 Merge

Merge with the new API

Comments (0)

Files changed (67)

src/_manifest.lua

 		"base/tree.lua",
 		"base/project.lua",
 		"base/config.lua",
-		"base/bake.lua",
 		"base/validate.lua",
 		"base/help.lua",
 		"base/premake.lua",
 		
 		-- configuration APIs
-		"base/api.lua",		
 		"base/configset.lua",
 		"base/context.lua",
+		"base/api.lua",
+		"base/detoken.lua",
 		
 		-- runtime environment setup
 		"_premake_init.lua",
 		"tools/ow.lua",
 		"tools/snc.lua",
 
-		-- CodeBlocks action
-		"actions/codeblocks/_codeblocks.lua",
-		"actions/codeblocks/codeblocks_workspace.lua",
-		"actions/codeblocks/codeblocks_cbp.lua",
-		
-		-- CodeLite action
-		"actions/codelite/_codelite.lua",
-		"actions/codelite/codelite_workspace.lua",
-		"actions/codelite/codelite_project.lua",
-		
 		-- GNU make action
 		"actions/make/_make.lua",
 		"actions/make/make_solution.lua",
 		"actions/vstudio/vs2010_vcxproj.lua",
 		"actions/vstudio/vs2010_vcxproj_user.lua",
 		"actions/vstudio/vs2010_vcxproj_filters.lua",
-	
-		-- Xcode action
-		"actions/xcode/_xcode.lua",
-		"actions/xcode/xcode_common.lua",
-		"actions/xcode/xcode_project.lua",
-		
-		-- Xcode4 action
-		"actions/xcode/xcode4_workspace.lua",
-		
+
 		-- Clean action
 		"actions/clean/_clean.lua",
 	}

src/_premake_init.lua

 -- Copyright (c) 2012 Jason Perkins and the Premake project
 --
 
-	local configset = premake.configset
-
-
---
--- Create a "root" configuration set, to hold the global configuration. Values
--- that are added to this set become available for all add-ons, solution, projects,
--- and on down the line.
---
-
-	premake.root = configset.new()
-	local root = premake.root
-
 
 --
 -- Set up the global environment for the systems I know about. I would like to see
 -- at least some if not all of this moved into add-ons in the future.
 --
--- TODO: use the same configuration API as the user project scripts, once they
--- have been ported, like:
---
---     configuration { "Windows or Xbox360", "SharedLib" }
---         targetprefix ""
---         targetextension ".dll"
---         implibextension ".lib"
---
 
 --
 -- Use Posix-style target naming by default, since it is the most common.
 --
 
-	configset.addblock(root, { "SharedLib" })
-	
-		configset.addvalue(root, "targetprefix", "lib")
-		configset.addvalue(root, "targetextension", ".so")
+	configuration { "SharedLib" }
+		targetprefix "lib"
+		targetextension ".so"
 
-	configset.addblock(root, { "StaticLib" })
-	
-		configset.addvalue(root, "targetprefix", "lib")
-		configset.addvalue(root, "targetextension", ".a")
+	configuration { "StaticLib" }
+		targetprefix "lib"
+		targetextension ".a"
 
 
 --
 -- Add variations for other Posix-like systems.
 --
 
-	configset.addblock(root, { "MacOSX", "SharedLib" })
-	
-		configset.addvalue(root, "targetextension", ".dylib")
+	configuration { "MacOSX", "SharedLib" }
+		targetextension ".dylib"
 
-	configset.addblock(root, { "PS3", "ConsoleApp" })
-	
-		configset.addvalue(root, "targetextension", ".elf")
+	configuration { "PS3", "ConsoleApp" }
+		targetextension ".elf"
 
 
 --
 -- Windows and friends.
 --
 
-	configset.addblock(root, { "Windows", "ConsoleApp" })
-	
-		configset.addvalue(root, "targetextension", ".exe")
+	configuration { "Windows or Xbox360 or C#", "ConsoleApp or WindowedApp" }
+		targetextension ".exe"
 
-	configset.addblock(root, { "Windows", "WindowedApp" })
-	
-		configset.addvalue(root, "targetextension", ".exe")
+	configuration { "Windows or Xbox360 or C#", "SharedLib" }
+		targetprefix ""
+		targetextension ".dll"
+		implibextension ".lib"
 
-	configset.addblock(root, { "Windows", "SharedLib" })
-	
-		configset.addvalue(root, "targetprefix", "")
-		configset.addvalue(root, "targetextension", ".dll")
-		configset.addvalue(root, "implibextension", ".lib")
-
-	configset.addblock(root, { "Windows", "StaticLib" })
-	
-		configset.addvalue(root, "targetprefix", "")
-		configset.addvalue(root, "targetextension", ".lib")
-
-	configset.addblock(root, { "Xbox360", "ConsoleApp" })
-	
-		configset.addvalue(root, "targetextension", ".exe")
-
-	configset.addblock(root, { "Xbox360", "WindowedApp" })
-	
-		configset.addvalue(root, "targetextension", ".exe")
-
-	configset.addblock(root, { "Xbox360", "SharedLib" })
-	
-		configset.addvalue(root, "targetprefix", "")
-		configset.addvalue(root, "targetextension", ".dll")
-		configset.addvalue(root, "implibextension", ".lib")
-
-	configset.addblock(root, { "Xbox360", "StaticLib" })
-	
-		configset.addvalue(root, "targetprefix", "")
-		configset.addvalue(root, "targetextension", ".lib")
-
-
---
--- .NET languages always use Windows-style naming.
---
-
-	configset.addblock(root, { "C#", "ConsoleApp" })
-	
-		configset.addvalue(root, "targetextension", ".exe")
-
-	configset.addblock(root, { "C#", "WindowedApp" })
-	
-		configset.addvalue(root, "targetextension", ".exe")
-
-	configset.addblock(root, { "C#", "SharedLib" })
-	
-		configset.addvalue(root, "targetprefix", "")
-		configset.addvalue(root, "targetextension", ".dll")
+	configuration { "Windows or Xbox360 or C#", "StaticLib" }
+		targetprefix ""
+		targetextension ".lib"

src/_premake_main.lua

 --
 -- _premake_main.lua
 -- Script-side entry point for the main program logic.
--- Copyright (c) 2002-2011 Jason Perkins and the Premake project
+-- Copyright (c) 2002-2012 Jason Perkins and the Premake project
 --
 
 
 
 
 --
--- Inject a new target platform into each solution; called if the --platform
--- argument was specified on the command line.
---
-
-	local function injectplatform(platform)
-		if not platform then return true end
-		platform = premake.checkvalue(platform, premake.fields.platforms.allowed)
-		
-		for sln in premake.solution.each() do
-			local platforms = sln.platforms or { }
-			
-			-- an empty table is equivalent to a native build
-			if #platforms == 0 then
-				table.insert(platforms, "Native")
-			end
-			
-			-- the solution must provide a native build in order to support this feature
-			if not table.contains(platforms, "Native") then
-				return false, sln.name .. " does not target native platform\nNative platform settings are required for the --platform feature."
-			end
-			
-			-- add it to the end of the list, if it isn't in there already
-			if not table.contains(platforms, platform) then
-				table.insert(platforms, platform)
-			end
-			
-			sln.platforms = platforms
-		end
-		
-		return true
-	end
-	
-
---
 -- Script-side program entry point.
 --
 
 		if (not ok) then error("Error: " .. err, 0) end
 		
 		
-		-- If a platform was specified on the command line, inject it now
-
-		ok, err = injectplatform(_OPTIONS["platform"])
-		if (not ok) then error("Error: " .. err, 0) end
-
-		
 		-- Quick hack: disable the old configuration baking logic for the new
 		-- next-gen actions; this code will go away when everything has been
 		-- ported to the new API
 		print("Building configurations...")
-		if not action.isnextgen then
-			premake.bake.buildconfigs()		
-			ok, err = premake.checkprojects()
-			if (not ok) then error("Error: " .. err, 0) end
-		else
-			premake.solution.bakeall()
-		end
-			
+		premake.solution.bakeall()
+
 		
 		-- Hand over control to the action
 		printf("Running action '%s'...", action.trigger)

src/actions/clean/_clean.lua

 -- Register the "clean" action.
 --
 
+	--[[
 	newaction {
 		trigger     = "clean",
 		description = "Remove all binaries and generated files",
 			end
 		end
 	}
+	--]]

src/actions/codeblocks/_codeblocks.lua

---
--- _codeblocks.lua
--- Define the Code::Blocks action(s).
--- Copyright (c) 2002-2011 Jason Perkins and the Premake project
---
-
-	premake.codeblocks = { }
-
-	newaction {
-		trigger         = "codeblocks",
-		shortname       = "Code::Blocks",
-		description     = "Generate Code::Blocks project files",
-		
-		valid_kinds     = { "ConsoleApp", "WindowedApp", "StaticLib", "SharedLib" },
-		
-		valid_languages = { "C", "C++" },
-		
-		valid_tools     = {
-			cc   = { "gcc", "ow" },
-		},
-		
-		onsolution = function(sln)
-			premake.generate(sln, ".workspace", premake.codeblocks.workspace)
-		end,
-		
-		onproject = function(prj)
-			premake.generate(prj, ".cbp", premake.codeblocks.cbp)
-		end,
-		
-		oncleansolution = function(sln)
-			premake.clean.file(sln, "%%.workspace")
-		end,
-		
-		oncleanproject = function(prj)
-			premake.clean.file(prj, "%%.cbp")
-			premake.clean.file(prj, "%%.depend")
-			premake.clean.file(prj, "%%.layout")
-		end
-	}

src/actions/codeblocks/codeblocks_cbp.lua

---
--- codeblocks_cbp.lua
--- Generate a Code::Blocks C/C++ project.
--- Copyright (c) 2009, 2011 Jason Perkins and the Premake project
---
-
-	local codeblocks = premake.codeblocks
-
-
---
--- Write out a list of the source code files in the project.
---
-
-	function codeblocks.files(prj)
-		local pchheader
-		if (prj.pchheader) then
-			pchheader = path.getrelative(prj.location, prj.pchheader)
-		end
-		
-		for fcfg in premake.project.eachfile(prj) do
-			_p(2,'<Unit filename="%s">', premake.esc(fcfg.name))
-			if fcfg.name ~= fcfg.vpath then
-				_p(3,'<Option virtualFolder="%s" />', path.getdirectory(fcfg.vpath))
-			end
-			if path.isresourcefile(fcfg.name) then
-				_p(3,'<Option compilerVar="WINDRES" />')
-			elseif path.iscfile(fcfg.name) and prj.language == "C++" then
-				_p(3,'<Option compilerVar="CC" />')
-			end
-			if not prj.flags.NoPCH and fcfg.name == pchheader then
-				_p(3,'<Option compilerVar="%s" />', iif(prj.language == "C", "CC", "CPP"))
-				_p(3,'<Option compile="1" />')
-				_p(3,'<Option weight="0" />')
-				_p(3,'<Add option="-x c++-header" />')
-			end
-			_p(2,'</Unit>')
-		end
-	end
-
-	function premake.codeblocks.debugenvs(cfg)
-		--Assumption: if gcc is being used then so is gdb although this section will be ignored by
-		--other debuggers. If using gcc and not gdb it will silently not pass the
-		--environment arguments to the debugger
-		if premake.gettool(cfg) == premake.gcc then
-			_p(3,'<debugger>')
-				_p(4,'<remote_debugging target="%s">', premake.esc(cfg.longname))
-					local args = ''
-					local sz = #cfg.debugenvs
-					for idx, v in ipairs(cfg.debugenvs) do
-						args = args .. 'set env ' .. v 
-						if sz ~= idx then args = args .. '&#x0A;' end
-					end
-					_p(5,'<options additional_cmds_before="%s" />',args)
-				_p(4,'</remote_debugging>')
-			_p(3,'</debugger>')
-		else
-			 error('Sorry at this moment there is no support for debug environment variables with this debugger and codeblocks')
-		end
-	end
-	
---
--- The main function: write out the project file.
---
-	
-	function premake.codeblocks.cbp(prj)
-		-- alias the C/C++ compiler interface
-		local cc = premake.gettool(prj)
-		
-		_p('<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>')
-		_p('<CodeBlocks_project_file>')
-		_p(1,'<FileVersion major="1" minor="6" />')
-		
-		-- write project block header
-		_p(1,'<Project>')
-		_p(2,'<Option title="%s" />', premake.esc(prj.name))
-		_p(2,'<Option pch_mode="2" />')
-		_p(2,'<Option compiler="%s" />', _OPTIONS.cc)
-
-		-- build a list of supported target platforms; I don't support cross-compiling yet
-		local platforms = premake.filterplatforms(prj.solution, cc.platforms, "Native")
-		for i = #platforms, 1, -1 do
-			if premake.platforms[platforms[i]].iscrosscompiler then
-				table.remove(platforms, i)
-			end
-		end 
-		
-		-- write configuration blocks
-		_p(2,'<Build>')
-		for _, platform in ipairs(platforms) do		
-			for cfg in premake.eachconfig(prj, platform) do
-				_p(3,'<Target title="%s">', premake.esc(cfg.longname))
-				
-				_p(4,'<Option output="%s" prefix_auto="0" extension_auto="0" />', premake.esc(cfg.buildtarget.fullpath))
-				
-				if cfg.debugdir then
-					_p(4,'<Option working_dir="%s" />', premake.esc(cfg.debugdir))
-				end
-				
-				_p(4,'<Option object_output="%s" />', premake.esc(cfg.objectsdir))
-
-				-- identify the type of binary
-				local types = { WindowedApp = 0, ConsoleApp = 1, StaticLib = 2, SharedLib = 3 }
-				_p(4,'<Option type="%d" />', types[cfg.kind])
-
-				_p(4,'<Option compiler="%s" />', _OPTIONS.cc)
-				
-				if (cfg.kind == "SharedLib") then
-					_p(4,'<Option createDefFile="0" />')
-					_p(4,'<Option createStaticLib="%s" />', iif(cfg.flags.NoImportLib, 0, 1))
-				end
-
-				-- begin compiler block --
-				_p(4,'<Compiler>')
-				for _,flag in ipairs(table.join(cc.getcflags(cfg), cc.getcxxflags(cfg), cc.getdefines(cfg.defines), cfg.buildoptions)) do
-					_p(5,'<Add option="%s" />', premake.esc(flag))
-				end
-				if not cfg.flags.NoPCH and cfg.pchheader then
-					_p(5,'<Add option="-Winvalid-pch" />')
-					_p(5,'<Add option="-include &quot;%s&quot;" />', premake.esc(cfg.pchheader))
-				end
-				for _,v in ipairs(cfg.includedirs) do
-					_p(5,'<Add directory="%s" />', premake.esc(v))
-				end
-				_p(4,'</Compiler>')
-				-- end compiler block --
-				
-				-- begin linker block --
-				_p(4,'<Linker>')
-				for _,flag in ipairs(table.join(cc.getldflags(cfg), cfg.linkoptions)) do
-					_p(5,'<Add option="%s" />', premake.esc(flag))
-				end
-				for _,v in ipairs(premake.getlinks(cfg, "all", "directory")) do
-					_p(5,'<Add directory="%s" />', premake.esc(v))
-				end
-				for _,v in ipairs(premake.getlinks(cfg, "all", "basename")) do
-					_p(5,'<Add library="%s" />', premake.esc(v))
-				end
-				_p(4,'</Linker>')
-				-- end linker block --
-				
-				-- begin resource compiler block --
-				if premake.findfile(cfg, ".rc") then
-					_p(4,'<ResourceCompiler>')
-					for _,v in ipairs(cfg.includedirs) do
-						_p(5,'<Add directory="%s" />', premake.esc(v))
-					end
-					for _,v in ipairs(cfg.resincludedirs) do
-						_p(5,'<Add directory="%s" />', premake.esc(v))
-					end
-					_p(4,'</ResourceCompiler>')
-				end
-				-- end resource compiler block --
-				
-				-- begin build steps --
-				if #cfg.prebuildcommands > 0 or #cfg.postbuildcommands > 0 then
-					_p(4,'<ExtraCommands>')
-					for _,v in ipairs(cfg.prebuildcommands) do
-						_p(5,'<Add before="%s" />', premake.esc(v))
-					end
-					for _,v in ipairs(cfg.postbuildcommands) do
-						_p(5,'<Add after="%s" />', premake.esc(v))
-					end
-
-					_p(4,'</ExtraCommands>')
-				end
-				-- end build steps --
-				
-				_p(3,'</Target>')
-			end
-		end
-		_p(2,'</Build>')
-		
-		codeblocks.files(prj)
-		
-		_p(2,'<Extensions>')
-        for _, platform in ipairs(platforms) do
-			for cfg in premake.eachconfig(prj, platform) do
-				if cfg.debugenvs and #cfg.debugenvs > 0 then
-					premake.codeblocks.debugenvs(cfg)
-				end
-			end
-		end
-		_p(2,'</Extensions>')
-
-		_p(1,'</Project>')
-		_p('</CodeBlocks_project_file>')
-		_p('')
-		
-	end

src/actions/codeblocks/codeblocks_workspace.lua

---
--- codeblocks_workspace.lua
--- Generate a Code::Blocks workspace.
--- Copyright (c) 2009 Jason Perkins and the Premake project
---
-
-	function premake.codeblocks.workspace(sln)
-		_p('<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>')
-		_p('<CodeBlocks_workspace_file>')
-		_p(1,'<Workspace title="%s">', sln.name)
-		
-		for prj in premake.solution.eachproject(sln) do
-			local fname = path.join(path.getrelative(sln.location, prj.location), prj.name)
-			local active = iif(prj.project == sln.projects[1], ' active="1"', '')
-			
-			_p(2,'<Project filename="%s.cbp"%s>', fname, active)
-			for _,dep in ipairs(premake.getdependencies(prj)) do
-				_p(3,'<Depends filename="%s.cbp" />', path.join(path.getrelative(sln.location, dep.location), dep.name))
-			end
-		
-			_p(2,'</Project>')
-		end
-		
-		_p(1,'</Workspace>')
-		_p('</CodeBlocks_workspace_file>')
-	end
-

src/actions/codelite/_codelite.lua

---
--- _codelite.lua
--- Define the CodeLite action(s).
--- Copyright (c) 2008-2009 Jason Perkins and the Premake project
---
-
-	premake.codelite = { }
-
-	newaction {
-		trigger         = "codelite",
-		shortname       = "CodeLite",
-		description     = "Generate CodeLite project files",
-	
-		valid_kinds     = { "ConsoleApp", "WindowedApp", "StaticLib", "SharedLib" },
-		
-		valid_languages = { "C", "C++" },
-		
-		valid_tools     = {
-			cc   = { "gcc" },
-		},
-		
-		onsolution = function(sln)
-			premake.generate(sln, ".workspace", premake.codelite.workspace)
-		end,
-		
-		onproject = function(prj)
-			premake.generate(prj, ".project", premake.codelite.project)
-		end,
-		
-		oncleansolution = function(sln)
-			premake.clean.file(sln, "%%.workspace")
-			premake.clean.file(sln, "%%_wsp.mk")
-			premake.clean.file(sln, "%%.tags")
-		end,
-		
-		oncleanproject = function(prj)
-			premake.clean.file(prj, "%%.project")
-			premake.clean.file(prj, "%%.mk")
-			premake.clean.file(prj, "%%.list")
-			premake.clean.file(prj, "%%.out")
-		end
-	}

src/actions/codelite/codelite_project.lua

---
--- codelite_project.lua
--- Generate a CodeLite C/C++ project file.
--- Copyright (c) 2009, 2011 Jason Perkins and the Premake project
---
-
-	local codelite = premake.codelite
-	local tree = premake.tree
-
-
---
--- Write out a list of the source code files in the project.
---
-
-	function codelite.files(prj)
-		local tr = premake.project.buildsourcetree(prj)
-		tree.traverse(tr, {
-			
-			-- folders are handled at the internal nodes
-			onbranchenter = function(node, depth)
-				_p(depth, '<VirtualDirectory Name="%s">', node.name)
-			end,
-
-			onbranchexit = function(node, depth)
-				_p(depth, '</VirtualDirectory>')
-			end,
-
-			-- source files are handled at the leaves
-			onleaf = function(node, depth)
-				_p(depth, '<File Name="%s"/>', node.cfg.name)
-			end,
-			
-		}, false, 1)
-	end
-	
-
---
--- The main function: write out the project file.
---
-
-	function premake.codelite.project(prj)
-		io.indent = "  "
-		
-		_p('<?xml version="1.0" encoding="utf-8"?>')
-		_p('<CodeLite_Project Name="%s">', premake.esc(prj.name))
-
-		-- Write out the list of source code files in the project
-		codelite.files(prj)
-
-		local types = { 
-			ConsoleApp  = "Executable", 
-			WindowedApp = "Executable", 
-			StaticLib   = "Static Library",
-			SharedLib   = "Dynamic Library",
-		}
-		_p('  <Settings Type="%s">', types[prj.kind])
-		
-		-- build a list of supported target platforms; I don't support cross-compiling yet
-		local platforms = premake.filterplatforms(prj.solution, premake[_OPTIONS.cc].platforms, "Native")
-		for i = #platforms, 1, -1 do
-			if premake.platforms[platforms[i]].iscrosscompiler then
-				table.remove(platforms, i)
-			end
-		end 
-
-		for _, platform in ipairs(platforms) do
-			for cfg in premake.eachconfig(prj, platform) do
-				local name = premake.esc(cfg.longname)
-				local compiler = iif(cfg.language == "C", "gcc", "g++")
-				_p('    <Configuration Name="%s" CompilerType="gnu %s" DebuggerType="GNU gdb debugger" Type="%s">', name, compiler, types[cfg.kind])
-			
-				local fname  = premake.esc(cfg.buildtarget.fullpath)
-				local objdir = premake.esc(cfg.objectsdir)
-				local runcmd = cfg.buildtarget.name
-				local rundir = cfg.debugdir or cfg.buildtarget.directory
-				local runargs = table.concat(cfg.debugargs, " ")
-				local pause  = iif(cfg.kind == "WindowedApp", "no", "yes")
-				_p('      <General OutputFile="%s" IntermediateDirectory="%s" Command="./%s" CommandArguments="%s" WorkingDirectory="%s" PauseExecWhenProcTerminates="%s"/>', fname, objdir, runcmd, runargs, rundir, pause)
-				
-				-- begin compiler block --
-				local flags = premake.esc(table.join(premake.gcc.getcflags(cfg), premake.gcc.getcxxflags(cfg), cfg.buildoptions))
-				_p('      <Compiler Required="yes" Options="%s">', table.concat(flags, ";"))
-				for _,v in ipairs(cfg.includedirs) do
-					_p('        <IncludePath Value="%s"/>', premake.esc(v))
-				end
-				for _,v in ipairs(cfg.defines) do
-					_p('        <Preprocessor Value="%s"/>', premake.esc(v))
-				end
-				_p('      </Compiler>')
-				-- end compiler block --
-				
-				-- begin linker block --
-				flags = premake.esc(table.join(premake.gcc.getldflags(cfg), cfg.linkoptions))
-				_p('      <Linker Required="yes" Options="%s">', table.concat(flags, ";"))
-				for _,v in ipairs(premake.getlinks(cfg, "all", "directory")) do
-					_p('        <LibraryPath Value="%s" />', premake.esc(v))
-				end
-				for _,v in ipairs(premake.getlinks(cfg, "all", "basename")) do
-					_p('        <Library Value="%s" />', premake.esc(v))
-				end
-				_p('      </Linker>')
-				-- end linker block --
-				
-				-- begin resource compiler block --
-				if premake.findfile(cfg, ".rc") then
-					local defines = table.implode(table.join(cfg.defines, cfg.resdefines), "-D", ";", "")
-					local options = table.concat(cfg.resoptions, ";")
-					_p('      <ResourceCompiler Required="yes" Options="%s%s">', defines, options)
-					for _,v in ipairs(table.join(cfg.includedirs, cfg.resincludedirs)) do
-						_p('        <IncludePath Value="%s"/>', premake.esc(v))
-					end
-					_p('      </ResourceCompiler>')
-				else
-					_p('      <ResourceCompiler Required="no" Options=""/>')
-				end
-				-- end resource compiler block --
-				
-				-- begin build steps --
-				if #cfg.prebuildcommands > 0 then
-					_p('      <PreBuild>')
-					for _,v in ipairs(cfg.prebuildcommands) do
-						_p('        <Command Enabled="yes">%s</Command>', premake.esc(v))
-					end
-					_p('      </PreBuild>')
-				end
-				if #cfg.postbuildcommands > 0 then
-					_p('      <PostBuild>')
-					for _,v in ipairs(cfg.postbuildcommands) do
-						_p('        <Command Enabled="yes">%s</Command>', premake.esc(v))
-					end
-					_p('      </PostBuild>')
-				end
-				-- end build steps --
-				
-				_p('      <CustomBuild Enabled="no">')
-				_p('        <CleanCommand></CleanCommand>')
-				_p('        <BuildCommand></BuildCommand>')
-				_p('        <SingleFileCommand></SingleFileCommand>')
-				_p('        <MakefileGenerationCommand></MakefileGenerationCommand>')
-				_p('        <ThirdPartyToolName>None</ThirdPartyToolName>')
-				_p('        <WorkingDirectory></WorkingDirectory>')
-				_p('      </CustomBuild>')
-				_p('      <AdditionalRules>')
-				_p('        <CustomPostBuild></CustomPostBuild>')
-				_p('        <CustomPreBuild></CustomPreBuild>')
-				_p('      </AdditionalRules>')
-				_p('    </Configuration>')
-			end
-		end
-		_p('  </Settings>')
-
-		for _, platform in ipairs(platforms) do
-			for cfg in premake.eachconfig(prj, platform) do
-				_p('  <Dependencies name="%s">', cfg.longname)
-				for _,dep in ipairs(premake.getdependencies(prj)) do
-					_p('    <Project Name="%s"/>', dep.name)
-				end
-				_p('  </Dependencies>')
-			end
-		end
-		
-		_p('</CodeLite_Project>')
-	end

src/actions/codelite/codelite_workspace.lua

---
--- codelite_workspace.lua
--- Generate a CodeLite workspace file.
--- Copyright (c) 2009, 2011 Jason Perkins and the Premake project
---
-
-	function premake.codelite.workspace(sln)
-		_p('<?xml version="1.0" encoding="utf-8"?>')
-		_p('<CodeLite_Workspace Name="%s" Database="./%s.tags">', premake.esc(sln.name), premake.esc(sln.name))
-		
-		for i,prj in ipairs(sln.projects) do
-			local name = premake.esc(prj.name)
-			local fname = path.join(path.getrelative(sln.location, prj.location), prj.name)
-			local active = iif(i==1, "Yes", "No")
-			_p('  <Project Name="%s" Path="%s.project" Active="%s" />', name, fname, active)
-		end
-		
-		-- build a list of supported target platforms; I don't support cross-compiling yet
-		local platforms = premake.filterplatforms(sln, premake[_OPTIONS.cc].platforms, "Native")
-		for i = #platforms, 1, -1 do
-			if premake.platforms[platforms[i]].iscrosscompiler then
-				table.remove(platforms, i)
-			end
-		end 
-
-		_p('  <BuildMatrix>')
-		for _, platform in ipairs(platforms) do
-			for _, cfgname in ipairs(sln.configurations) do
-				local name = premake.getconfigname(cfgname, platform)
-				_p('    <WorkspaceConfiguration Name="%s" Selected="yes">', name)
-				for _,prj in ipairs(sln.projects) do
-					_p('      <Project Name="%s" ConfigName="%s"/>', prj.name, name)
-				end
-				_p('    </WorkspaceConfiguration>')
-			end
-		end
-		_p('  </BuildMatrix>')
-		_p('</CodeLite_Workspace>')
-	end
-

src/actions/xcode/_xcode.lua

---
--- _xcode.lua
--- Define the Apple XCode action and support functions.
--- Copyright (c) 2009 Jason Perkins and the Premake project
---
-
-	premake.xcode = { }
-	
-	newaction 
-	{
-		trigger         = "xcode3",
-		shortname       = "Xcode 3",
-		description     = "Generate Apple Xcode 3 project files (experimental)",
-		os              = "macosx",
-
-		valid_kinds     = { "ConsoleApp", "WindowedApp", "SharedLib", "StaticLib" },
-		
-		valid_languages = { "C", "C++" },
-		
-		valid_tools     = {
-			cc     = { "gcc" },
-		},
-
-		valid_platforms = { 
-			Native = "Native", 
-			x32 = "Native 32-bit", 
-			x64 = "Native 64-bit", 
-			Universal32 = "32-bit Universal", 
-			Universal64 = "64-bit Universal", 
-			Universal = "Universal",
-		},
-		
-		default_platform = "Universal",
-		
-		onsolution = function(sln)
-			-- Assign IDs needed for inter-project dependencies
-			premake.xcode.preparesolution(sln)
-		end,
-		
-		onproject = function(prj)
-			premake.generate(prj, ".xcodeproj/project.pbxproj", premake.xcode.project)
-		end,
-		
-		oncleanproject = function(prj)
-			premake.clean.directory(prj, "%%.xcodeproj")
-		end,
-		
-		oncheckproject = function(prj)
-			-- Xcode can't mix target kinds within a project
-			local last
-			for cfg in premake.eachconfig(prj) do
-				if last and last ~= cfg.kind then
-					error("Project '" .. prj.name .. "' uses more than one target kind; not supported by Xcode", 0)
-				end
-				last = cfg.kind
-			end
-		end,
-	}
-
-	newaction 
-	{
-		trigger         = "xcode4",
-		shortname       = "Xcode 4",
-		description     = "Generate Apple Xcode 4 project files (experimental)",
-		os              = "macosx",
-
-		valid_kinds     = { "ConsoleApp", "WindowedApp", "SharedLib", "StaticLib" },
-		
-		valid_languages = { "C", "C++" },
-		
-		valid_tools     = {
-			cc     = { "gcc" },
-		},
-
-		valid_platforms = { 
-			Native = "Native", 
-			x32 = "Native 32-bit", 
-			x64 = "Native 64-bit", 
-			Universal32 = "32-bit Universal", 
-			Universal64 = "64-bit Universal", 
-			Universal = "Universal",
-		},
-		
-		default_platform = "Universal",
-		
-		onsolution = function(sln)
-			premake.generate(sln, ".xcworkspace/contents.xcworkspacedata", premake.xcode4.workspace_generate)
-		end,
-		
-		onproject = function(prj)
-			premake.generate(prj, ".xcodeproj/project.pbxproj", premake.xcode.project)
-		end,
-		
-		oncleanproject = function(prj)
-			premake.clean.directory(prj, "%%.xcodeproj")
-			premake.clean.directory(prj, "%%.xcworkspace")
-		end,
-		
-		oncheckproject = function(prj)
-			-- Xcode can't mix target kinds within a project
-			local last
-			for cfg in premake.eachconfig(prj) do
-				if last and last ~= cfg.kind then
-					error("Project '" .. prj.name .. "' uses more than one target kind; not supported by Xcode", 0)
-				end
-				last = cfg.kind
-			end
-		end,
-	}
-
-

src/actions/xcode/xcode4_workspace.lua

-premake.xcode4 = {}
-
-local xcode4 = premake.xcode4
-
-function xcode4.workspace_head()
-	_p('<?xml version="1.0" encoding="UTF-8"?>')
-	_p('<Workspace')
-		_p(1,'version = "1.0">')
-
-end
-
-function xcode4.workspace_tail()
-	_p('</Workspace>')
-end
-
-function xcode4.workspace_file_ref(prj)
-
-		local projpath = path.getrelative(prj.solution.location, prj.location)
-		if projpath == '.' then projpath = '' 
-		else projpath = projpath ..'/' 
-		end
-		_p(1,'<FileRef')
-			_p(2,'location = "group:%s">',projpath .. prj.name .. '.xcodeproj')
-		_p(1,'</FileRef>')
-end
-
-function xcode4.workspace_generate(sln)
-	premake.xcode.preparesolution(sln)
-
-	xcode4.workspace_head()
-
-	for prj in premake.solution.eachproject(sln) do
-		xcode4.workspace_file_ref(prj)
-	end
-	
-	xcode4.workspace_tail()
-end
-
-
-

src/actions/xcode/xcode_common.lua

---
--- xcode_common.lua
--- Functions to generate the different sections of an Xcode project.
--- Copyright (c) 2009-2011 Jason Perkins and the Premake project
---
-
-	local xcode = premake.xcode
-	local tree  = premake.tree
-
-
---
--- Return the Xcode build category for a given file, based on the file extension.
---
--- @param node
---    The node to identify.
--- @returns
---    An Xcode build category, one of "Sources", "Resources", "Frameworks", or nil.
---
-
-	function xcode.getbuildcategory(node)
-		local categories = {
-			[".a"] = "Frameworks",
-			[".c"] = "Sources",
-			[".cc"] = "Sources",
-			[".cpp"] = "Sources",
-			[".cxx"] = "Sources",
-			[".dylib"] = "Frameworks",
-			[".framework"] = "Frameworks",
-			[".m"] = "Sources",
-			[".mm"] = "Sources",
-			[".strings"] = "Resources",
-			[".nib"] = "Resources",
-			[".xib"] = "Resources",
-			[".icns"] = "Resources",
-		}
-		return categories[path.getextension(node.name)]
-	end
-
-
---
--- Return the displayed name for a build configuration, taking into account the
--- configuration and platform, i.e. "Debug 32-bit Universal".
---
--- @param cfg
---    The configuration being identified.
--- @returns
---    A build configuration name.
---
-
-	function xcode.getconfigname(cfg)
-		local name = cfg.name
-		if #cfg.project.solution.xcode.platforms > 1 then
-			name = name .. " " .. premake.action.current().valid_platforms[cfg.platform]
-		end
-		return name
-	end
-
-
---
--- Return the Xcode type for a given file, based on the file extension.
---
--- @param fname
---    The file name to identify.
--- @returns
---    An Xcode file type, string.
---
-
-	function xcode.getfiletype(node)
-		local types = {
-			[".c"]         = "sourcecode.c.c",
-			[".cc"]        = "sourcecode.cpp.cpp",
-			[".cpp"]       = "sourcecode.cpp.cpp",
-			[".css"]       = "text.css",
-			[".cxx"]       = "sourcecode.cpp.cpp",
-			[".framework"] = "wrapper.framework",
-			[".gif"]       = "image.gif",
-			[".h"]         = "sourcecode.c.h",
-			[".html"]      = "text.html",
-			[".lua"]       = "sourcecode.lua",
-			[".m"]         = "sourcecode.c.objc",
-			[".mm"]        = "sourcecode.cpp.objc",
-			[".nib"]       = "wrapper.nib",
-			[".pch"]       = "sourcecode.c.h",
-			[".plist"]     = "text.plist.xml",
-			[".strings"]   = "text.plist.strings",
-			[".xib"]       = "file.xib",
-			[".icns"]      = "image.icns",
-		}
-		return types[path.getextension(node.path)] or "text"
-	end
-
-
---
--- Return the Xcode product type, based target kind.
---
--- @param node
---    The product node to identify.
--- @returns
---    An Xcode product type, string.
---
-
-	function xcode.getproducttype(node)
-		local types = {
-			ConsoleApp  = "com.apple.product-type.tool",
-			WindowedApp = "com.apple.product-type.application",
-			StaticLib   = "com.apple.product-type.library.static",
-			SharedLib   = "com.apple.product-type.library.dynamic",
-		}
-		return types[node.cfg.kind]
-	end
-
-
---
--- Return the Xcode target type, based on the target file extension.
---
--- @param node
---    The product node to identify.
--- @returns
---    An Xcode target type, string.
---
-
-	function xcode.gettargettype(node)
-		local types = {
-			ConsoleApp  = "\"compiled.mach-o.executable\"",
-			WindowedApp = "wrapper.application",
-			StaticLib   = "archive.ar",
-			SharedLib   = "\"compiled.mach-o.dylib\"",
-		}
-		return types[node.cfg.kind]
-	end
-
-
---
--- Return a unique file name for a project. Since Xcode uses .xcodeproj's to 
--- represent both solutions and projects there is a likely change of a name
--- collision. Tack on a number to differentiate them.
---
--- @param prj
---    The project being queried.
--- @returns
---    A uniqued file name
---
-
-	function xcode.getxcodeprojname(prj)
-		-- if there is a solution with matching name, then use "projectname1.xcodeproj"
-		-- just get something working for now
-		local fname = premake.project.getfilename(prj, "%%.xcodeproj")
-		return fname
-	end
-
-
---
--- Returns true if the file name represents a framework.
---
--- @param fname
---    The name of the file to test.
---
-
-	function xcode.isframework(fname)
-		return (path.getextension(fname) == ".framework")
-	end
-
-
---
--- Retrieves a unique 12 byte ID for an object. This function accepts and ignores two
--- parameters 'node' and 'usage', which are used by an alternative implementation of
--- this function for testing.
---
--- @returns
---    A 24-character string representing the 12 byte ID.
---
-
-	function xcode.newid()
-		return string.format("%04X%04X%04X%04X%04X%04X",
-			math.random(0, 32767),
-			math.random(0, 32767),
-			math.random(0, 32767),
-			math.random(0, 32767),
-			math.random(0, 32767),
-			math.random(0, 32767))
-	end
-
-
---
--- Create a product tree node and all projects in a solution; assigning IDs 
--- that are needed for inter-project dependencies.
---
--- @param sln
---    The solution to prepare.
---
-
-	function xcode.preparesolution(sln)
-		-- create and cache a list of supported platforms
-		sln.xcode = { }
-		sln.xcode.platforms = premake.filterplatforms(sln, premake.action.current().valid_platforms, "Universal")
-		
-		for prj in premake.solution.eachproject(sln) do
-			-- need a configuration to get the target information
-			local cfg = premake.getconfig(prj, prj.configurations[1], sln.xcode.platforms[1])
-
-			-- build the product tree node
-			local node = premake.tree.new(path.getname(cfg.buildtarget.bundlepath))
-			node.cfg = cfg
-			node.id = premake.xcode.newid(node, "product")
-			node.targetid = premake.xcode.newid(node, "target")
-			
-			-- attach it to the project
-			prj.xcode = {}
-			prj.xcode.projectnode = node
-		end
-	end
-
-
---
--- Print out a list value in the Xcode format.
---
--- @param list
---    The list of values to be printed.
--- @param tag
---    The Xcode specific list tag.
---
-
-	function xcode.printlist(list, tag)
-		if #list > 0 then
-			_p(4,'%s = (', tag)
-			for _, item in ipairs(list) do
-				_p(5, '"%s",', item)
-			end
-			_p(4,');')
-		end
-	end
-
-
----------------------------------------------------------------------------
--- Section generator functions, in the same order in which they appear
--- in the .pbxproj file
----------------------------------------------------------------------------
-
-	function xcode.Header()
-		_p('// !$*UTF8*$!')
-		_p('{')
-		_p(1,'archiveVersion = 1;')
-		_p(1,'classes = {')
-		_p(1,'};')
-		_p(1,'objectVersion = 45;')
-		_p(1,'objects = {')
-		_p('')
-	end
-
-
-	function xcode.PBXBuildFile(tr)
-		_p('/* Begin PBXBuildFile section */')
-		tree.traverse(tr, {
-			onnode = function(node)
-				if node.buildid then
-					_p(2,'%s /* %s in %s */ = {isa = PBXBuildFile; fileRef = %s /* %s */; };', 
-						node.buildid, node.name, xcode.getbuildcategory(node), node.id, node.name)
-				end
-			end
-		})
-		_p('/* End PBXBuildFile section */')
-		_p('')
-	end
-
-
-	function xcode.PBXContainerItemProxy(tr)
-		if #tr.projects.children > 0 then
-			_p('/* Begin PBXContainerItemProxy section */')
-			for _, node in ipairs(tr.projects.children) do
-				_p(2,'%s /* PBXContainerItemProxy */ = {', node.productproxyid)
-				_p(3,'isa = PBXContainerItemProxy;')
-				_p(3,'containerPortal = %s /* %s */;', node.id, path.getname(node.path))
-				_p(3,'proxyType = 2;')
-				_p(3,'remoteGlobalIDString = %s;', node.project.xcode.projectnode.id)
-				_p(3,'remoteInfo = "%s";', node.project.xcode.projectnode.name)
-				_p(2,'};')
-				_p(2,'%s /* PBXContainerItemProxy */ = {', node.targetproxyid)
-				_p(3,'isa = PBXContainerItemProxy;')
-				_p(3,'containerPortal = %s /* %s */;', node.id, path.getname(node.path))
-				_p(3,'proxyType = 1;')
-				_p(3,'remoteGlobalIDString = %s;', node.project.xcode.projectnode.targetid)
-				_p(3,'remoteInfo = "%s";', node.project.xcode.projectnode.name)
-				_p(2,'};')
-			end
-			_p('/* End PBXContainerItemProxy section */')
-			_p('')
-		end
-	end
-
-
-	function xcode.PBXFileReference(tr)
-		_p('/* Begin PBXFileReference section */')
-		
-		tree.traverse(tr, {
-			onleaf = function(node)
-				-- I'm only listing files here, so ignore anything without a path
-				if not node.path then
-					return
-				end
-				
-				-- is this the product node, describing the output target?
-				if node.kind == "product" then
-					_p(2,'%s /* %s */ = {isa = PBXFileReference; explicitFileType = %s; includeInIndex = 0; name = "%s"; path = "%s"; sourceTree = BUILT_PRODUCTS_DIR; };',
-						node.id, node.name, xcode.gettargettype(node), node.name, path.getname(node.cfg.buildtarget.bundlepath))
-						
-				-- is this a project dependency?
-				elseif node.parent.parent == tr.projects then
-					local relpath = path.getrelative(tr.project.location, node.parent.project.location)
-					_p(2,'%s /* %s */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = "%s"; path = "%s"; sourceTree = SOURCE_ROOT; };',
-						node.parent.id, node.parent.name, node.parent.name, path.join(relpath, node.parent.name))
-					
-				-- something else
-				else
-					local pth, src
-					if xcode.isframework(node.path) then
-						--respect user supplied paths
-						if string.find(node.path,'/')  then
-							if string.find(node.path,'^%.')then
-								error('relative paths are not currently supported for frameworks')
-							end
-							pth = node.path
-						else
-							pth = "/System/Library/Frameworks/" .. node.path
-						end
-						src = "absolute"
-					else
-						-- something else; probably a source code file
-						src = "group"
-
-						-- if the parent node is virtual, it won't have a local path
-						-- of its own; need to use full relative path from project
-						if node.parent.isvpath then
-							pth = node.cfg.name
-						else
-							pth = tree.getlocalpath(node)
-						end
-					end
-					
-					_p(2,'%s /* %s */ = {isa = PBXFileReference; lastKnownFileType = %s; name = "%s"; path = "%s"; sourceTree = "<%s>"; };',
-						node.id, node.name, xcode.getfiletype(node), node.name, pth, src)
-				end
-			end
-		})
-		
-		_p('/* End PBXFileReference section */')
-		_p('')
-	end
-
-
-	function xcode.PBXFrameworksBuildPhase(tr)
-		_p('/* Begin PBXFrameworksBuildPhase section */')
-		_p(2,'%s /* Frameworks */ = {', tr.products.children[1].fxstageid)
-		_p(3,'isa = PBXFrameworksBuildPhase;')
-		_p(3,'buildActionMask = 2147483647;')
-		_p(3,'files = (')
-		
-		-- write out library dependencies
-		tree.traverse(tr.frameworks, {
-			onleaf = function(node)
-				_p(4,'%s /* %s in Frameworks */,', node.buildid, node.name)
-			end
-		})
-		
-		-- write out project dependencies
-		tree.traverse(tr.projects, {
-			onleaf = function(node)
-				_p(4,'%s /* %s in Frameworks */,', node.buildid, node.name)
-			end
-		})
-		
-		_p(3,');')
-		_p(3,'runOnlyForDeploymentPostprocessing = 0;')
-		_p(2,'};')
-		_p('/* End PBXFrameworksBuildPhase section */')
-		_p('')
-	end
-
-
-	function xcode.PBXGroup(tr)
-		_p('/* Begin PBXGroup section */')
-
-		tree.traverse(tr, {
-			onnode = function(node)
-				-- Skip over anything that isn't a proper group
-				if (node.path and #node.children == 0) or node.kind == "vgroup" then
-					return
-				end
-				
-				-- project references get special treatment
-				if node.parent == tr.projects then
-					_p(2,'%s /* Products */ = {', node.productgroupid)
-				else
-					_p(2,'%s /* %s */ = {', node.id, node.name)
-				end
-				
-				_p(3,'isa = PBXGroup;')
-				_p(3,'children = (')
-				for _, childnode in ipairs(node.children) do
-					_p(4,'%s /* %s */,', childnode.id, childnode.name)
-				end
-				_p(3,');')
-				
-				if node.parent == tr.projects then
-					_p(3,'name = Products;')
-				else
-					_p(3,'name = "%s";', node.name)
-					if node.path and not node.isvpath then
-						local p = node.path
-						if node.parent.path then
-							p = path.getrelative(node.parent.path, node.path)
-						end
-						_p(3,'path = "%s";', p)
-					end
-				end
-				
-				_p(3,'sourceTree = "<group>";')
-				_p(2,'};')
-			end
-		}, true)
-				
-		_p('/* End PBXGroup section */')
-		_p('')
-	end	
-
-
-	function xcode.PBXNativeTarget(tr)
-		_p('/* Begin PBXNativeTarget section */')
-		for _, node in ipairs(tr.products.children) do
-			local name = tr.project.name
-			
-			_p(2,'%s /* %s */ = {', node.targetid, name)
-			_p(3,'isa = PBXNativeTarget;')
-			_p(3,'buildConfigurationList = %s /* Build configuration list for PBXNativeTarget "%s" */;', node.cfgsection, name)
-			_p(3,'buildPhases = (')
-			if #tr.project.prebuildcommands > 0 then
-				_p(4,'9607AE1010C857E500CD1376 /* Prebuild */,')
-			end
-			_p(4,'%s /* Resources */,', node.resstageid)
-			_p(4,'%s /* Sources */,', node.sourcesid)
-			if #tr.project.prelinkcommands > 0 then
-				_p(4,'9607AE3510C85E7E00CD1376 /* Prelink */,')
-			end
-			_p(4,'%s /* Frameworks */,', node.fxstageid)
-			if #tr.project.postbuildcommands > 0 then
-				_p(4,'9607AE3710C85E8F00CD1376 /* Postbuild */,')
-			end
-			_p(3,');')
-			_p(3,'buildRules = (')
-			_p(3,');')
-			
-			_p(3,'dependencies = (')
-			for _, node in ipairs(tr.projects.children) do
-				_p(4,'%s /* PBXTargetDependency */,', node.targetdependid)
-			end
-			_p(3,');')
-			
-			_p(3,'name = "%s";', name)
-			
-			local p
-			if node.cfg.kind == "ConsoleApp" then
-				p = "$(HOME)/bin"
-			elseif node.cfg.kind == "WindowedApp" then
-				p = "$(HOME)/Applications"
-			end
-			if p then
-				_p(3,'productInstallPath = "%s";', p)
-			end
-			
-			_p(3,'productName = "%s";', name)
-			_p(3,'productReference = %s /* %s */;', node.id, node.name)
-			_p(3,'productType = "%s";', xcode.getproducttype(node))
-			_p(2,'};')
-		end
-		_p('/* End PBXNativeTarget section */')
-		_p('')
-	end
-
-
-	function xcode.PBXProject(tr)
-		_p('/* Begin PBXProject section */')
-		_p(2,'08FB7793FE84155DC02AAC07 /* Project object */ = {')
-		_p(3,'isa = PBXProject;')
-		_p(3,'buildConfigurationList = 1DEB928908733DD80010E9CD /* Build configuration list for PBXProject "%s" */;', tr.name)
-		_p(3,'compatibilityVersion = "Xcode 3.2";')
-		_p(3,'hasScannedForEncodings = 1;')
-		_p(3,'mainGroup = %s /* %s */;', tr.id, tr.name)
-		_p(3,'projectDirPath = "";')
-		
-		if #tr.projects.children > 0 then
-			_p(3,'projectReferences = (')
-			for _, node in ipairs(tr.projects.children) do
-				_p(4,'{')
-				_p(5,'ProductGroup = %s /* Products */;', node.productgroupid)
-				_p(5,'ProjectRef = %s /* %s */;', node.id, path.getname(node.path))
-				_p(4,'},')
-			end
-			_p(3,');')
-		end
-		
-		_p(3,'projectRoot = "";')
-		_p(3,'targets = (')
-		for _, node in ipairs(tr.products.children) do
-			_p(4,'%s /* %s */,', node.targetid, node.name)
-		end
-		_p(3,');')
-		_p(2,'};')
-		_p('/* End PBXProject section */')
-		_p('')
-	end
-
-
-	function xcode.PBXReferenceProxy(tr)
-		if #tr.projects.children > 0 then
-			_p('/* Begin PBXReferenceProxy section */')
-			tree.traverse(tr.projects, {
-				onleaf = function(node)
-					_p(2,'%s /* %s */ = {', node.id, node.name)
-					_p(3,'isa = PBXReferenceProxy;')
-					_p(3,'fileType = %s;', xcode.gettargettype(node))
-					_p(3,'path = "%s";', node.path)
-					_p(3,'remoteRef = %s /* PBXContainerItemProxy */;', node.parent.productproxyid)
-					_p(3,'sourceTree = BUILT_PRODUCTS_DIR;')
-					_p(2,'};')
-				end
-			})
-			_p('/* End PBXReferenceProxy section */')
-			_p('')
-		end
-	end
-	
-
-	function xcode.PBXResourcesBuildPhase(tr)
-		_p('/* Begin PBXResourcesBuildPhase section */')
-		for _, target in ipairs(tr.products.children) do
-			_p(2,'%s /* Resources */ = {', target.resstageid)
-			_p(3,'isa = PBXResourcesBuildPhase;')
-			_p(3,'buildActionMask = 2147483647;')
-			_p(3,'files = (')
-			tree.traverse(tr, {
-				onnode = function(node)
-					if xcode.getbuildcategory(node) == "Resources" then
-						_p(4,'%s /* %s in Resources */,', node.buildid, node.name)
-					end
-				end
-			})
-			_p(3,');')
-			_p(3,'runOnlyForDeploymentPostprocessing = 0;')
-			_p(2,'};')
-		end
-		_p('/* End PBXResourcesBuildPhase section */')
-		_p('')
-	end
-	
-	function xcode.PBXShellScriptBuildPhase(tr)
-		local wrapperWritten = false
-
-		local function doblock(id, name, which)
-			-- start with the project-level commands (most common)
-			local prjcmds = tr.project[which]
-			local commands = table.join(prjcmds, {})
-
-			-- see if there are any config-specific commands to add
-			for _, cfg in ipairs(tr.configs) do
-				local cfgcmds = cfg[which]
-				if #cfgcmds > #prjcmds then
-					table.insert(commands, 'if [ "${CONFIGURATION}" = "' .. xcode.getconfigname(cfg) .. '" ]; then')
-					for i = #prjcmds + 1, #cfgcmds do
-						table.insert(commands, cfgcmds[i])
-					end
-					table.insert(commands, 'fi')
-				end
-			end
-			
-			if #commands > 0 then
-				if not wrapperWritten then
-					_p('/* Begin PBXShellScriptBuildPhase section */')
-					wrapperWritten = true
-				end
-				_p(2,'%s /* %s */ = {', id, name)
-				_p(3,'isa = PBXShellScriptBuildPhase;')
-				_p(3,'buildActionMask = 2147483647;')
-				_p(3,'files = (')
-				_p(3,');')
-				_p(3,'inputPaths = (');
-				_p(3,');');
-				_p(3,'name = %s;', name);
-				_p(3,'outputPaths = (');
-				_p(3,');');
-				_p(3,'runOnlyForDeploymentPostprocessing = 0;');
-				_p(3,'shellPath = /bin/sh;');
-				_p(3,'shellScript = "%s";', table.concat(commands, "\\n"):gsub('"', '\\"'))
-				_p(2,'};')
-			end
-		end
-				
-		doblock("9607AE1010C857E500CD1376", "Prebuild", "prebuildcommands")
-		doblock("9607AE3510C85E7E00CD1376", "Prelink", "prelinkcommands")
-		doblock("9607AE3710C85E8F00CD1376", "Postbuild", "postbuildcommands")
-		
-		if wrapperWritten then
-			_p('/* End PBXShellScriptBuildPhase section */')
-		end
-	end
-	
-	
-	function xcode.PBXSourcesBuildPhase(tr)
-		_p('/* Begin PBXSourcesBuildPhase section */')
-		for _, target in ipairs(tr.products.children) do
-			_p(2,'%s /* Sources */ = {', target.sourcesid)
-			_p(3,'isa = PBXSourcesBuildPhase;')
-			_p(3,'buildActionMask = 2147483647;')
-			_p(3,'files = (')
-			tree.traverse(tr, {
-				onleaf = function(node)
-					if xcode.getbuildcategory(node) == "Sources" then
-						_p(4,'%s /* %s in Sources */,', node.buildid, node.name)
-					end
-				end
-			})
-			_p(3,');')
-			_p(3,'runOnlyForDeploymentPostprocessing = 0;')
-			_p(2,'};')
-		end
-		_p('/* End PBXSourcesBuildPhase section */')
-		_p('')
-	end
-
-
-	function xcode.PBXVariantGroup(tr)
-		_p('/* Begin PBXVariantGroup section */')
-		tree.traverse(tr, {
-			onbranch = function(node)
-				if node.kind == "vgroup" then
-					_p(2,'%s /* %s */ = {', node.id, node.name)
-					_p(3,'isa = PBXVariantGroup;')
-					_p(3,'children = (')
-					for _, lang in ipairs(node.children) do
-						_p(4,'%s /* %s */,', lang.id, lang.name)
-					end
-					_p(3,');')
-					_p(3,'name = %s;', node.name)
-					_p(3,'sourceTree = "<group>";')
-					_p(2,'};')
-				end
-			end
-		})
-		_p('/* End PBXVariantGroup section */')
-		_p('')
-	end
-
-
-	function xcode.PBXTargetDependency(tr)
-		if #tr.projects.children > 0 then
-			_p('/* Begin PBXTargetDependency section */')
-			tree.traverse(tr.projects, {
-				onleaf = function(node)
-					_p(2,'%s /* PBXTargetDependency */ = {', node.parent.targetdependid)
-					_p(3,'isa = PBXTargetDependency;')
-					_p(3,'name = "%s";', node.name)
-					_p(3,'targetProxy = %s /* PBXContainerItemProxy */;', node.parent.targetproxyid)
-					_p(2,'};')
-				end
-			})
-			_p('/* End PBXTargetDependency section */')
-			_p('')
-		end
-	end
-
-
-	function xcode.XCBuildConfiguration_Target(tr, target, cfg)
-		local cfgname = xcode.getconfigname(cfg)
-		
-		_p(2,'%s /* %s */ = {', cfg.xcode.targetid, cfgname)
-		_p(3,'isa = XCBuildConfiguration;')
-		_p(3,'buildSettings = {')
-		_p(4,'ALWAYS_SEARCH_USER_PATHS = NO;')
-
-		if not cfg.flags.Symbols then
-			_p(4,'DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";')
-		end
-		
-		if cfg.kind ~= "StaticLib" and cfg.buildtarget.prefix ~= "" then
-			_p(4,'EXECUTABLE_PREFIX = %s;', cfg.buildtarget.prefix)
-		end
-		
-		if cfg.targetextension then
-			local ext = cfg.targetextension
-			ext = iif(ext:startswith("."), ext:sub(2), ext)
-			_p(4,'EXECUTABLE_EXTENSION = %s;', ext)
-		end
-
-		local outdir = path.getdirectory(cfg.buildtarget.bundlepath)
-		if outdir ~= "." then
-			_p(4,'CONFIGURATION_BUILD_DIR = %s;', outdir)
-		end
-
-		_p(4,'GCC_DYNAMIC_NO_PIC = NO;')
-		_p(4,'GCC_MODEL_TUNING = G5;')
-
-		if tr.infoplist then
-			_p(4,'INFOPLIST_FILE = "%s";', tr.infoplist.cfg.name)
-		end
-
-		installpaths = {
-			ConsoleApp = '/usr/local/bin',
-			WindowedApp = '"$(HOME)/Applications"',
-			SharedLib = '/usr/local/lib',
-			StaticLib = '/usr/local/lib',
-		}
-		_p(4,'INSTALL_PATH = %s;', installpaths[cfg.kind])
-
-		_p(4,'PRODUCT_NAME = "%s";', cfg.buildtarget.basename)
-		_p(3,'};')
-		_p(3,'name = "%s";', cfgname)
-		_p(2,'};')
-	end
-	
-	
-	function xcode.XCBuildConfiguration_Project(tr, cfg)
-		local cfgname = xcode.getconfigname(cfg)
-
-		_p(2,'%s /* %s */ = {', cfg.xcode.projectid, cfgname)
-		_p(3,'isa = XCBuildConfiguration;')
-		_p(3,'buildSettings = {')
-		
-		local archs = {
-			Native = "$(NATIVE_ARCH_ACTUAL)",
-			x32    = "i386",
-			x64    = "x86_64",
-			Universal32 = "$(ARCHS_STANDARD_32_BIT)",
-			Universal64 = "$(ARCHS_STANDARD_64_BIT)",
-			Universal = "$(ARCHS_STANDARD_32_64_BIT)",
-		}
-		_p(4,'ARCHS = "%s";', archs[cfg.platform])
-		
-		local targetdir = path.getdirectory(cfg.buildtarget.bundlepath)
-		if targetdir ~= "." then
-			_p(4,'CONFIGURATION_BUILD_DIR = "$(SYMROOT)";');
-		end
-		
-		_p(4,'CONFIGURATION_TEMP_DIR = "$(OBJROOT)";')
-		
-		if cfg.flags.Symbols then
-			_p(4,'COPY_PHASE_STRIP = NO;')
-		end
-		
-		_p(4,'GCC_C_LANGUAGE_STANDARD = gnu99;')
-		
-		if cfg.flags.NoExceptions then
-			_p(4,'GCC_ENABLE_CPP_EXCEPTIONS = NO;')
-		end
-		
-		if cfg.flags.NoRTTI then
-			_p(4,'GCC_ENABLE_CPP_RTTI = NO;')
-		end
-		
-		if _ACTION ~= "xcode4" and cfg.flags.Symbols and not cfg.flags.NoEditAndContinue then
-			_p(4,'GCC_ENABLE_FIX_AND_CONTINUE = YES;')
-		end
-		
-		if cfg.flags.NoExceptions then
-			_p(4,'GCC_ENABLE_OBJC_EXCEPTIONS = NO;')
-		end
-		
-		if cfg.flags.Optimize or cfg.flags.OptimizeSize then
-			_p(4,'GCC_OPTIMIZATION_LEVEL = s;')
-		elseif cfg.flags.OptimizeSpeed then
-			_p(4,'GCC_OPTIMIZATION_LEVEL = 3;')
-		else
-			_p(4,'GCC_OPTIMIZATION_LEVEL = 0;')
-		end
-		
-		if cfg.pchheader and not cfg.flags.NoPCH then
-			_p(4,'GCC_PRECOMPILE_PREFIX_HEADER = YES;')
-			_p(4,'GCC_PREFIX_HEADER = "%s";', cfg.pchheader)
-		end
-		
-		xcode.printlist(cfg.defines, 'GCC_PREPROCESSOR_DEFINITIONS')
-
-		_p(4,'GCC_SYMBOLS_PRIVATE_EXTERN = NO;')
-		
-		if cfg.flags.FatalWarnings then
-			_p(4,'GCC_TREAT_WARNINGS_AS_ERRORS = YES;')
-		end
-		
-		_p(4,'GCC_WARN_ABOUT_RETURN_TYPE = YES;')
-		_p(4,'GCC_WARN_UNUSED_VARIABLE = YES;')
-
-		for i,v in ipairs(cfg.includedirs) do
-			cfg.includedirs[i] = premake5.project.getrelative(cfg.project, cfg.includedirs[i])
-		end
-		for i,v in ipairs(cfg.libdirs) do
-			cfg.libdirs[i] = premake5.project.getrelative(cfg.project, cfg.libdirs[i])
-		end
-		
-		xcode.printlist(cfg.includedirs, 'HEADER_SEARCH_PATHS')
-		xcode.printlist(cfg.libdirs, 'LIBRARY_SEARCH_PATHS')
-		
-		_p(4,'OBJROOT = "%s";', cfg.objectsdir)
-
-		_p(4,'ONLY_ACTIVE_ARCH = %s;',iif(premake.config.isdebugbuild(cfg),'YES','NO'))
-		
-		-- build list of "other" C/C++ flags
-		local checks = {
-			["-ffast-math"]          = cfg.flags.FloatFast,
-			["-ffloat-store"]        = cfg.flags.FloatStrict,
-			["-fomit-frame-pointer"] = cfg.flags.NoFramePointer,
-		}
-			
-		local flags = { }
-		for flag, check in pairs(checks) do
-			if check then
-				table.insert(flags, flag)
-			end
-		end
-		xcode.printlist(table.join(flags, cfg.buildoptions), 'OTHER_CFLAGS')
-
-		-- build list of "other" linked flags. All libraries that aren't frameworks
-		-- are listed here, so I don't have to try and figure out if they are ".a"
-		-- or ".dylib", which Xcode requires to list in the Frameworks section
-		flags = { }
-		for _, lib in ipairs(premake.getlinks(cfg, "system")) do
-			if not xcode.isframework(lib) then
-				table.insert(flags, "-l" .. lib)
-			end
-		end
-		flags = table.join(flags, cfg.linkoptions)
-		xcode.printlist(flags, 'OTHER_LDFLAGS')
-		
-		if cfg.flags.StaticRuntime then
-			_p(4,'STANDARD_C_PLUS_PLUS_LIBRARY_TYPE = static;')
-		end
-		
-		if targetdir ~= "." then
-			_p(4,'SYMROOT = "%s";', targetdir)
-		end
-		
-		if cfg.flags.ExtraWarnings then
-			_p(4,'WARNING_CFLAGS = "-Wall";')
-		end
-		
-		_p(3,'};')
-		_p(3,'name = "%s";', cfgname)
-		_p(2,'};')
-	end
-
-
-	function xcode.XCBuildConfiguration(tr)
-		_p('/* Begin XCBuildConfiguration section */')
-		for _, target in ipairs(tr.products.children) do
-			for _, cfg in ipairs(tr.configs) do
-				xcode.XCBuildConfiguration_Target(tr, target, cfg)
-			end
-		end
-		for _, cfg in ipairs(tr.configs) do
-			xcode.XCBuildConfiguration_Project(tr, cfg)
-		end
-		_p('/* End XCBuildConfiguration section */')
-		_p('')
-	end
-
-
-	function xcode.XCBuildConfigurationList(tr)
-		local sln = tr.project.solution
-		
-		_p('/* Begin XCConfigurationList section */')
-		for _, target in ipairs(tr.products.children) do
-			_p(2,'%s /* Build configuration list for PBXNativeTarget "%s" */ = {', target.cfgsection, target.name)
-			_p(3,'isa = XCConfigurationList;')
-			_p(3,'buildConfigurations = (')
-			for _, cfg in ipairs(tr.configs) do
-				_p(4,'%s /* %s */,', cfg.xcode.targetid, xcode.getconfigname(cfg))
-			end
-			_p(3,');')
-			_p(3,'defaultConfigurationIsVisible = 0;')
-			_p(3,'defaultConfigurationName = "%s";', xcode.getconfigname(tr.configs[1]))
-			_p(2,'};')
-		end
-		_p(2,'1DEB928908733DD80010E9CD /* Build configuration list for PBXProject "%s" */ = {', tr.name)
-		_p(3,'isa = XCConfigurationList;')
-		_p(3,'buildConfigurations = (')
-		for _, cfg in ipairs(tr.configs) do
-			_p(4,'%s /* %s */,', cfg.xcode.projectid, xcode.getconfigname(cfg))
-		end
-		_p(3,');')
-		_p(3,'defaultConfigurationIsVisible = 0;')
-		_p(3,'defaultConfigurationName = "%s";', xcode.getconfigname(tr.configs[1]))
-		_p(2,'};')
-		_p('/* End XCConfigurationList section */')
-		_p('')
-	end
-
-
-	function xcode.Footer()
-		_p(1,'};')
-		_p('\trootObject = 08FB7793FE84155DC02AAC07 /* Project object */;')
-		_p('}')
-	end

src/actions/xcode/xcode_project.lua

---
--- xcode_project.lua
--- Generate an Xcode C/C++ project.
--- Copyright (c) 2009 Jason Perkins and the Premake project
---
-
-	local xcode = premake.xcode
-	local tree = premake.tree
-
---
--- Create a tree corresponding to what is shown in the Xcode project browser
--- pane, with nodes for files and folders, resources, frameworks, and products.
---
--- @param prj
---    The project being generated.
--- @returns
---    A tree, loaded with metadata, which mirrors Xcode's view of the project.
---
-
-	function xcode.buildprjtree(prj)
-		local tr = premake.project.buildsourcetree(prj)
-		
-		-- create a list of build configurations and assign IDs
-		tr.configs = {}
-		for _, cfgname in ipairs(prj.solution.configurations) do
-			for _, platform in ipairs(prj.solution.xcode.platforms) do
-				local cfg = premake.getconfig(prj, cfgname, platform)
-				cfg.xcode = {}
-				cfg.xcode.targetid = xcode.newid(prj.xcode.projectnode, cfgname)
-				cfg.xcode.projectid = xcode.newid(tr, cfgname)
-				table.insert(tr.configs, cfg)
-			end
-		end
-		
-		-- convert localized resources from their filesystem layout (English.lproj/MainMenu.xib)
-		-- to Xcode's display layout (MainMenu.xib/English).
-		tree.traverse(tr, {
-			onbranch = function(node)
-				if path.getextension(node.name) == ".lproj" then
-					local lang = path.getbasename(node.name)  -- "English", "French", etc.
-					
-					-- create a new language group for each file it contains
-					for _, filenode in ipairs(node.children) do
-						local grpnode = node.parent.children[filenode.name]
-						if not grpnode then
-							grpnode = tree.insert(node.parent, tree.new(filenode.name))
-							grpnode.kind = "vgroup"
-						end
-						
-						-- convert the file node to a language node and add to the group
-						filenode.name = path.getbasename(lang)
-						tree.insert(grpnode, filenode)
-					end
-					
-					-- remove this directory from the tree
-					tree.remove(node)
-				end
-			end
-		})
-		
-		-- the special folder "Frameworks" lists all linked frameworks
-		tr.frameworks = tree.new("Frameworks")
-		for cfg in premake.eachconfig(prj) do
-			for _, link in ipairs(premake.getlinks(cfg, "system", "fullpath")) do
-				local name = path.getname(link)
-				if xcode.isframework(name) and not tr.frameworks.children[name] then
-					node = tree.insert(tr.frameworks, tree.new(name))
-					node.path = link
-				end
-			end
-		end
-		
-		-- only add it to the tree if there are frameworks to link
-		if #tr.frameworks.children > 0 then 
-			tree.insert(tr, tr.frameworks)
-		end
-		
-		-- the special folder "Products" holds the target produced by the project; this
-		-- is populated below
-		tr.products = tree.insert(tr, tree.new("Products"))
-
-		-- the special folder "Projects" lists sibling project dependencies
-		tr.projects = tree.new("Projects")
-		for _, dep in ipairs(premake.getdependencies(prj, "sibling", "object")) do
-			-- create a child node for the dependency's xcodeproj
-			local xcpath = xcode.getxcodeprojname(dep)
-			local xcnode = tree.insert(tr.projects, tree.new(path.getname(xcpath)))
-			xcnode.path = xcpath
-			xcnode.project = dep
-			xcnode.productgroupid = xcode.newid(xcnode, "prodgrp")
-			xcnode.productproxyid = xcode.newid(xcnode, "prodprox")
-			xcnode.targetproxyid  = xcode.newid(xcnode, "targprox")
-			xcnode.targetdependid = xcode.newid(xcnode, "targdep")
-			
-			-- create a grandchild node for the dependency's link target
-			local cfg = premake.getconfig(dep, prj.configurations[1])
-			node = tree.insert(xcnode, tree.new(cfg.linktarget.name))
-			node.path = cfg.linktarget.fullpath
-			node.cfg = cfg
-		end
-
-		if #tr.projects.children > 0 then
-			tree.insert(tr, tr.projects)
-		end
-
-		-- Final setup
-		tree.traverse(tr, {
-			onnode = function(node)
-				-- assign IDs to every node in the tree
-				node.id = xcode.newid(node)
-				
-				-- assign build IDs to buildable files
-				if xcode.getbuildcategory(node) then