premake/premake4.lua
changeset 7925 f090a47eb7f7
child 8149 681eb46b8ac4
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/premake/premake4.lua	Sun Nov 10 00:38:37 2013 -0500
     1.3 @@ -0,0 +1,482 @@
     1.4 +-- Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org>
     1.5 +--
     1.6 +-- This software is provided 'as-is', without any express or implied
     1.7 +-- warranty.  In no event will the authors be held liable for any damages
     1.8 +-- arising from the use of this software.
     1.9 +--
    1.10 +-- Permission is granted to anyone to use this software for any purpose,
    1.11 +-- including commercial applications, and to alter it and redistribute it
    1.12 +-- freely.
    1.13 +--
    1.14 +-- Meta-build system using premake created and maintained by
    1.15 +-- Benjamin Henning <b.henning@digipen.edu>
    1.16 +
    1.17 +--[[
    1.18 +premake4.lua
    1.19 +
    1.20 +	This script sets up the entire premake system. It's responsible for executing
    1.21 +	all of the definition scripts for the SDL2 library and the entire test suite,
    1.22 +	or demos for the iOS platform. It handles each specific platform and uses the
    1.23 +	setup state to generate both the configuration header file needed to build
    1.24 +	SDL2 and the premake lua script to generate the target project files.
    1.25 +]]
    1.26 +
    1.27 +-- string utility functions
    1.28 +dofile "util/sdl_string.lua"
    1.29 +-- utility file wrapper for some useful functions
    1.30 +dofile "util/sdl_file.lua"
    1.31 +-- system for defining SDL projects
    1.32 +dofile "util/sdl_projects.lua"
    1.33 +-- offers a utility function for finding dependencies specifically on windows
    1.34 +dofile "util/sdl_depends.lua"
    1.35 +-- system for generating a *config.h file used to build the SDL2 library
    1.36 +dofile "util/sdl_gen_config.lua"
    1.37 +-- functions to handle complicated dependency checks using CMake-esque functions
    1.38 +dofile "util/sdl_check_compile.lua"
    1.39 +-- a list of dependency functions for the SDL2 project and any other projects
    1.40 +dofile "util/sdl_dependency_checkers.lua"
    1.41 +
    1.42 +-- the following are various options for configuring the meta-build system
    1.43 +newoption {
    1.44 +	trigger = "to",
    1.45 +	value   = "path",
    1.46 +	description = "Set the base output directory for the generated and executed lua file."
    1.47 +}
    1.48 +
    1.49 +newoption {
    1.50 +	trigger = "mingw",
    1.51 +	description = "Runs the premake generation script targeted to MinGW."
    1.52 +}
    1.53 +
    1.54 +newoption {
    1.55 +	trigger = "cygwin",
    1.56 +	description = "Runs the premake generation script targeted to Cygwin."
    1.57 +}
    1.58 +
    1.59 +newoption {
    1.60 +	trigger = "ios",
    1.61 +	description = "Runs the premake generation script targeted to iOS."
    1.62 +}
    1.63 +
    1.64 +-- determine the localized destination path
    1.65 +local baseLoc = "./"
    1.66 +if _OPTIONS["to"] then
    1.67 +	baseLoc = _OPTIONS["to"]:gsub("\\", "/")
    1.68 +end
    1.69 +
    1.70 +local deps = SDL_getDependencies()
    1.71 +for _,v in ipairs(deps) do
    1.72 +	newoption {
    1.73 +		trigger = v:lower(),
    1.74 +		description = "Force on the dependency: " .. v
    1.75 +	}
    1.76 +end
    1.77 +
    1.78 +-- clean action
    1.79 +if _ACTION == "clean" then
    1.80 +	-- this is kept the way it is because premake's default method of cleaning the
    1.81 +	-- build tree is not very good standalone, whereas the following correctly
    1.82 +	-- cleans every build option
    1.83 +	print("Cleaning the build environment...")
    1.84 +	os.rmdir(baseLoc .. "/SDL2")
    1.85 +	os.rmdir(baseLoc .. "/SDL2main")
    1.86 +	os.rmdir(baseLoc .. "/SDL2test")
    1.87 +	os.rmdir(baseLoc .. "/tests")
    1.88 +	os.rmdir(baseLoc .. "/Demos")
    1.89 +	os.rmdir(baseLoc .. "/ipch") -- sometimes shows up
    1.90 +	os.remove(baseLoc .. "/SDL.sln")
    1.91 +	os.remove(baseLoc .. "/SDL.suo")
    1.92 +	os.remove(baseLoc .. "/SDL.v11.suo")
    1.93 +	os.remove(baseLoc .. "/SDL.sdf")
    1.94 +	os.remove(baseLoc .. "/SDL.ncb")
    1.95 +	os.remove(baseLoc .. "/SDL-gen.lua")
    1.96 +	os.remove(baseLoc .. "/SDL_config_premake.h")
    1.97 +	os.remove(baseLoc .. "/Makefile")
    1.98 +	os.rmdir(baseLoc .. "/SDL.xcworkspace")
    1.99 +	os.exit()
   1.100 +end
   1.101 +
   1.102 +-- only run through standard execution if not in help mode
   1.103 +if _OPTIONS["help"] == nil then
   1.104 +	-- load all of the project definitions
   1.105 +	local results = os.matchfiles("projects/**.lua")
   1.106 +	for _,dir in ipairs(results) do
   1.107 +		dofile(dir)
   1.108 +	end
   1.109 +
   1.110 +	-- figure out which configuration template to use
   1.111 +	local premakeConfigHeader = baseLoc .. "/SDL_config_premake.h"
   1.112 +	-- minimal configuration is the default
   1.113 +	local premakeTemplateHeader = "./config/SDL_config_minimal.template.h"
   1.114 +	if SDL_getos() == "windows" or SDL_getos() == "mingw" then
   1.115 +		premakeTemplateHeader = "./config/SDL_config_windows.template.h"
   1.116 +	elseif SDL_getos() == "macosx" then
   1.117 +		premakeTemplateHeader = "./config/SDL_config_macosx.template.h"
   1.118 +	elseif SDL_getos() == "ios" then
   1.119 +		premakeTemplateHeader = "./config/SDL_config_iphoneos.template.h"
   1.120 +	elseif os.get() == "linux" then
   1.121 +		premakeTemplateHeader = "./config/SDL_config_linux.template.h"
   1.122 +	elseif SDL_getos() == "cygwin" then
   1.123 +		premakeTemplateHeader = "./config/SDL_config_cygwin.template.h"
   1.124 +	end
   1.125 +
   1.126 +	local genFile = baseLoc .. "/SDL-gen.lua"
   1.127 +	local file = fileopen(genFile, "wt")
   1.128 +	print("Generating " .. genFile .. "...")
   1.129 +	-- begin generating the config header file
   1.130 +	startGeneration(premakeConfigHeader, premakeTemplateHeader)
   1.131 +
   1.132 +	-- begin generating the actual premake script
   1.133 +	file:print(0, "-- Premake script generated by Simple DirectMedia Layer meta-build script")
   1.134 +	file:print(1, 'solution "SDL"')
   1.135 +	local platforms = { }
   1.136 +	local platformsIndexed = { }
   1.137 +		for n,p in pairs(projects) do
   1.138 +			if p.platforms and #p.platforms ~= 0 then
   1.139 +				for k,v in pairs(p.platforms) do
   1.140 +					platforms[v] = true
   1.141 +				end
   1.142 +			end
   1.143 +		end
   1.144 +		for n,v in pairs(platforms) do
   1.145 +			platformsIndexed[#platformsIndexed + 1] = n
   1.146 +		end
   1.147 +		file:print(2, implode(platformsIndexed, 'platforms {', '"', '"', ', ', '}'))
   1.148 +		file:print(2, 'configurations { "Debug", "Release" }')
   1.149 +		for n,p in pairs(projects) do
   1.150 +			if p.compat then
   1.151 +				local proj = {}
   1.152 +				if p.projectLocation ~= nil then
   1.153 +					proj.location = p.projectLocation .. "/" .. p.name
   1.154 +				else
   1.155 +					proj.location = p.name .. "/"
   1.156 +				end
   1.157 +				proj.includedirs = { path.getrelative(baseLoc,
   1.158 +					path.getdirectory(premakeConfigHeader)),
   1.159 +					path.getrelative(baseLoc, "../include") }
   1.160 +				proj.libdirs = { }
   1.161 +				proj.files = { }
   1.162 +				local links = { }
   1.163 +				local dbgCopyTable = { }
   1.164 +				local relCopyTable = { }
   1.165 +				-- custom links that shouldn't exist...
   1.166 +				-- (these should always happen before dependencies)
   1.167 +				if p.customLinks ~= nil then
   1.168 +					for k,lnk in pairs(p.customLinks) do
   1.169 +						table.insert(links, lnk)
   1.170 +					end
   1.171 +				end
   1.172 +				-- setup project dependencies
   1.173 +				local dependencyLocs = { }
   1.174 +				if p.projectDependencies ~= nil and #p.projectDependencies ~= 0 then
   1.175 +					for k,projname in pairs(p.projectDependencies) do
   1.176 +						local depproj = projects[projname]
   1.177 +						-- validation that it exists and can be linked to
   1.178 +						if depproj ~= nil and (depproj.kind == "SharedLib" or depproj.kind == "StaticLib") then
   1.179 +							if depproj.kind == "SharedLib" then
   1.180 +								local deplocation = nil
   1.181 +								if depproj.projectLocation ~= nil then
   1.182 +									deplocation = depproj.projectLocation .. "/" .. p.name
   1.183 +								else
   1.184 +									deplocation = depproj.name .. "/"
   1.185 +								end
   1.186 +								table.insert(dependencyLocs, { location = deplocation, name = projname })
   1.187 +							else -- static lib
   1.188 +								-- we are now dependent on everything the static lib is dependent on
   1.189 +								if depproj.customLinks ~= nil then
   1.190 +									for k,lnk in pairs(depproj.customLinks) do
   1.191 +										table.insert(links, lnk)
   1.192 +									end
   1.193 +								end
   1.194 +								-- also include links from dependencies
   1.195 +								for i,d in pairs(depproj.dependencyTree) do
   1.196 +									if d.links then
   1.197 +										for k,v in pairs(d.links) do
   1.198 +											local propPath = v:gsub("\\", "/")
   1.199 +											table.insert(links, propPath)
   1.200 +										end
   1.201 +									end
   1.202 +								end
   1.203 +							end
   1.204 +							-- finally, depend on the project itself
   1.205 +							table.insert(links, projname)
   1.206 +						elseif depproj == nil then
   1.207 +							print("Warning: Missing external dependency for project: ".. p.name ..
   1.208 +								". Be sure you setup project dependencies in a logical order.")
   1.209 +						else
   1.210 +							print("Warning: Cannot link " .. p.name .. " to second project " ..
   1.211 +								projname .. " because the second project is not a library.")
   1.212 +						end
   1.213 +					end
   1.214 +				end
   1.215 +				-- iterate across all root directories, matching source directories
   1.216 +				local dirs = createDirTable(p.sourcedir)
   1.217 +				-- but first, handle any files specifically set in the project, rather than
   1.218 +				-- its dependencies
   1.219 +				-- register c and h files in this directory
   1.220 +				if (p.files ~= nil and #p.files ~= 0) or (p.paths ~= nil and #p.paths ~= 0) then
   1.221 +					-- handle all lists of files
   1.222 +					if p.files ~= nil and #p.files ~= 0 then
   1.223 +						for k,filepat in pairs(p.files) do
   1.224 +							for k,f in pairs(os.matchfiles(p.sourcedir .. filepat)) do
   1.225 +								table.insert(proj.files, path.getrelative(baseLoc, f))
   1.226 +							end
   1.227 +						end
   1.228 +					end -- end props files if
   1.229 +					-- add all .c/.h files from each path
   1.230 +					-- handle all related paths
   1.231 +					if p.paths ~= nil and #p.paths ~= 0 then
   1.232 +						for j,filepat in ipairs(p.paths) do
   1.233 +							for k,f in pairs(os.matchfiles(p.sourcedir .. filepat .. "*.c")) do
   1.234 +								table.insert(proj.files, path.getrelative(baseLoc, f))
   1.235 +							end
   1.236 +							for k,f in pairs(os.matchfiles(p.sourcedir .. filepat .. "*.h")) do
   1.237 +								table.insert(proj.files, path.getrelative(baseLoc, f))
   1.238 +							end
   1.239 +							-- mac osx
   1.240 +							for k,f in pairs(os.matchfiles(p.sourcedir .. filepat .. "*.m")) do
   1.241 +								table.insert(proj.files, path.getrelative(baseLoc, f))
   1.242 +							end
   1.243 +						end
   1.244 +					end -- end of props paths if
   1.245 +				end -- end of check for files/paths in main project
   1.246 +				-- if this project has any configuration flags, add them to the current file
   1.247 +				if p.config then
   1.248 +					addConfig(p.config)
   1.249 +				end
   1.250 +				-- now, handle files and paths for dependencies
   1.251 +				for i,props in ipairs(p.dependencyTree) do
   1.252 +					if props.compat then
   1.253 +						-- register c and h files in this directory
   1.254 +						-- handle all lists of files
   1.255 +						if props.files ~= nil and #props.files ~= 0 then
   1.256 +							for k,filepat in pairs(props.files) do
   1.257 +								for k,f in pairs(os.matchfiles(p.sourcedir .. filepat)) do
   1.258 +									table.insert(proj.files, path.getrelative(baseLoc, f))
   1.259 +								end
   1.260 +							end
   1.261 +						end -- end props files if
   1.262 +						-- add all .c/.h files from each path
   1.263 +						-- handle all related paths
   1.264 +						if props.paths ~= nil and #props.paths ~= 0 then
   1.265 +							for j,filepat in ipairs(props.paths) do
   1.266 +								for k,f in pairs(os.matchfiles(p.sourcedir .. filepat .. "*.c")) do
   1.267 +									table.insert(proj.files, path.getrelative(baseLoc, f))
   1.268 +								end
   1.269 +								for k,f in pairs(os.matchfiles(p.sourcedir .. filepat .. "*.h")) do
   1.270 +									table.insert(proj.files, path.getrelative(baseLoc, f))
   1.271 +								end
   1.272 +								-- mac osx
   1.273 +								for k,f in pairs(os.matchfiles(p.sourcedir .. filepat .. "*.m")) do
   1.274 +									table.insert(proj.files, path.getrelative(baseLoc, f))
   1.275 +								end
   1.276 +							end
   1.277 +						end -- end of props paths if
   1.278 +						-- if this dependency has any special configuration flags, add 'em
   1.279 +						if props.config then
   1.280 +							addConfig(props.config)
   1.281 +						end -- end of props config if check
   1.282 +					end -- end check for compatibility
   1.283 +				end -- end of props loop
   1.284 +				--local debugConfig = configuration("Debug")
   1.285 +				local debugConfig = {}
   1.286 +				local releaseConfig = {}
   1.287 +				debugConfig.defines = { "USING_PREMAKE_CONFIG_H", "_DEBUG" }
   1.288 +				releaseConfig.defines = { "USING_PREMAKE_CONFIG_H", "NDEBUG" }
   1.289 +				-- setup per-project defines
   1.290 +				if p.defines ~= nil then
   1.291 +					for k,def in pairs(p.defines) do
   1.292 +						table.insert(debugConfig.defines, def)
   1.293 +						table.insert(releaseConfig.defines, def)
   1.294 +					end
   1.295 +				end
   1.296 +				debugConfig.buildoptions = { }
   1.297 +				if SDL_getos() == "windows" then
   1.298 +					table.insert(debugConfig.buildoptions, "/MDd")
   1.299 +				end
   1.300 +				debugConfig.linkoptions = { }
   1.301 +				releaseConfig.buildoptions = {}
   1.302 +				releaseConfig.linkoptions = {}
   1.303 +				local baseBuildDir = "/Build"
   1.304 +				if os.get() == "windows" then
   1.305 +					baseBuildDir = "/Win32"
   1.306 +				end
   1.307 +				debugConfig.flags = { "Symbols" }
   1.308 +				debugConfig.targetdir = proj.location .. baseBuildDir .. "/Debug"
   1.309 +				releaseConfig.flags = { "OptimizeSpeed" }
   1.310 +				releaseConfig.targetdir = proj.location .. baseBuildDir .. "/Release"
   1.311 +				-- setup postbuild options
   1.312 +				local dbgPostbuildcommands = { }
   1.313 +				local relPostbuildcommands = { }
   1.314 +				-- handle copying depended shared libraries to correct folders
   1.315 +				if os.get() == "windows" then
   1.316 +					for k,deploc in pairs(dependencyLocs) do
   1.317 +						table.insert(dbgCopyTable, { src = deploc.location .. baseBuildDir .. "/Debug/" .. deploc.name .. ".dll",
   1.318 +							dst = debugConfig.targetdir .. "/" .. deploc.name .. ".dll" })
   1.319 +						table.insert(relCopyTable, { src = deploc.location .. baseBuildDir .. "/Release/" .. deploc.name .. ".dll",
   1.320 +							dst = releaseConfig.targetdir .. "/" .. deploc.name .. ".dll" })
   1.321 +					end
   1.322 +				end
   1.323 +				if p.copy ~= nil then
   1.324 +					for k,file in pairs(p.copy) do
   1.325 +						-- the following builds relative paths native to the current system for copying, other
   1.326 +						-- than the copy command itself, this is essentially cross-platform for paths
   1.327 +					
   1.328 +						-- all custom copies should be relative to the current working directory
   1.329 +						table.insert(dbgCopyTable, { src = path.getrelative(baseLoc, p.sourcedir .. "/" .. file), dst = debugConfig.targetdir .. "/" .. file })
   1.330 +						table.insert(relCopyTable, { src = path.getrelative(baseLoc, p.sourcedir .. "/" .. file), dst = releaseConfig.targetdir .. "/" .. file })
   1.331 +					end
   1.332 +				end
   1.333 +				for k,file in pairs(dbgCopyTable) do
   1.334 +					-- all copies should be relative to project location, based on platform
   1.335 +					local relLocation = "./"
   1.336 +					--if os.get() == "windows" then
   1.337 +						relLocation = proj.location
   1.338 +					--end
   1.339 +					local fromPath = "./" .. path.getrelative(relLocation, file.src)
   1.340 +					local toPath = "./" .. path.getrelative(relLocation, file.dst)
   1.341 +					local toPathParent = path.getdirectory(toPath)
   1.342 +					local copyCommand = "cp"
   1.343 +					local destCheck = "if [ ! -d \\\"" .. toPathParent .. "\\\" ]; then mkdir -p \\\"" .. toPathParent .. "\\\"; fi"
   1.344 +					if SDL_getos() ~= "windows" and fromPath:find("*") ~= nil then
   1.345 +						-- to path must be a directory for * copies
   1.346 +						toPath = path.getdirectory(toPath)
   1.347 +					end
   1.348 +					if SDL_getos() == "windows" then
   1.349 +						fromPath = path.translate(fromPath, "/"):gsub("/", "\\\\")
   1.350 +						toPath = path.translate(toPath, "/"):gsub("/", "\\\\")
   1.351 +						toPathParent = path.translate(toPathParent, "/"):gsub("/", "\\\\")
   1.352 +						copyCommand = "copy"
   1.353 +						destCheck = "if not exist \\\"" .. toPathParent .. "\\\" ( mkdir \\\"" .. toPathParent .. "\\\" )"
   1.354 +					else
   1.355 +						fromPath = path.translate(fromPath, nil):gsub("\\", "/")
   1.356 +						toPath = path.translate(toPath, nil):gsub("\\", "/")
   1.357 +					end
   1.358 +					-- command will check for destination directory to exist and, if it doesn't,
   1.359 +					-- it will make the directory and then copy over any assets
   1.360 +					local quotedFromPath = fromPath
   1.361 +					if SDL_getos() == "windows" or fromPath:find("*") == nil then
   1.362 +						quotedFromPath = '\\"' .. quotedFromPath .. '\\"'
   1.363 +					end
   1.364 +					table.insert(dbgPostbuildcommands, destCheck)
   1.365 +					table.insert(dbgPostbuildcommands,
   1.366 +						copyCommand .. " " ..
   1.367 +						quotedFromPath .. " \\\"" ..
   1.368 +						toPath .. "\\\"")
   1.369 +				end
   1.370 +				for k,file in pairs(relCopyTable) do
   1.371 +					-- all copies should be relative to project location, based on platform
   1.372 +					local relLocation = "./"
   1.373 +					relLocation = proj.location
   1.374 +					local fromPath = "./" .. path.getrelative(relLocation, file.src)
   1.375 +					local toPath = "./" .. path.getrelative(relLocation, file.dst)
   1.376 +					local toPathParent = path.getdirectory(toPath)
   1.377 +					local copyCommand = "cp"
   1.378 +					local destCheck = "if [ ! -d \\\"" .. toPathParent .. "\\\" ]; then mkdir -p \\\"" .. toPathParent .. "\\\"; fi"
   1.379 +					if SDL_getos() ~= "windows" and fromPath:find("*") ~= nil then
   1.380 +						-- to path must be a directory for * copies
   1.381 +						toPath = path.getdirectory(toPath)
   1.382 +					end
   1.383 +					if SDL_getos() == "windows" then
   1.384 +						fromPath = path.translate(fromPath, "/"):gsub("/", "\\\\")
   1.385 +						toPath = path.translate(toPath, "/"):gsub("/", "\\\\")
   1.386 +						toPathParent = path.translate(toPathParent, "/"):gsub("/", "\\\\")
   1.387 +						copyCommand = "copy"
   1.388 +						destCheck = "if not exist \\\"" .. toPathParent .. "\\\" ( mkdir \\\"" .. toPathParent .. "\\\" )"
   1.389 +					else
   1.390 +						fromPath = path.translate(fromPath, nil):gsub("\\", "/")
   1.391 +						toPath = path.translate(toPath, nil):gsub("\\", "/")
   1.392 +					end
   1.393 +					-- command will check for destination directory to exist and, if it doesn't,
   1.394 +					-- it will make the directory and then copy over any assets
   1.395 +					local quotedFromPath = fromPath
   1.396 +					if SDL_getos() == "windows" or fromPath:find("*") == nil then
   1.397 +						quotedFromPath = '\\"' .. quotedFromPath .. '\\"'
   1.398 +					end
   1.399 +					table.insert(relPostbuildcommands, destCheck)
   1.400 +					table.insert(relPostbuildcommands,
   1.401 +						copyCommand .. " " ..
   1.402 +						quotedFromPath .. " \\\"" ..
   1.403 +						toPath .. "\\\"")
   1.404 +				end
   1.405 +				debugConfig.postbuildcommands = dbgPostbuildcommands
   1.406 +				debugConfig.links = links
   1.407 +				releaseConfig.postbuildcommands = relPostbuildcommands
   1.408 +				releaseConfig.links = links -- release links?
   1.409 +				for i,d in pairs(p.dependencyTree) do
   1.410 +					if d.includes then
   1.411 +						for k,v in pairs(d.includes) do
   1.412 +							local propPath = v:gsub("\\", "/")
   1.413 +							proj.includedirs[propPath] = propPath
   1.414 +						end
   1.415 +					end
   1.416 +					if d.libs then
   1.417 +						for k,v in pairs(d.libs) do
   1.418 +							local propPath = v:gsub("\\", "/")
   1.419 +							proj.libdirs[propPath] = propPath
   1.420 +						end
   1.421 +					end
   1.422 +					if d.links then
   1.423 +						for k,v in pairs(d.links) do
   1.424 +							local propPath = v:gsub("\\", "/")
   1.425 +							debugConfig.links[#debugConfig.links + 1] = propPath
   1.426 +						end
   1.427 +					end
   1.428 +				end
   1.429 +				if #proj.files > 0 then
   1.430 +					file:print(1, 'project "' .. p.name .. '"')
   1.431 +					file:print(2, 'targetname "' .. p.name .. '"')
   1.432 +					-- note: commented out because I think this hack is unnecessary
   1.433 +					--if iOSMode and p.kind == "ConsoleApp" then
   1.434 +						-- hack for iOS where we cannot build "tools"/ConsoleApps in
   1.435 +						-- Xcode for iOS, so we convert them over to WindowedApps
   1.436 +					--	p.kind = "WindowedApp"
   1.437 +					--end
   1.438 +					file:print(2, 'kind "' .. p.kind .. '"')
   1.439 +					file:print(2, 'language "' .. p.language .. '"')
   1.440 +					file:print(2, 'location "' .. proj.location .. '"')
   1.441 +					file:print(2, 'flags { "NoExceptions" }') -- NoRTTI
   1.442 +					file:print(2, 'buildoptions { }')--"/GS-" }')
   1.443 +					file:print(2, implode(proj.includedirs, 'includedirs {', '"', '"', ', ', '}'))
   1.444 +					file:print(2, implode(proj.libdirs, 'libdirs {', '"', '"', ', ', '}'))
   1.445 +					file:print(2, implode(proj.files, 'files {', '"', '"', ', ', '}'))
   1.446 +					-- debug configuration
   1.447 +					file:print(2, 'configuration "Debug"')
   1.448 +					file:print(3, 'targetdir "' .. debugConfig.targetdir .. '"')
   1.449 +					-- debug dir is relative to the solution's location
   1.450 +					file:print(3, 'debugdir "' .. debugConfig.targetdir .. '"')
   1.451 +					file:print(3, implode(debugConfig.defines, 'defines {', '"', '"', ', ', '}'))
   1.452 +					file:print(3, implode(debugConfig.links, "links {", '"', '"', ', ', "}"))
   1.453 +					if SDL_getos() == "mingw" then
   1.454 +						-- static runtime
   1.455 +						file:print(3, 'linkoptions { "-lmingw32 -static-libgcc" }')
   1.456 +					end
   1.457 +					if SDL_getos() == "cygwin" then
   1.458 +						file:print(3, 'linkoptions { "-static-libgcc" }')
   1.459 +					end
   1.460 +					file:print(3, implode(debugConfig.flags, "flags {", '"', '"', ', ', "}"))
   1.461 +					file:print(3, implode(debugConfig.postbuildcommands, "postbuildcommands {", '"', '"', ', ', "}"))
   1.462 +					-- release configuration
   1.463 +					file:print(2, 'configuration "Release"')
   1.464 +					file:print(3, 'targetdir "' .. releaseConfig.targetdir .. '"')
   1.465 +					-- debug dir is relative to the solution's location
   1.466 +					file:print(3, 'debugdir "' .. releaseConfig.targetdir .. '"')
   1.467 +					file:print(3, implode(releaseConfig.defines, 'defines {', '"', '"', ', ', '}'))
   1.468 +					file:print(3, implode(releaseConfig.links, "links {", '"', '"', ', ', "}"))
   1.469 +					if SDL_getos() == "mingw" then
   1.470 +						-- static runtime
   1.471 +						file:print(3, 'linkoptions { "-lmingw32 -static-libgcc" }')
   1.472 +					end
   1.473 +					file:print(3, implode(releaseConfig.flags, "flags {", '"', '"', ', ', "}"))
   1.474 +					file:print(3, implode(releaseConfig.postbuildcommands, "postbuildcommands {", '"', '"', ', ', "}"))
   1.475 +				end -- end check for valid project (files to build)
   1.476 +			end -- end compatibility check for projects
   1.477 +		end -- end for loop for projects
   1.478 +
   1.479 +	endGeneration() -- finish generating the config header file
   1.480 +	file:close()
   1.481 +
   1.482 +	-- generation is over, now execute the generated file, setup the premake
   1.483 +	-- solution, and let premake execute the action and generate the project files
   1.484 +	dofile(genFile)
   1.485 +end -- end check for not being in help mode
   1.486 \ No newline at end of file