From f2b52173c7a2a45cd2b3c51fb62488ba3d0dcbbf Mon Sep 17 00:00:00 2001 From: starkos Date: Fri, 8 May 2009 20:18:47 +0000 Subject: [PATCH] Added PS3-specific target naming --- src/_manifest.lua | 3 +- src/actions/codelite/_codelite.lua | 1 - src/actions/make/_make.lua | 3 +- src/actions/make/make_csharp.lua | 2 +- src/actions/vstudio/_vstudio.lua | 20 ++ src/actions/vstudio/vs2002_csproj.lua | 4 +- src/actions/vstudio/vs2005_csproj.lua | 4 +- src/actions/vstudio/vs200x_vcproj.lua | 78 ++++- src/base/cmdline.lua | 2 +- src/base/configs.lua | 52 +-- src/base/globals.lua | 2 + src/base/path.lua | 2 +- src/base/project.lua | 89 +++-- src/host/scripts.c | 27 +- src/tools/{csc.lua => dotnet.lua} | 15 +- src/tools/gcc.lua | 2 +- tests/test_configs.lua | 24 +- tests/test_gmake_cpp.lua | 10 +- tests/test_targets.lua | 464 ++++++++++++++++---------- tests/test_vs2002_sln.lua | 3 +- tests/test_vs2003_sln.lua | 3 +- tests/test_vs2008_sln.lua | 3 +- tests/test_vs200x_vcproj.lua | 20 +- 23 files changed, 535 insertions(+), 298 deletions(-) rename src/tools/{csc.lua => dotnet.lua} (83%) diff --git a/src/_manifest.lua b/src/_manifest.lua index c6c406fa..0fb03417 100644 --- a/src/_manifest.lua +++ b/src/_manifest.lua @@ -19,8 +19,9 @@ "base/configs.lua", "base/api.lua", "base/cmdline.lua", - "tools/csc.lua", + "tools/dotnet.lua", "tools/gcc.lua", + "tools/msc.lua", "tools/ow.lua", "base/validate.lua", "base/help.lua", diff --git a/src/actions/codelite/_codelite.lua b/src/actions/codelite/_codelite.lua index 8dd5a7cf..5cdd7e95 100644 --- a/src/actions/codelite/_codelite.lua +++ b/src/actions/codelite/_codelite.lua @@ -8,7 +8,6 @@ trigger = "codelite", shortname = "CodeLite", description = "CodeLite (experimental)", - targetstyle = "linux", valid_kinds = { "ConsoleApp", "WindowedApp", "StaticLib", "SharedLib" }, diff --git a/src/actions/make/_make.lua b/src/actions/make/_make.lua index a0abe1cb..a449f6d0 100644 --- a/src/actions/make/_make.lua +++ b/src/actions/make/_make.lua @@ -75,7 +75,6 @@ trigger = "gmake", shortname = "GNU Make", description = "GNU makefiles for POSIX, MinGW, and Cygwin", - targetstyle = "linux", valid_kinds = { "ConsoleApp", "WindowedApp", "StaticLib", "SharedLib" }, @@ -83,7 +82,7 @@ valid_tools = { cc = { "gcc" }, - dotnet = { "mono", "ms", "pnet" }, + dotnet = { "mono", "msnet", "pnet" }, }, solutiontemplates = { diff --git a/src/actions/make/make_csharp.lua b/src/actions/make/make_csharp.lua index 7a087136..cd5a1c35 100644 --- a/src/actions/make/make_csharp.lua +++ b/src/actions/make/make_csharp.lua @@ -28,7 +28,7 @@ -- function premake.make_csharp(prj) - local csc = premake.csc + local csc = premake.dotnet -- Do some processing up front: build a list of configuration-dependent libraries. -- Libraries that are built to a location other than $(TARGETDIR) will need to diff --git a/src/actions/vstudio/_vstudio.lua b/src/actions/vstudio/_vstudio.lua index da08505e..7cb98d7d 100644 --- a/src/actions/vstudio/_vstudio.lua +++ b/src/actions/vstudio/_vstudio.lua @@ -319,6 +319,11 @@ valid_kinds = { "ConsoleApp", "WindowedApp", "StaticLib", "SharedLib" }, valid_languages = { "C", "C++", "C#" }, + + valid_tools = { + cc = { "msc" }, + dotnet = { "msnet" }, + }, solutiontemplates = { { ".sln", premake.vs2002_solution }, @@ -342,6 +347,11 @@ valid_kinds = { "ConsoleApp", "WindowedApp", "StaticLib", "SharedLib" }, valid_languages = { "C", "C++", "C#" }, + + valid_tools = { + cc = { "msc" }, + dotnet = { "msnet" }, + }, solutiontemplates = { { ".sln", premake.vs2003_solution }, @@ -365,6 +375,11 @@ valid_kinds = { "ConsoleApp", "WindowedApp", "StaticLib", "SharedLib" }, valid_languages = { "C", "C++", "C#" }, + + valid_tools = { + cc = { "msc" }, + dotnet = { "msnet" }, + }, solutiontemplates = { { ".sln", premake.vs2005_solution }, @@ -388,6 +403,11 @@ valid_kinds = { "ConsoleApp", "WindowedApp", "StaticLib", "SharedLib" }, valid_languages = { "C", "C++", "C#" }, + + valid_tools = { + cc = { "msc" }, + dotnet = { "msnet" }, + }, solutiontemplates = { { ".sln", premake.vs2005_solution }, diff --git a/src/actions/vstudio/vs2002_csproj.lua b/src/actions/vstudio/vs2002_csproj.lua index 535ded4e..f1b9bcec 100644 --- a/src/actions/vstudio/vs2002_csproj.lua +++ b/src/actions/vstudio/vs2002_csproj.lua @@ -54,7 +54,7 @@ if _ACTION == "vs2002" then _p('\t\t\t\tNoStandardLibraries = "false"') end - _p('\t\t\t\tOutputType = "%s"', premake.csc.getkind(prj)) + _p('\t\t\t\tOutputType = "%s"', premake.dotnet.getkind(prj)) if _ACTION == "vs2003" then _p('\t\t\t\tPreBuildEvent = ""') _p('\t\t\t\tPostBuildEvent = ""') @@ -119,7 +119,7 @@ _p('\t\t') _p('\t\t\t') for fcfg in premake.eachfile(prj) do - local action = premake.csc.getbuildaction(fcfg) + local action = premake.dotnet.getbuildaction(fcfg) local fname = path.translate(premake.esc(fcfg.name), "\\") local elements, dependency = getelements(prj, action, fcfg.name) diff --git a/src/actions/vstudio/vs2005_csproj.lua b/src/actions/vstudio/vs2005_csproj.lua index 3aab5659..e35e7814 100644 --- a/src/actions/vstudio/vs2005_csproj.lua +++ b/src/actions/vstudio/vs2005_csproj.lua @@ -85,7 +85,7 @@ _p(' %s', vsversion) _p(' 2.0') _p(' {%s}', prj.uuid) - _p(' %s', premake.csc.getkind(prj)) + _p(' %s', premake.dotnet.getkind(prj)) _p(' Properties') _p(' %s', prj.buildtarget.basename) _p(' %s', prj.buildtarget.basename) @@ -127,7 +127,7 @@ _p(' ') for fcfg in premake.eachfile(prj) do - local action = premake.csc.getbuildaction(fcfg) + 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 diff --git a/src/actions/vstudio/vs200x_vcproj.lua b/src/actions/vstudio/vs200x_vcproj.lua index 8dd27859..459a4763 100644 --- a/src/actions/vstudio/vs200x_vcproj.lua +++ b/src/actions/vstudio/vs200x_vcproj.lua @@ -182,7 +182,7 @@ -- --- Compiler block for the PS3 platform, which uses GCC. +-- Compiler and linker blocks for the PS3 platform, which uses GCC. -- function premake.vs200x_vcproj_VCCLCompilerTool_GCC(cfg) @@ -208,6 +208,80 @@ _p('\t\t\t/>') end + function premake.vs200x_vcproj_VCLinkerTool_GCC(cfg) + _p('\t\t\t 0 then + _p('\t\t\t\tAdditionalOptions="%s"', table.concat(premake.esc(cfg.linkoptions), " ")) + end + + if #cfg.links > 0 then + _p('\t\t\t\tAdditionalDependencies="%s"', table.concat(premake.getlinks(cfg, "all", "fullpath"), " ")) + end + + _p('\t\t\t\tOutputFile="$(OutDir)\\%s"', cfg.buildtarget.name) + _p('\t\t\t\tLinkIncremental="%s"', iif(_VS.optimization(cfg) == 0, 2, 1)) + _p('\t\t\t\tAdditionalLibraryDirectories="%s"', table.concat(premake.esc(path.translate(cfg.libdirs, '\\')) , ";")) + + local deffile = premake.findfile(cfg, ".def") + if deffile then + _p('\t\t\t\tModuleDefinitionFile="%s"', deffile) + end + + if cfg.flags.NoManifest then + _p('\t\t\t\tGenerateManifest="%s"', _VS.bool(false)) + end + + _p('\t\t\t\tGenerateDebugInformation="%s"', _VS.bool(_VS.symbols(cfg) ~= 0)) + + if _VS.symbols(cfg) ~= 0 then + _p('\t\t\t\tProgramDatabaseFile="$(OutDir)\\$(ProjectName).pdb"') + end + + _p('\t\t\t\tSubSystem="%s"', iif(cfg.kind == "ConsoleApp", 1, 2)) + + if _VS.optimization(cfg) ~= 0 then + _p('\t\t\t\tOptimizeReferences="2"') + _p('\t\t\t\tEnableCOMDATFolding="2"') + end + + if (cfg.kind == "ConsoleApp" or cfg.kind == "WindowedApp") and not cfg.flags.WinMain then + _p('\t\t\t\tEntryPointSymbol="mainCRTStartup"') + end + + if cfg.kind == "SharedLib" then + local implibname = path.translate(premake.gettarget(cfg, "link", "windows").fullpath, "\\") + _p('\t\t\t\tImportLibrary="%s"', iif(cfg.flags.NoImportLib, cfg.objectsdir .. "\\" .. path.getname(implibname), implibname)) + end + + _p('\t\t\t\tTargetMachine="1"') + + else + _p('\t\t\t\tName="VCLibrarianTool"') + + local buildoptions = table.join(premake.gcc.getldflags(cfg), cfg.linkoptions) + if #buildoptions > 0 then + _p('\t\t\t\tAdditionalOptions="%s"', premake.esc(table.concat(buildoptions, " "))) + end + + if #cfg.links > 0 then + _p('\t\t\t\tAdditionalDependencies="%s"', table.concat(premake.getlinks(cfg, "all", "fullpath"), " ")) + end + + _p('\t\t\t\tOutputFile="$(OutDir)\\%s"', cfg.buildtarget.name) + _p('\t\t\t\tAdditionalLibraryDirectories="%s"', premake.esc(path.translate(table.concat(cfg.libdirs, ";")))) + end + + _p('\t\t\t/>') + end + + -- -- Resource compiler block. @@ -331,7 +405,7 @@ "VCManagedResourceCompilerTool", "VCResourceCompilerTool", "VCPreLinkEventTool", - "VCLinkerTool", + "VCLinkerTool_GCC", "VCALinkTool", "VCManifestTool", "VCXDCMakeTool", diff --git a/src/base/cmdline.lua b/src/base/cmdline.lua index 47066a6a..812fec3c 100644 --- a/src/base/cmdline.lua +++ b/src/base/cmdline.lua @@ -85,7 +85,7 @@ value = "value", description = "Choose a .NET compiler set", allowed = { - { "ms", "Microsoft .NET (csc)" }, + { "msnet", "Microsoft .NET (csc)" }, { "mono", "Novell Mono (mcs)" }, { "pnet", "Portable.NET (cscc)" }, } diff --git a/src/base/configs.lua b/src/base/configs.lua index 9371eb10..a02353f8 100644 --- a/src/base/configs.lua +++ b/src/base/configs.lua @@ -268,13 +268,6 @@ -- set the project location, if not already set cfg.location = cfg.location or cfg.basedir - - -- deduce and store the applicable tool for this configuration - if cfg.language == "C" or cfg.language == "C++" then - if _OPTIONS.cc then cfg.tool = premake[_OPTIONS.cc] end - elseif cfg.language == "C#" then - if _OPTIONS.dotnet then cfg.tool = premake[_OPTIONS.dotnet] end - end -- figure out the target system local platform = premake.platforms[cfg.platform] @@ -394,28 +387,23 @@ -- Pre-computes the build and link targets for a configuration. -- - local function buildtargets(cfg) + function premake.configs_buildtargets() + for _, sln in ipairs(_SOLUTIONS) do + for _, prj in ipairs(sln.projects) do + for _, cfg in pairs(prj.__configs) do + + local targetstyle = premake.gettool(cfg).targetstyle - -- deduce the target and path style from the current action/tool pairing - local action = premake.actions[_ACTION] - local targetstyle = action.targetstyle or "linux" - if (cfg.tool) then - targetstyle = cfg.tool.targetstyle or targetstyle - end - - -- precompute the target names and paths - cfg.buildtarget = premake.gettarget(cfg, "build", targetstyle) - cfg.linktarget = premake.gettarget(cfg, "link", targetstyle) - - -- translate the paths as appropriate - local pathstyle = action.pathstyle or targetstyle - if (pathstyle == "windows") then - cfg.buildtarget.directory = path.translate(cfg.buildtarget.directory, "\\") - cfg.buildtarget.fullpath = path.translate(cfg.buildtarget.fullpath, "\\") - cfg.linktarget.directory = path.translate(cfg.linktarget.directory, "\\") - cfg.linktarget.fullpath = path.translate(cfg.linktarget.fullpath, "\\") - cfg.objectsdir = path.translate(cfg.objectsdir, "\\") - end + cfg.buildtarget = premake.gettarget(cfg, "build", targetstyle) + cfg.linktarget = premake.gettarget(cfg, "link", targetstyle) + + if (targetstyle == "windows") then + cfg.objectsdir = path.translate(cfg.objectsdir, "\\") + end + + end + end + end end @@ -455,12 +443,6 @@ builduniquedirs() -- walk it again and build the targets and unique directories - for _, sln in ipairs(_SOLUTIONS) do - for _, prj in ipairs(sln.projects) do - for _, cfg in pairs(prj.__configs) do - buildtargets(cfg) - end - end - end + premake.configs_buildtargets(cfg) end diff --git a/src/base/globals.lua b/src/base/globals.lua index c261538c..04a6c38a 100644 --- a/src/base/globals.lua +++ b/src/base/globals.lua @@ -59,11 +59,13 @@ cfgsuffix = "ps3", iscrosscompiler = true, nosharedlibs = true, + targetstyle = "ps3", }, Xbox360 = { cfgsuffix = "xbox360", iscrosscompiler = true, + targetstyle = "windows", }, } diff --git a/src/base/path.lua b/src/base/path.lua index c1df17f8..1ec79c33 100644 --- a/src/base/path.lua +++ b/src/base/path.lua @@ -247,7 +247,7 @@ else sep = "/" end - end + end local result = p:gsub("[/\\]", sep) return result end diff --git a/src/base/project.lua b/src/base/project.lua index 5a3147b9..214a6d95 100644 --- a/src/base/project.lua +++ b/src/base/project.lua @@ -338,30 +338,44 @@ -- --- Assembles a target file name for a configuration. Direction is one of --- "build" (the build target name) or "link" (the name to use when trying --- to link against this target). Style is one of "windows" or "linux". +-- Assembles a target for a particular tool/system/configuration. +-- +-- @param cfg +-- The configuration to be targeted. +-- @param direction +-- One of 'build' for the build target, or 'link' for the linking target. +-- @param tool +-- The target toolset interface. +-- @param system +-- The target operating system; if nil will use current OS settings. +-- @returns +-- An object with these fields: +-- basename - the target with no directory or file extension +-- name - the target name and extension, with no directory +-- directory - relative path to the target, with no file name +-- fullpath - directory, name, and extension -- - function premake.gettarget(cfg, direction, style, os) - -- normalize the arguments - if not os then os = _G["os"].get() end - if (os == "bsd") then os = "linux" end - + function premake.gettarget(cfg, direction, style, system) + if not system then system = os.get() end + if system == "bsd" then system = "linux" end + local kind = cfg.kind - if (cfg.language == "C" or cfg.language == "C++") then + local decorations = premake.platforms[cfg.platform].targetstyle or style + + if premake.iscppproject(cfg) then -- On Windows, shared libraries link against a static import library - if (style == "windows" or os == "windows") and kind == "SharedLib" and direction == "link" then + if (style == "windows" or system == "windows") and kind == "SharedLib" and direction == "link" then kind = "StaticLib" end -- Linux name conventions only apply to static libs on windows (by user request) - if (style == "linux" and os == "windows" and kind ~= "StaticLib") then - style = "windows" + if style == "linux" and system == "windows" and kind ~= "StaticLib" then + decorations = "windows" end - elseif (cfg.language == "C#") then + else -- .NET always uses Windows naming conventions - style = "windows" + decorations = "windows" end -- Initialize the target components @@ -370,13 +384,8 @@ local dir = cfg[field.."dir"] or cfg.targetdir or path.getrelative(cfg.location, cfg.basedir) local prefix = "" local suffix = "" - - -- If using an import library and "NoImportLib" flag is set, library will be in objdir - if cfg.kind == "SharedLib" and kind == "StaticLib" and cfg.flags.NoImportLib then - dir = cfg.objectsdir - end - - if style == "windows" then + + if decorations == "windows" then if kind == "ConsoleApp" or kind == "WindowedApp" then suffix = ".exe" elseif kind == "SharedLib" then @@ -384,8 +393,8 @@ elseif kind == "StaticLib" then suffix = ".lib" end - elseif style == "linux" then - if (kind == "WindowedApp" and os == "macosx") then + elseif decorations == "linux" then + if kind == "WindowedApp" and system == "macosx" then dir = path.join(dir, name .. ".app/Contents/MacOS") elseif kind == "SharedLib" then prefix = "lib" @@ -394,8 +403,15 @@ prefix = "lib" suffix = ".a" end + elseif decorations == "ps3" then + if kind == "ConsoleApp" or kind == "WindowedApp" then + suffix = ".elf" + elseif kind == "StaticLib" then + prefix = "lib" + suffix = ".a" + end end - + prefix = cfg[field.."prefix"] or cfg.targetprefix or prefix suffix = cfg[field.."extension"] or cfg.targetextension or suffix @@ -404,11 +420,32 @@ result.name = prefix .. name .. suffix result.directory = dir result.fullpath = path.join(result.directory, result.name) + + if style == "windows" then + result.directory = path.translate(result.directory, "\\") + result.fullpath = path.translate(result.fullpath, "\\") + end + return result end - +-- +-- Return the appropriate tool interface, based on the target language and +-- any relevant command-line options. +-- + + function premake.gettool(cfg) + if premake.iscppproject(cfg) then + if not _OPTIONS.cc then _OPTIONS.cc = premake.actions[_ACTION].valid_tools.cc[1] end + return premake[_OPTIONS.cc] + else + return premake.dotnet + end + end + + + -- -- Returns true if the solution contains at least one C/C++ project. -- @@ -456,7 +493,7 @@ end - + -- -- Walk the list of source code files, breaking them into "groups" based -- on the directory hierarchy. diff --git a/src/host/scripts.c b/src/host/scripts.c index 089da777..e22f804f 100644 --- a/src/host/scripts.c +++ b/src/host/scripts.c @@ -7,13 +7,14 @@ const char* builtin_scripts[] = { "--\n\n\n\nfunction string.explode(s, pattern, plain)\nif (pattern == '') then return false end\nlocal pos = 0\nlocal arr = { }\nfor st,sp in function() return s:find(pattern, pos, plain) end do\ntable.insert(arr, s:sub(pos, st-1))\npos = sp + 1\nend\ntable.insert(arr, s:sub(pos))\nreturn arr\nend\n\n\n\n\nfunction string.findlast(s, pattern, plain)\nlocal curr = 0\nrepeat\nlocal next = s:find(pattern, curr + 1, plain)\nif (next) then curr = next end\nuntil (not next)\nif (curr > 0) then\nreturn curr\nend\nend\n\n\n\n\nfunction string.startswith(haystack, needle)\nreturn (haystack:find(needle, 1, true) == 1)\nend", "--\n\n\n\nfunction table.contains(t, value)\nfor _,v in pairs(t) do\nif (v == value) then\nreturn true\nend\nend\nreturn false\nend\n\n\n\nfunction table.extract(arr, fname)\nlocal result = { }\nfor _,v in ipairs(arr) do\ntable.insert(result, v[fname])\nend\nreturn result\nend\n\n\n\n\nfunction table.implode(arr, before, after, between)\nlocal result = \"\"\nfor _,v in ipairs(arr) do\nif (result ~= \"\" and between) then\nresult = result .. between\nend\nresult = result .. before .. v .. after\nend\nreturn result\nend\n\n\n\nfunction table.join(...)\nlocal result = { }\nfor _,t in ipairs(arg) do\nif type(t) == \"table\" then\nfor _,v in ipairs(t) do\ntable.insert(result, v)\nend\nelse\ntable.insert(result, t)\nend\nend\nreturn result\nend\n\n\n\nfunction table.keys(tbl)\nlocal keys = {}\nfor k, _ in pairs(tbl) do\ntable.insert(keys, k)\nend\nreturn keys\nend\n\n\n\nfunction table.translate(arr, translation)\nlocal result = { }\nfor _, value in ipairs(arr) do\nlocal tvalue\nif type(translation) == \"function\" then\ntvalue = translation(value)\nelse\ntvalue = translation[value]\nend\nif (tvalue) then\ntable.insert(result, tvalue)\nend\nend\nreturn result\nend\n\n", "--\n\n\n\nfunction io.capture()\nio.captured = ''\nend\n\n\n\n\nfunction io.endcapture()\nlocal captured = io.captured\nio.captured = nil\nreturn captured\nend\n\n\n\nlocal builtin_open = io.open\nfunction io.open(fname, mode)\nif (mode) then\nif (mode:find(\"w\")) then\nlocal dir = path.getdirectory(fname)\nok, err = os.mkdir(dir)\nif (not ok) then\nerror(err, 0)\nend\nend\nend\nreturn builtin_open(fname, mode)\nend\n\n\n\n\nfunction io.printf(msg, ...)\nif (not io.eol) then\nio.eol = \"\\n\"\nend\n\nlocal s = string.format(msg, unpack(arg))\nif io.captured then\nio.captured = io.captured .. s .. io.eol\nelse\nio.write(s)\nio.write(io.eol)\nend\nend\n\n\n\n_p = io.printf\n", - "--\n\n\n\n_SOLUTIONS = { }\n\n\n\n_TEMPLATES = { }\n\n\n\npremake = { }\n\n\n\npremake.actions = { }\npremake.options = { }\n\n\n\npremake.platforms = \n{\nNative = \n{ \ncfgsuffix = \"\",\n},\nx32 = \n{ \ncfgsuffix = \"32\",\n},\nx64 = \n{ \ncfgsuffix = \"64\",\n},\nUniversal = \n{ \ncfgsuffix = \"unix\",\n},\nUniversal32 = \n{ \ncfgsuffix = \"univ32\",\n},\nUniversal64 = \n{ \ncfgsuffix = \"univ64\",\n},\nPS3 = \n{ \ncfgsuffix = \"ps3\",\niscrosscompiler = true,\nnosharedlibs = true,\n},\nXbox360 = \n{ \ncfgsuffix = \"xbox360\",\niscrosscompiler = true,\n},\n}\n\n\n\nlocal builtin_dofile = dofile\nfunction dofile(fname)\n-- remember the current working directory; I'll restore it shortly\nlocal oldcwd = os.getcwd()\n\n-- if the file doesn't exist, check the search path\nif (not os.isfile(fname)) then\nlocal path = os.pathsearch(fname, _OPTIONS[\"scripts\"], os.getenv(\"PREMAKE_PATH\"))\nif (path) then\nfname = path..\"/\"..fname\nend\nend\n\n-- use the absolute path to the script file, to avoid any file name\n-- ambiguity if an error should arise\nfname = path.getabsolute(fname)\n\n-- switch the working directory to the new script location\nlocal newcwd = path.getdirectory(fname)\nos.chdir(newcwd)\n\n-- run the chunk. How can I catch variable return values?\nlocal a, b, c, d, e, f = builtin_dofile(fname)\n\n-- restore the previous working directory when done\nos.chdir(oldcwd)\nreturn a, b, c, d, e, f\nend\n\n\n\n\nfunction iif(expr, trueval, falseval)\nif (expr) then\nreturn trueval\nelse\nreturn falseval\nend\nend\n\n\n\n\nfunction include(fname)\nreturn dofile(fname .. \"/premake4.lua\")\nend\n\n\n\n\nfunction printf(msg, ...)\nprint(string.format(msg, unpack(arg)))\nend\n\n\n\n\nlocal builtin_type = type\nfunction type(t)\nlocal mt = getmetatable(t)\nif (mt) then\nif (mt.__type) then\nreturn mt.__type\nend\nend\nreturn builtin_type(t)\nend\n", - "--\n\n\n\nfunction premake.eachconfig(prj, platform)\n-- I probably have the project root config, rather than the actual project\nif prj.project then prj = prj.project end\n\nlocal cfgs = prj.solution.configurations\nlocal i = 0\n\nreturn function ()\ni = i + 1\nif i <= #cfgs then\nreturn premake.getconfig(prj, cfgs[i], platform)\nend\nend\nend\n\n\n\n\nfunction premake.eachfile(prj)\n-- project root config contains the file config list\nif not prj.project then prj = premake.getconfig(prj) end\nlocal i = 0\nlocal t = prj.files\nreturn function ()\ni = i + 1\nif (i <= #t) then\nreturn prj.__fileconfigs[t[i]]\nend\nend\nend\n\n\n\n\nfunction premake.eachproject(sln)\nlocal i = 0\nreturn function ()\ni = i + 1\nif (i <= #sln.projects) then\nlocal prj = sln.projects[i]\nlocal cfg = premake.getconfig(prj)\ncfg.name = prj.name\ncfg.blocks = prj.blocks\nreturn cfg\nend\nend\nend\n\n\n\n\nfunction premake.esc(value)\nif (type(value) == \"table\") then\nlocal result = { }\nfor _,v in ipairs(value) do\ntable.insert(result, premake.esc(v))\nend\nreturn result\nelse\nvalue = value:gsub('&', \"&\")\nvalue = value:gsub('\"', \""\")\nvalue = value:gsub(\"'\", \"'\")\nvalue = value:gsub('<', \"<\")\nvalue = value:gsub('>', \">\")\nvalue = value:gsub('\\r', \" \")\nvalue = value:gsub('\\n', \" \")\nreturn value\nend\nend\n\n\n\n\nfunction premake.filterplatforms(sln, map, default)\nlocal result = { }\nlocal keys = { }\nif sln.platforms then\nfor _, p in ipairs(sln.platforms) do\nif map[p] and not table.contains(keys, map[p]) then\ntable.insert(result, p)\ntable.insert(keys, map[p])\nend\nend\nend\n\nif #result == 0 and default then\ntable.insert(result, default)\nend\n\nreturn result\nend\n\n\n\n\nfunction premake.findproject(name)\nname = name:lower()\nfor _, sln in ipairs(_SOLUTIONS) do\nfor _, prj in ipairs(sln.projects) do\nif (prj.name:lower() == name) then\nreturn prj\nend\nend\nend\nend\n\n\n\n\nfunction premake.findfile(prj, extension)\nfor _, fname in ipairs(prj.files) do\nif fname:endswith(extension) then return fname end\nend\nend\n\n\n\n\nfunction premake.getconfig(prj, cfgname, pltname)\n-- might have the root configuration, rather than the actual project\nif prj.project then \nprj = prj.project \nend\n\n-- if platform is not included in the solution, use general settings instead\nif pltname == \"Native\" or not table.contains(prj.solution.platforms or {}, pltname) then\npltname = nil\nend\n\nlocal key = (cfgname or \"\")\nif pltname then key = key .. pltname end\nreturn prj.__configs[key]\nend\n\n\n\n\nfunction premake.getconfigname(cfgname, platform, useshortname)\nif cfgname then\nlocal name = cfgname\nif platform and platform ~= \"Native\" then\nif useshortname then\nname = name .. premake.platforms[platform].cfgsuffix\nelse\nname = name .. \"|\" .. platform\nend\nend\nreturn iif(useshortname, name:lower(), name)\nend\nend\n\n\n\n\nfunction premake.getdependencies(cfg)\nlocal results = { }\nfor _, link in ipairs(cfg.links) do\nlocal prj = premake.findproject(link)\nif (prj) then\ntable.insert(results, prj)\nend\nend\nreturn results\nend\n\n\n\n\nfunction premake.getlinks(cfg, kind, part)\n-- if I'm building a list of link directories, include libdirs\nlocal result = iif (part == \"directory\" and kind == \"all\", cfg.libdirs, {})\n\n-- am I getting links for a configuration or a project?\nlocal cfgname = iif(cfg.name == cfg.project.name, \"\", cfg.name)\n\nlocal function canlink(source, target)\nif (target.kind ~= \"SharedLib\" and target.kind ~= \"StaticLib\") then return false end\nif (source.language == \"C\" or source.language == \"C++\") then\nif (target.language ~= \"C\" and target.language ~= \"C++\") then return false end\nreturn true\nelseif (source.language == \"C#\") then\nif (target.language ~= \"C#\") then return false end\nreturn true\nend\nend\n\nfor _, link in ipairs(cfg.links) do\nlocal item\n\n-- is this a sibling project?\nlocal prj = premake.findproject(link)\nif prj and kind ~= \"system\" then\n\nlocal prjcfg = premake.getconfig(prj, cfgname)\nif kind == \"dependencies\" or canlink(cfg, prjcfg) then\nif (part == \"directory\") then\nitem = path.rebase(prjcfg.linktarget.directory, prjcfg.location, cfg.location)\nelseif (part == \"basename\") then\nitem = prjcfg.linktarget.basename\nelseif (part == \"fullpath\") then\nitem = path.rebase(prjcfg.linktarget.fullpath, prjcfg.location, cfg.location)\nelseif (part == \"object\") then\nitem = prjcfg\nend\nend\n\nelseif not prj and (kind == \"system\" or kind == \"all\") then\n\nif (part == \"directory\") then\nlocal dir = path.getdirectory(link)\nif (dir ~= \".\") then\nitem = dir\nend\nelseif (part == \"fullpath\") then\nitem = link\nif premake.actions[_ACTION].targetstyle == \"windows\" then\nitem = item .. iif(cfg.language == \"C\" or cfg.language == \"C++\", \".lib\", \".dll\")\nend\nif item:find(\"/\", nil, true) then\nitem = path.getrelative(cfg.basedir, item)\nend\nelse\nitem = link\nend\n\nend\n\nif item then\nif premake.actions[_ACTION].targetstyle == \"windows\" and part ~= \"object\" then\nitem = path.translate(item, \"\\\\\")\nend\nif not table.contains(result, item) then\ntable.insert(result, item)\nend\nend\nend\n\nreturn result\nend\n\n\n\n\nfunction premake.getoutputname(this, namespec)\nlocal fname\nif (type(namespec) == \"function\") then\nfname = namespec(this)\nelse\nfname = this.name .. namespec\nend\nreturn path.join(this.location, fname)\nend\n\n\n\n\nfunction premake.gettarget(cfg, direction, style, os)\n-- normalize the arguments\nif not os then os = _G[\"os\"].get() end\nif (os == \"bsd\") then os = \"linux\" end\n\nlocal kind = cfg.kind\nif (cfg.language == \"C\" or cfg.language == \"C++\") then\n-- On Windows, shared libraries link against a static import library\nif (style == \"windows\" or os == \"windows\") and kind == \"SharedLib\" and direction == \"link\" then\nkind = \"StaticLib\"\nend\n\n-- Linux name conventions only apply to static libs on windows (by user request)\nif (style == \"linux\" and os == \"windows\" and kind ~= \"StaticLib\") then\nstyle = \"windows\"\nend\nelseif (cfg.language == \"C#\") then\n-- .NET always uses Windows naming conventions\nstyle = \"windows\"\nend\n\n-- Initialize the target components\nlocal field = iif(direction == \"build\", \"target\", \"implib\")\nlocal name = cfg[field..\"name\"] or cfg.targetname or cfg.project.name\nlocal dir = cfg[field..\"dir\"] or cfg.targetdir or path.getrelative(cfg.location, cfg.basedir)\nlocal prefix = \"\"\nlocal suffix = \"\"\n\n-- If using an import library and \"NoImportLib\" flag is set, library will be in objdir\nif cfg.kind == \"SharedLib\" and kind == \"StaticLib\" and cfg.flags.NoImportLib then\ndir = cfg.objectsdir\nend\n\nif style == \"windows\" then\nif kind == \"ConsoleApp\" or kind == \"WindowedApp\" then\nsuffix = \".exe\"\nelseif kind == \"SharedLib\" then\nsuffix = \".dll\"\nelseif kind == \"StaticLib\" then\nsuffix = \".lib\"\nend\nelseif style == \"linux\" then\nif (kind == \"WindowedApp\" and os == \"macosx\") then\ndir = path.join(dir, name .. \".app/Contents/MacOS\")\nelseif kind == \"SharedLib\" then\nprefix = \"lib\"\nsuffix = \".so\"\nelseif kind == \"StaticLib\" then\nprefix = \"lib\"\nsuffix = \".a\"\nend\nend\n\nprefix = cfg[field..\"prefix\"] or cfg.targetprefix or prefix\nsuffix = cfg[field..\"extension\"] or cfg.targetextension or suffix\n\nlocal result = { }\nresult.basename = name\nresult.name = prefix .. name .. suffix\nresult.directory = dir\nresult.fullpath = path.join(result.directory, result.name)\nreturn result\nend\n\n\n\n\nfunction premake.hascppproject(sln)\nfor prj in premake.eachproject(sln) do\nif premake.iscppproject(prj) then\nreturn true\nend\nend\nend\n\n\n\n\nfunction premake.hasdotnetproject(sln)\nfor prj in premake.eachproject(sln) do\nif premake.isdotnetproject(prj) then\nreturn true\nend\nend\nend\n\n\n\n\nfunction premake.iscppproject(prj)\nreturn (prj.language == \"C\" or prj.language == \"C++\")\nend\n\n\n\n\nfunction premake.isdotnetproject(prj)\nreturn (prj.language == \"C#\")\nend\n\n\n\n\nlocal function walksources(prj, files, fn, group, nestlevel, finished)\nlocal grouplen = group:len()\nlocal gname = iif(group:endswith(\"/\"), group:sub(1, -2), group)\n\n-- open this new group\nif (nestlevel >= 0) then\nfn(prj, gname, \"GroupStart\", nestlevel)\nend\n\n-- scan the list of files for items which belong in this group\nfor _,fname in ipairs(files) do\nif (fname:startswith(group)) then\n\n-- is there a subgroup within this item?\nlocal _,split = fname:find(\"[^\\.]/\", grouplen + 1)\nif (split) then\nlocal subgroup = fname:sub(1, split)\nif (not finished[subgroup]) then\nfinished[subgroup] = true\nwalksources(prj, files, fn, subgroup, nestlevel + 1, finished)\nend\nend\n\nend\nend\n\n-- process all files that belong in this group\nfor _,fname in ipairs(files) do\nif (fname:startswith(group) and not fname:find(\"[^\\.]/\", grouplen + 1)) then\nfn(prj, fname, \"GroupItem\", nestlevel + 1)\nend\nend\n\n-- close the group\nif (nestlevel >= 0) then\nfn(prj, gname, \"GroupEnd\", nestlevel)\nend\nend\n\n\nfunction premake.walksources(prj, files, fn)\nwalksources(prj, files, fn, \"\", -1, {})\nend\n", - "--\n\n\n-- do not copy these fields into the configurations\nlocal nocopy = \n{\nblocks = true,\nkeywords = true,\nprojects = true,\n__configs = true,\n}\n\n-- leave these paths as absolute, rather than converting to project relative\nlocal nofixup =\n{\nbasedir = true,\nlocation = true,\n}\n\n\n\n\nfunction premake.getactiveterms()\nlocal terms = { _ACTION:lower(), os.get() }\n\n-- add option keys or values\nfor key, value in pairs(_OPTIONS) do\nif value ~= \"\" then\ntable.insert(terms, value:lower())\nelse\ntable.insert(terms, key:lower())\nend\nend\n\nreturn terms\nend\n\n\n\n\nfunction premake.escapekeyword(keyword)\nkeyword = keyword:gsub(\"([%.%-%^%$%(%)%%])\", \"%%%1\")\nif keyword:find(\"**\", nil, true) then\nkeyword = keyword:gsub(\"%*%*\", \".*\")\nelse\nkeyword = keyword:gsub(\"%*\", \"[^/]*\")\nend\nreturn keyword:lower()\nend\n\n\n\n\nfunction premake.iskeywordmatch(keyword, terms)\n-- is it negated?\nif keyword:startswith(\"not \") then\nreturn not premake.iskeywordmatch(keyword:sub(5), terms)\nend\n\nfor _, word in ipairs(keyword:explode(\" or \")) do\nlocal pattern = \"^\" .. word .. \"$\"\nfor termkey, term in pairs(terms) do\nif term:match(pattern) then\nreturn termkey\nend\nend\nend\nend\n\n\n\n\nfunction premake.iskeywordsmatch(keywords, terms)\nlocal hasrequired = false\nfor _, keyword in ipairs(keywords) do\nlocal matched = premake.iskeywordmatch(keyword, terms)\nif not matched then\nreturn false\nend\nif matched == \"required\" then\nhasrequired = true\nend\nend\n\nif terms.required and not hasrequired then\nreturn false\nelse\nreturn true\nend\nend\n\n\n\nlocal function adjustpaths(location, obj)\nfor name, value in pairs(obj) do\nlocal field = premake.fields[name]\nif field and value and not nofixup[name] then\nif field.kind == \"path\" then\nobj[name] = path.getrelative(location, value) \nelseif field.kind == \"dirlist\" or field.kind == \"filelist\" then\nfor i, p in ipairs(value) do \nvalue[i] = path.getrelative(location, p) \nend\nend\nend\nend\nend\n\n\n\n\nlocal function mergeobject(dest, src)\nif not src then return end\nfor field, value in pairs(src) do\nif not nocopy[field] then\nif type(value) == \"table\" then\ndest[field] = table.join(dest[field] or {}, value)\nelse\ndest[field] = value\nend\nend\nend\nend\n\n\n\n\nlocal function merge(dest, obj, basis, cfgname, pltname)\npltname = pltname or \"Native\"\n\nlocal key = cfgname or \"\"\nif pltname ~= \"Native\" then\nkey = key .. pltname\nend\n\nlocal cfg = {}\nmergeobject(cfg, basis[key])\nadjustpaths(obj.location, cfg)\nmergeobject(cfg, obj)\n\nlocal terms = premake.getactiveterms()\nterms.config = (cfgname or \"\"):lower()\nterms.platform = pltname:lower()\n\nfor _, blk in ipairs(obj.blocks) do\nif (premake.iskeywordsmatch(blk.keywords, terms)) then\nmergeobject(cfg, blk)\nend\nend\n\ncfg.name = cfgname\ncfg.platform = pltname\ncfg.terms = terms\ndest[key] = cfg\nend\n\n\n\n\nlocal function collapse(obj, basis)\nlocal result = {}\nbasis = basis or {}\n\n-- find the solution, which contains the configuration and platform lists\nlocal sln = obj.solution or obj\n\nmerge(result, obj, basis)\nfor _, cfgname in ipairs(sln.configurations) do\nmerge(result, obj, basis, cfgname, \"Native\")\nfor _, pltname in ipairs(sln.platforms or {}) do\nif pltname ~= \"Native\" then\nmerge(result, obj, basis, cfgname, pltname)\nend\nend\nend\n\nreturn result\nend\n\n\n\nlocal function postprocess(prj, cfg)\ncfg.project = prj\ncfg.shortname = premake.getconfigname(cfg.name, cfg.platform, true)\ncfg.longname = premake.getconfigname(cfg.name, cfg.platform)\n\n-- set the project location, if not already set\ncfg.location = cfg.location or cfg.basedir\n\n-- deduce and store the applicable tool for this configuration\nif cfg.language == \"C\" or cfg.language == \"C++\" then\nif _OPTIONS.cc then cfg.tool = premake[_OPTIONS.cc] end\nelseif cfg.language == \"C#\" then\nif _OPTIONS.dotnet then cfg.tool = premake[_OPTIONS.dotnet] end\nend\n\n-- figure out the target system\nlocal platform = premake.platforms[cfg.platform]\nif platform.iscrosscompiler then\ncfg.system = cfg.platform\nelse\ncfg.system = os.get()\nend\n\n-- adjust the kind as required by the target system\nif cfg.kind == \"SharedLib\" and platform.nosharedlibs then\ncfg.kind = \"StaticLib\"\nend\n\n-- remove excluded files from the file list\nlocal files = { }\nfor _, fname in ipairs(cfg.files) do\nlocal excluded = false\nfor _, exclude in ipairs(cfg.excludes) do\nexcluded = (fname == exclude)\nif (excluded) then break end\nend\n\nif (not excluded) then\ntable.insert(files, fname)\nend\nend\ncfg.files = files\n\n-- fixup the data\nfor name, field in pairs(premake.fields) do\n-- re-key flag fields for faster lookups\nif field.isflags then\nlocal values = cfg[name]\nfor _, flag in ipairs(values) do values[flag] = true end\nend\nend\n\n-- build configuration objects for all files\ncfg.__fileconfigs = { }\nfor _, fname in ipairs(cfg.files) do\ncfg.terms.required = fname:lower()\nlocal fcfg = {}\nfor _, blk in ipairs(cfg.project.blocks) do\nif (premake.iskeywordsmatch(blk.keywords, cfg.terms)) then\nmergeobject(fcfg, blk)\nend\nend\n\n-- add indexed by name and integer\nfcfg.name = fname\ncfg.__fileconfigs[fname] = fcfg\ntable.insert(cfg.__fileconfigs, fcfg)\nend\nend\n\n\n\n\nlocal function builduniquedirs()\nlocal num_variations = 4\n\n-- Start by listing out each possible object directory for each configuration.\n-- Keep a count of how many times each path gets used across the session.\nlocal cfg_dirs = {}\nlocal hit_counts = {}\n\nfor _, sln in ipairs(_SOLUTIONS) do\nfor _, prj in ipairs(sln.projects) do\nfor _, cfg in pairs(prj.__configs) do\n\nlocal dirs = { }\ndirs[1] = path.getabsolute(path.join(cfg.location, cfg.objdir or cfg.project.objdir or \"obj\"))\ndirs[2] = path.join(dirs[1], iif(cfg.platform == \"Native\", \"\", cfg.platform))\ndirs[3] = path.join(dirs[2], cfg.name)\ndirs[4] = path.join(dirs[3], cfg.project.name)\ncfg_dirs[cfg] = dirs\n\nfor v = 1, num_variations do\nlocal d = dirs[v]\nif hit_counts[d] then\nhit_counts[d] = hit_counts[d] + 1\nelse\nhit_counts[d] = 1\nend\nend\n\nend\nend\nend\n\n-- Now assign an object directory to each configuration, skipping those\n-- that are in use somewhere else in the session\nfor _, sln in ipairs(_SOLUTIONS) do\nfor _, prj in ipairs(sln.projects) do\nfor _, cfg in pairs(prj.__configs) do\n\nlocal dir\nfor v = 1, num_variations do\ndir = cfg_dirs[cfg][v]\nif hit_counts[dir] == 1 then break end\nend\ncfg.objectsdir = path.getrelative(cfg.location, dir)\n\nend\nend\nend\n\nend\n\n\n\n\nlocal function buildtargets(cfg)\n\n-- deduce the target and path style from the current action/tool pairing\nlocal action = premake.actions[_ACTION]\nlocal targetstyle = action.targetstyle or \"linux\"\nif (cfg.tool) then\ntargetstyle = cfg.tool.targetstyle or targetstyle\nend\n\n-- precompute the target names and paths\ncfg.buildtarget = premake.gettarget(cfg, \"build\", targetstyle)\ncfg.linktarget = premake.gettarget(cfg, \"link\", targetstyle)\n\n-- translate the paths as appropriate\nlocal pathstyle = action.pathstyle or targetstyle\nif (pathstyle == \"windows\") then\ncfg.buildtarget.directory = path.translate(cfg.buildtarget.directory, \"\\\\\")\ncfg.buildtarget.fullpath = path.translate(cfg.buildtarget.fullpath, \"\\\\\")\ncfg.linktarget.directory = path.translate(cfg.linktarget.directory, \"\\\\\")\ncfg.linktarget.fullpath = path.translate(cfg.linktarget.fullpath, \"\\\\\")\ncfg.objectsdir = path.translate(cfg.objectsdir, \"\\\\\")\nend\nend\n\n\n\n\nfunction premake.buildconfigs()\n\n-- convert project path fields to be relative to project location\nfor _, sln in ipairs(_SOLUTIONS) do\nfor _, prj in ipairs(sln.projects) do\nadjustpaths(prj.location, prj)\nfor _, blk in ipairs(prj.blocks) do\nadjustpaths(prj.location, blk)\nend\nend\nend\n\n-- collapse configuration blocks, so that there is only one block per build\n-- configuration/platform pair, filtered to the current operating environment\nfor _, sln in ipairs(_SOLUTIONS) do\nlocal basis = collapse(sln)\nfor _, prj in ipairs(sln.projects) do\nprj.__configs = collapse(prj, basis)\nfor _, cfg in pairs(prj.__configs) do\npostprocess(prj, cfg)\nend\nend\nend\n\n-- assign unique object directories to each configuration\nbuilduniquedirs()\n\n-- walk it again and build the targets and unique directories\nfor _, sln in ipairs(_SOLUTIONS) do\nfor _, prj in ipairs(sln.projects) do\nfor _, cfg in pairs(prj.__configs) do\nbuildtargets(cfg)\nend\nend\nend\n\nend\n", + "--\n\n\n\n_SOLUTIONS = { }\n\n\n\n_TEMPLATES = { }\n\n\n\npremake = { }\n\n\n\npremake.actions = { }\npremake.options = { }\n\n\n\npremake.platforms = \n{\nNative = \n{ \ncfgsuffix = \"\",\n},\nx32 = \n{ \ncfgsuffix = \"32\",\n},\nx64 = \n{ \ncfgsuffix = \"64\",\n},\nUniversal = \n{ \ncfgsuffix = \"unix\",\n},\nUniversal32 = \n{ \ncfgsuffix = \"univ32\",\n},\nUniversal64 = \n{ \ncfgsuffix = \"univ64\",\n},\nPS3 = \n{ \ncfgsuffix = \"ps3\",\niscrosscompiler = true,\nnosharedlibs = true,\ntargetstyle = \"ps3\",\n},\nXbox360 = \n{ \ncfgsuffix = \"xbox360\",\niscrosscompiler = true,\ntargetstyle = \"windows\",\n},\n}\n\n\n\nlocal builtin_dofile = dofile\nfunction dofile(fname)\n-- remember the current working directory; I'll restore it shortly\nlocal oldcwd = os.getcwd()\n\n-- if the file doesn't exist, check the search path\nif (not os.isfile(fname)) then\nlocal path = os.pathsearch(fname, _OPTIONS[\"scripts\"], os.getenv(\"PREMAKE_PATH\"))\nif (path) then\nfname = path..\"/\"..fname\nend\nend\n\n-- use the absolute path to the script file, to avoid any file name\n-- ambiguity if an error should arise\nfname = path.getabsolute(fname)\n\n-- switch the working directory to the new script location\nlocal newcwd = path.getdirectory(fname)\nos.chdir(newcwd)\n\n-- run the chunk. How can I catch variable return values?\nlocal a, b, c, d, e, f = builtin_dofile(fname)\n\n-- restore the previous working directory when done\nos.chdir(oldcwd)\nreturn a, b, c, d, e, f\nend\n\n\n\n\nfunction iif(expr, trueval, falseval)\nif (expr) then\nreturn trueval\nelse\nreturn falseval\nend\nend\n\n\n\n\nfunction include(fname)\nreturn dofile(fname .. \"/premake4.lua\")\nend\n\n\n\n\nfunction printf(msg, ...)\nprint(string.format(msg, unpack(arg)))\nend\n\n\n\n\nlocal builtin_type = type\nfunction type(t)\nlocal mt = getmetatable(t)\nif (mt) then\nif (mt.__type) then\nreturn mt.__type\nend\nend\nreturn builtin_type(t)\nend\n", + "--\n\n\n\nfunction premake.eachconfig(prj, platform)\n-- I probably have the project root config, rather than the actual project\nif prj.project then prj = prj.project end\n\nlocal cfgs = prj.solution.configurations\nlocal i = 0\n\nreturn function ()\ni = i + 1\nif i <= #cfgs then\nreturn premake.getconfig(prj, cfgs[i], platform)\nend\nend\nend\n\n\n\n\nfunction premake.eachfile(prj)\n-- project root config contains the file config list\nif not prj.project then prj = premake.getconfig(prj) end\nlocal i = 0\nlocal t = prj.files\nreturn function ()\ni = i + 1\nif (i <= #t) then\nreturn prj.__fileconfigs[t[i]]\nend\nend\nend\n\n\n\n\nfunction premake.eachproject(sln)\nlocal i = 0\nreturn function ()\ni = i + 1\nif (i <= #sln.projects) then\nlocal prj = sln.projects[i]\nlocal cfg = premake.getconfig(prj)\ncfg.name = prj.name\ncfg.blocks = prj.blocks\nreturn cfg\nend\nend\nend\n\n\n\n\nfunction premake.esc(value)\nif (type(value) == \"table\") then\nlocal result = { }\nfor _,v in ipairs(value) do\ntable.insert(result, premake.esc(v))\nend\nreturn result\nelse\nvalue = value:gsub('&', \"&\")\nvalue = value:gsub('\"', \""\")\nvalue = value:gsub(\"'\", \"'\")\nvalue = value:gsub('<', \"<\")\nvalue = value:gsub('>', \">\")\nvalue = value:gsub('\\r', \" \")\nvalue = value:gsub('\\n', \" \")\nreturn value\nend\nend\n\n\n\n\nfunction premake.filterplatforms(sln, map, default)\nlocal result = { }\nlocal keys = { }\nif sln.platforms then\nfor _, p in ipairs(sln.platforms) do\nif map[p] and not table.contains(keys, map[p]) then\ntable.insert(result, p)\ntable.insert(keys, map[p])\nend\nend\nend\n\nif #result == 0 and default then\ntable.insert(result, default)\nend\n\nreturn result\nend\n\n\n\n\nfunction premake.findproject(name)\nname = name:lower()\nfor _, sln in ipairs(_SOLUTIONS) do\nfor _, prj in ipairs(sln.projects) do\nif (prj.name:lower() == name) then\nreturn prj\nend\nend\nend\nend\n\n\n\n\nfunction premake.findfile(prj, extension)\nfor _, fname in ipairs(prj.files) do\nif fname:endswith(extension) then return fname end\nend\nend\n\n\n\n\nfunction premake.getconfig(prj, cfgname, pltname)\n-- might have the root configuration, rather than the actual project\nif prj.project then \nprj = prj.project \nend\n\n-- if platform is not included in the solution, use general settings instead\nif pltname == \"Native\" or not table.contains(prj.solution.platforms or {}, pltname) then\npltname = nil\nend\n\nlocal key = (cfgname or \"\")\nif pltname then key = key .. pltname end\nreturn prj.__configs[key]\nend\n\n\n\n\nfunction premake.getconfigname(cfgname, platform, useshortname)\nif cfgname then\nlocal name = cfgname\nif platform and platform ~= \"Native\" then\nif useshortname then\nname = name .. premake.platforms[platform].cfgsuffix\nelse\nname = name .. \"|\" .. platform\nend\nend\nreturn iif(useshortname, name:lower(), name)\nend\nend\n\n\n\n\nfunction premake.getdependencies(cfg)\nlocal results = { }\nfor _, link in ipairs(cfg.links) do\nlocal prj = premake.findproject(link)\nif (prj) then\ntable.insert(results, prj)\nend\nend\nreturn results\nend\n\n\n\n\nfunction premake.getlinks(cfg, kind, part)\n-- if I'm building a list of link directories, include libdirs\nlocal result = iif (part == \"directory\" and kind == \"all\", cfg.libdirs, {})\n\n-- am I getting links for a configuration or a project?\nlocal cfgname = iif(cfg.name == cfg.project.name, \"\", cfg.name)\n\nlocal function canlink(source, target)\nif (target.kind ~= \"SharedLib\" and target.kind ~= \"StaticLib\") then return false end\nif (source.language == \"C\" or source.language == \"C++\") then\nif (target.language ~= \"C\" and target.language ~= \"C++\") then return false end\nreturn true\nelseif (source.language == \"C#\") then\nif (target.language ~= \"C#\") then return false end\nreturn true\nend\nend\n\nfor _, link in ipairs(cfg.links) do\nlocal item\n\n-- is this a sibling project?\nlocal prj = premake.findproject(link)\nif prj and kind ~= \"system\" then\n\nlocal prjcfg = premake.getconfig(prj, cfgname)\nif kind == \"dependencies\" or canlink(cfg, prjcfg) then\nif (part == \"directory\") then\nitem = path.rebase(prjcfg.linktarget.directory, prjcfg.location, cfg.location)\nelseif (part == \"basename\") then\nitem = prjcfg.linktarget.basename\nelseif (part == \"fullpath\") then\nitem = path.rebase(prjcfg.linktarget.fullpath, prjcfg.location, cfg.location)\nelseif (part == \"object\") then\nitem = prjcfg\nend\nend\n\nelseif not prj and (kind == \"system\" or kind == \"all\") then\n\nif (part == \"directory\") then\nlocal dir = path.getdirectory(link)\nif (dir ~= \".\") then\nitem = dir\nend\nelseif (part == \"fullpath\") then\nitem = link\nif premake.actions[_ACTION].targetstyle == \"windows\" then\nitem = item .. iif(cfg.language == \"C\" or cfg.language == \"C++\", \".lib\", \".dll\")\nend\nif item:find(\"/\", nil, true) then\nitem = path.getrelative(cfg.basedir, item)\nend\nelse\nitem = link\nend\n\nend\n\nif item then\nif premake.actions[_ACTION].targetstyle == \"windows\" and part ~= \"object\" then\nitem = path.translate(item, \"\\\\\")\nend\nif not table.contains(result, item) then\ntable.insert(result, item)\nend\nend\nend\n\nreturn result\nend\n\n\n\n\nfunction premake.getoutputname(this, namespec)\nlocal fname\nif (type(namespec) == \"function\") then\nfname = namespec(this)\nelse\nfname = this.name .. namespec\nend\nreturn path.join(this.location, fname)\nend\n\n\n\n\nfunction premake.gettarget(cfg, direction, style, system)\nif not system then system = os.get() end\nif system == \"bsd\" then system = \"linux\" end\n\nlocal kind = cfg.kind\nlocal decorations = premake.platforms[cfg.platform].targetstyle or style\n\nif premake.iscppproject(cfg) then\n-- On Windows, shared libraries link against a static import library\nif (style == \"windows\" or system == \"windows\") and kind == \"SharedLib\" and direction == \"link\" then\nkind = \"StaticLib\"\nend\n\n-- Linux name conventions only apply to static libs on windows (by user request)\nif style == \"linux\" and system == \"windows\" and kind ~= \"StaticLib\" then\ndecorations = \"windows\"\nend\nelse\n-- .NET always uses Windows naming conventions\ndecorations = \"windows\"\nend\n\n-- Initialize the target components\nlocal field = iif(direction == \"build\", \"target\", \"implib\")\nlocal name = cfg[field..\"name\"] or cfg.targetname or cfg.project.name\nlocal dir = cfg[field..\"dir\"] or cfg.targetdir or path.getrelative(cfg.location, cfg.basedir)\nlocal prefix = \"\"\nlocal suffix = \"\"\n\nif decorations == \"windows\" then\nif kind == \"ConsoleApp\" or kind == \"WindowedApp\" then\nsuffix = \".exe\"\nelseif kind == \"SharedLib\" then\nsuffix = \".dll\"\nelseif kind == \"StaticLib\" then\nsuffix = \".lib\"\nend\nelseif decorations == \"linux\" then\nif kind == \"WindowedApp\" and system == \"macosx\" then\ndir = path.join(dir, name .. \".app/Contents/MacOS\")\nelseif kind == \"SharedLib\" then\nprefix = \"lib\"\nsuffix = \".so\"\nelseif kind == \"StaticLib\" then\nprefix = \"lib\"\nsuffix = \".a\"\nend\nelseif decorations == \"ps3\" then\nif kind == \"ConsoleApp\" or kind == \"WindowedApp\" then\nsuffix = \".elf\"\nelseif kind == \"StaticLib\" then\nprefix = \"lib\"\nsuffix = \".a\"\nend\nend\n\nprefix = cfg[field..\"prefix\"] or cfg.targetprefix or prefix\nsuffix = cfg[field..\"extension\"] or cfg.targetextension or suffix\n\nlocal result = { }\nresult.basename = name\nresult.name = prefix .. name .. suffix\nresult.directory = dir\nresult.fullpath = path.join(result.directory, result.name)\n\nif style == \"windows\" then\nresult.directory = path.translate(result.directory, \"\\\\\")\nresult.fullpath = path.translate(result.fullpath, \"\\\\\")\nend\n\nreturn result\nend\n\n\n\nfunction premake.gettool(cfg)\nif premake.iscppproject(cfg) then\nif not _OPTIONS.cc then _OPTIONS.cc = premake.actions[_ACTION].valid_tools.cc[1] end\nreturn premake[_OPTIONS.cc]\nelse\nreturn premake.dotnet\nend\nend\n\n\n\n\nfunction premake.hascppproject(sln)\nfor prj in premake.eachproject(sln) do\nif premake.iscppproject(prj) then\nreturn true\nend\nend\nend\n\n\n\n\nfunction premake.hasdotnetproject(sln)\nfor prj in premake.eachproject(sln) do\nif premake.isdotnetproject(prj) then\nreturn true\nend\nend\nend\n\n\n\n\nfunction premake.iscppproject(prj)\nreturn (prj.language == \"C\" or prj.language == \"C++\")\nend\n\n\n\n\nfunction premake.isdotnetproject(prj)\nreturn (prj.language == \"C#\")\nend\n\n\n\n\nlocal function walksources(prj, files, fn, group, nestlevel, finished)\nlocal grouplen = group:len()\nlocal gname = iif(group:endswith(\"/\"), group:sub(1, -2), group)\n\n-- open this new group\nif (nestlevel >= 0) then\nfn(prj, gname, \"GroupStart\", nestlevel)\nend\n\n-- scan the list of files for items which belong in this group\nfor _,fname in ipairs(files) do\nif (fname:startswith(group)) then\n\n-- is there a subgroup within this item?\nlocal _,split = fname:find(\"[^\\.]/\", grouplen + 1)\nif (split) then\nlocal subgroup = fname:sub(1, split)\nif (not finished[subgroup]) then\nfinished[subgroup] = true\nwalksources(prj, files, fn, subgroup, nestlevel + 1, finished)\nend\nend\n\nend\nend\n\n-- process all files that belong in this group\nfor _,fname in ipairs(files) do\nif (fname:startswith(group) and not fname:find(\"[^\\.]/\", grouplen + 1)) then\nfn(prj, fname, \"GroupItem\", nestlevel + 1)\nend\nend\n\n-- close the group\nif (nestlevel >= 0) then\nfn(prj, gname, \"GroupEnd\", nestlevel)\nend\nend\n\n\nfunction premake.walksources(prj, files, fn)\nwalksources(prj, files, fn, \"\", -1, {})\nend\n", + "--\n\n\n-- do not copy these fields into the configurations\nlocal nocopy = \n{\nblocks = true,\nkeywords = true,\nprojects = true,\n__configs = true,\n}\n\n-- leave these paths as absolute, rather than converting to project relative\nlocal nofixup =\n{\nbasedir = true,\nlocation = true,\n}\n\n\n\n\nfunction premake.getactiveterms()\nlocal terms = { _ACTION:lower(), os.get() }\n\n-- add option keys or values\nfor key, value in pairs(_OPTIONS) do\nif value ~= \"\" then\ntable.insert(terms, value:lower())\nelse\ntable.insert(terms, key:lower())\nend\nend\n\nreturn terms\nend\n\n\n\n\nfunction premake.escapekeyword(keyword)\nkeyword = keyword:gsub(\"([%.%-%^%$%(%)%%])\", \"%%%1\")\nif keyword:find(\"**\", nil, true) then\nkeyword = keyword:gsub(\"%*%*\", \".*\")\nelse\nkeyword = keyword:gsub(\"%*\", \"[^/]*\")\nend\nreturn keyword:lower()\nend\n\n\n\n\nfunction premake.iskeywordmatch(keyword, terms)\n-- is it negated?\nif keyword:startswith(\"not \") then\nreturn not premake.iskeywordmatch(keyword:sub(5), terms)\nend\n\nfor _, word in ipairs(keyword:explode(\" or \")) do\nlocal pattern = \"^\" .. word .. \"$\"\nfor termkey, term in pairs(terms) do\nif term:match(pattern) then\nreturn termkey\nend\nend\nend\nend\n\n\n\n\nfunction premake.iskeywordsmatch(keywords, terms)\nlocal hasrequired = false\nfor _, keyword in ipairs(keywords) do\nlocal matched = premake.iskeywordmatch(keyword, terms)\nif not matched then\nreturn false\nend\nif matched == \"required\" then\nhasrequired = true\nend\nend\n\nif terms.required and not hasrequired then\nreturn false\nelse\nreturn true\nend\nend\n\n\n\nlocal function adjustpaths(location, obj)\nfor name, value in pairs(obj) do\nlocal field = premake.fields[name]\nif field and value and not nofixup[name] then\nif field.kind == \"path\" then\nobj[name] = path.getrelative(location, value) \nelseif field.kind == \"dirlist\" or field.kind == \"filelist\" then\nfor i, p in ipairs(value) do \nvalue[i] = path.getrelative(location, p) \nend\nend\nend\nend\nend\n\n\n\n\nlocal function mergeobject(dest, src)\nif not src then return end\nfor field, value in pairs(src) do\nif not nocopy[field] then\nif type(value) == \"table\" then\ndest[field] = table.join(dest[field] or {}, value)\nelse\ndest[field] = value\nend\nend\nend\nend\n\n\n\n\nlocal function merge(dest, obj, basis, cfgname, pltname)\npltname = pltname or \"Native\"\n\nlocal key = cfgname or \"\"\nif pltname ~= \"Native\" then\nkey = key .. pltname\nend\n\nlocal cfg = {}\nmergeobject(cfg, basis[key])\nadjustpaths(obj.location, cfg)\nmergeobject(cfg, obj)\n\nlocal terms = premake.getactiveterms()\nterms.config = (cfgname or \"\"):lower()\nterms.platform = pltname:lower()\n\nfor _, blk in ipairs(obj.blocks) do\nif (premake.iskeywordsmatch(blk.keywords, terms)) then\nmergeobject(cfg, blk)\nend\nend\n\ncfg.name = cfgname\ncfg.platform = pltname\ncfg.terms = terms\ndest[key] = cfg\nend\n\n\n\n\nlocal function collapse(obj, basis)\nlocal result = {}\nbasis = basis or {}\n\n-- find the solution, which contains the configuration and platform lists\nlocal sln = obj.solution or obj\n\nmerge(result, obj, basis)\nfor _, cfgname in ipairs(sln.configurations) do\nmerge(result, obj, basis, cfgname, \"Native\")\nfor _, pltname in ipairs(sln.platforms or {}) do\nif pltname ~= \"Native\" then\nmerge(result, obj, basis, cfgname, pltname)\nend\nend\nend\n\nreturn result\nend\n\n\n\nlocal function postprocess(prj, cfg)\ncfg.project = prj\ncfg.shortname = premake.getconfigname(cfg.name, cfg.platform, true)\ncfg.longname = premake.getconfigname(cfg.name, cfg.platform)\n\n-- set the project location, if not already set\ncfg.location = cfg.location or cfg.basedir\n\n-- figure out the target system\nlocal platform = premake.platforms[cfg.platform]\nif platform.iscrosscompiler then\ncfg.system = cfg.platform\nelse\ncfg.system = os.get()\nend\n\n-- adjust the kind as required by the target system\nif cfg.kind == \"SharedLib\" and platform.nosharedlibs then\ncfg.kind = \"StaticLib\"\nend\n\n-- remove excluded files from the file list\nlocal files = { }\nfor _, fname in ipairs(cfg.files) do\nlocal excluded = false\nfor _, exclude in ipairs(cfg.excludes) do\nexcluded = (fname == exclude)\nif (excluded) then break end\nend\n\nif (not excluded) then\ntable.insert(files, fname)\nend\nend\ncfg.files = files\n\n-- fixup the data\nfor name, field in pairs(premake.fields) do\n-- re-key flag fields for faster lookups\nif field.isflags then\nlocal values = cfg[name]\nfor _, flag in ipairs(values) do values[flag] = true end\nend\nend\n\n-- build configuration objects for all files\ncfg.__fileconfigs = { }\nfor _, fname in ipairs(cfg.files) do\ncfg.terms.required = fname:lower()\nlocal fcfg = {}\nfor _, blk in ipairs(cfg.project.blocks) do\nif (premake.iskeywordsmatch(blk.keywords, cfg.terms)) then\nmergeobject(fcfg, blk)\nend\nend\n\n-- add indexed by name and integer\nfcfg.name = fname\ncfg.__fileconfigs[fname] = fcfg\ntable.insert(cfg.__fileconfigs, fcfg)\nend\nend\n\n\n\n\nlocal function builduniquedirs()\nlocal num_variations = 4\n\n-- Start by listing out each possible object directory for each configuration.\n-- Keep a count of how many times each path gets used across the session.\nlocal cfg_dirs = {}\nlocal hit_counts = {}\n\nfor _, sln in ipairs(_SOLUTIONS) do\nfor _, prj in ipairs(sln.projects) do\nfor _, cfg in pairs(prj.__configs) do\n\nlocal dirs = { }\ndirs[1] = path.getabsolute(path.join(cfg.location, cfg.objdir or cfg.project.objdir or \"obj\"))\ndirs[2] = path.join(dirs[1], iif(cfg.platform == \"Native\", \"\", cfg.platform))\ndirs[3] = path.join(dirs[2], cfg.name)\ndirs[4] = path.join(dirs[3], cfg.project.name)\ncfg_dirs[cfg] = dirs\n\nfor v = 1, num_variations do\nlocal d = dirs[v]\nif hit_counts[d] then\nhit_counts[d] = hit_counts[d] + 1\nelse\nhit_counts[d] = 1\nend\nend\n\nend\nend\nend\n\n-- Now assign an object directory to each configuration, skipping those\n-- that are in use somewhere else in the session\nfor _, sln in ipairs(_SOLUTIONS) do\nfor _, prj in ipairs(sln.projects) do\nfor _, cfg in pairs(prj.__configs) do\n\nlocal dir\nfor v = 1, num_variations do\ndir = cfg_dirs[cfg][v]\nif hit_counts[dir] == 1 then break end\nend\ncfg.objectsdir = path.getrelative(cfg.location, dir)\n\nend\nend\nend\n\nend\n\n\n\n\nfunction premake.configs_buildtargets()\nfor _, sln in ipairs(_SOLUTIONS) do\nfor _, prj in ipairs(sln.projects) do\nfor _, cfg in pairs(prj.__configs) do\n\nlocal targetstyle = premake.gettool(cfg).targetstyle\n\ncfg.buildtarget = premake.gettarget(cfg, \"build\", targetstyle)\ncfg.linktarget = premake.gettarget(cfg, \"link\", targetstyle)\n\nif (targetstyle == \"windows\") then\ncfg.objectsdir = path.translate(cfg.objectsdir, \"\\\\\")\nend\n\nend\nend\nend\nend\n\n\n\n\nfunction premake.buildconfigs()\n\n-- convert project path fields to be relative to project location\nfor _, sln in ipairs(_SOLUTIONS) do\nfor _, prj in ipairs(sln.projects) do\nadjustpaths(prj.location, prj)\nfor _, blk in ipairs(prj.blocks) do\nadjustpaths(prj.location, blk)\nend\nend\nend\n\n-- collapse configuration blocks, so that there is only one block per build\n-- configuration/platform pair, filtered to the current operating environment\nfor _, sln in ipairs(_SOLUTIONS) do\nlocal basis = collapse(sln)\nfor _, prj in ipairs(sln.projects) do\nprj.__configs = collapse(prj, basis)\nfor _, cfg in pairs(prj.__configs) do\npostprocess(prj, cfg)\nend\nend\nend\n\n-- assign unique object directories to each configuration\nbuilduniquedirs()\n\n-- walk it again and build the targets and unique directories\npremake.configs_buildtargets(cfg)\n\nend\n", "--\n\n\n\npremake.fields = \n{\nbasedir =\n{\nkind = \"path\",\nscope = \"container\",\n},\n\nbuildaction =\n{\nkind = \"string\",\nscope = \"config\",\nallowed = {\n\"Compile\",\n\"Copy\",\n\"Embed\",\n\"None\"\n}\n},\n\nbuildoptions =\n{\nkind = \"list\",\nscope = \"config\",\n},\n\nconfigurations = \n{\nkind = \"list\",\nscope = \"solution\",\n},\n\ndefines =\n{\nkind = \"list\",\nscope = \"config\",\n},\n\nexcludes =\n{\nkind = \"filelist\",\nscope = \"config\",\n},\n\nfiles =\n{\nkind = \"filelist\",\nscope = \"config\",\n},\n\nflags =\n{\nkind = \"list\",\nscope = \"config\",\nisflags = true,\nallowed = {\n\"ExtraWarnings\",\n\"FatalWarnings\",\n\"Managed\",\n\"NativeWChar\",\n\"No64BitChecks\",\n\"NoEditAndContinue\",\n\"NoExceptions\",\n\"NoFramePointer\",\n\"NoImportLib\",\n\"NoManifest\",\n\"NoNativeWChar\",\n\"NoPCH\",\n\"NoRTTI\",\n\"Optimize\",\n\"OptimizeSize\",\n\"OptimizeSpeed\",\n\"SEH\",\n\"StaticRuntime\",\n\"Symbols\",\n\"Unicode\",\n\"Unsafe\",\n\"WinMain\"\n}\n},\n\nimplibdir =\n{\nkind = \"path\",\nscope = \"config\",\n},\n\nimplibextension =\n{\nkind = \"string\",\nscope = \"config\",\n},\n\nimplibname =\n{\nkind = \"string\",\nscope = \"config\",\n},\n\nimplibprefix =\n{\nkind = \"string\",\nscope = \"config\",\n},\n\nincludedirs =\n{\nkind = \"dirlist\",\nscope = \"config\",\n},\n\nkind =\n{\nkind = \"string\",\nscope = \"config\",\nallowed = {\n\"ConsoleApp\",\n\"WindowedApp\",\n\"StaticLib\",\n\"SharedLib\"\n}\n},\n\nlanguage =\n{\nkind = \"string\",\nscope = \"container\",\nallowed = {\n\"C\",\n\"C++\",\n\"C#\"\n}\n},\n\nlibdirs =\n{\nkind = \"dirlist\",\nscope = \"config\",\n},\n\nlinkoptions =\n{\nkind = \"list\",\nscope = \"config\",\n},\n\nlinks =\n{\nkind = \"list\",\nscope = \"config\",\nallowed = function(value)\n-- if library name contains a '/' then treat it as a path to a local file\nif value:find('/', nil, true) then\nvalue = path.getabsolute(value)\nend\nreturn value\nend\n\n},\n\nlocation =\n{\nkind = \"path\",\nscope = \"container\",\n},\n\nobjdir =\n{\nkind = \"path\",\nscope = \"config\",\n},\n\npchheader =\n{\nkind = \"string\",\nscope = \"config\",\n},\n\npchsource =\n{\nkind = \"path\",\nscope = \"config\",\n},\n\nplatforms = \n{\nkind = \"list\",\nscope = \"solution\",\nallowed = table.keys(premake.platforms),\n},\n\npostbuildcommands =\n{\nkind = \"list\",\nscope = \"config\",\n},\n\nprebuildcommands =\n{\nkind = \"list\",\nscope = \"config\",\n},\n\nprelinkcommands =\n{\nkind = \"list\",\nscope = \"config\",\n},\n\nresdefines =\n{\nkind = \"list\",\nscope = \"config\",\n},\n\nresincludedirs =\n{\nkind = \"dirlist\",\nscope = \"config\",\n},\n\nresoptions =\n{\nkind = \"list\",\nscope = \"config\",\n},\n\ntargetdir =\n{\nkind = \"path\",\nscope = \"config\",\n},\n\ntargetextension =\n{\nkind = \"string\",\nscope = \"config\",\n},\n\ntargetname =\n{\nkind = \"string\",\nscope = \"config\",\n},\n\ntargetprefix =\n{\nkind = \"string\",\nscope = \"config\",\n},\n\nuuid =\n{\nkind = \"string\",\nscope = \"container\",\nallowed = function(value)\nlocal ok = true\nif (#value ~= 36) then ok = false end\nfor i=1,36 do\nlocal ch = value:sub(i,i)\nif (not ch:find(\"[ABCDEFabcdef0123456789-]\")) then ok = false end\nend\nif (value:sub(9,9) ~= \"-\") then ok = false end\nif (value:sub(14,14) ~= \"-\") then ok = false end\nif (value:sub(19,19) ~= \"-\") then ok = false end\nif (value:sub(24,24) ~= \"-\") then ok = false end\nif (not ok) then\nreturn nil, \"invalid UUID\"\nend\nreturn value:upper()\nend\n},\n}\n\n\n\n\n\n\nfunction premake.checkvalue(value, allowed)\nif (allowed) then\nif (type(allowed) == \"function\") then\nreturn allowed(value)\nelse\nfor _,v in ipairs(allowed) do\nif (value:lower() == v:lower()) then\nreturn v\nend\nend\nreturn nil, \"invalid value '\" .. value .. \"'\"\nend\nelse\nreturn value\nend\nend\n\n\n\n\nfunction premake.getobject(t)\nlocal container\n\nif (t == \"container\" or t == \"solution\") then\ncontainer = premake.CurrentContainer\nelse\ncontainer = premake.CurrentConfiguration\nend\n\nif t == \"solution\" then\nif type(container) == \"project\" then\ncontainer = container.solution\nend\nif type(container) ~= \"solution\" then\ncontainer = nil\nend\nend\n\nlocal msg\nif (not container) then\nif (t == \"container\") then\nmsg = \"no active solution or project\"\nelseif (t == \"solution\") then\nmsg = \"no active solution\"\nelse\nmsg = \"no active solution, project, or configuration\"\nend\nend\n\nreturn container, msg\nend\n\n\n\n\nfunction premake.setarray(ctype, fieldname, value, allowed)\nlocal container, err = premake.getobject(ctype)\nif (not container) then\nerror(err, 4)\nend\n\nif (not container[fieldname]) then\ncontainer[fieldname] = { }\nend\n\nlocal function doinsert(value, depth)\nif (type(value) == \"table\") then\nfor _,v in ipairs(value) do\ndoinsert(v, depth + 1)\nend\nelse\nvalue, err = premake.checkvalue(value, allowed)\nif (not value) then\nerror(err, depth)\nend\ntable.insert(container[fieldname], value)\nend\nend\n\nif (value) then\ndoinsert(value, 5)\nend\n\nreturn container[fieldname]\nend\n\n\n\n\nlocal function domatchedarray(ctype, fieldname, value, matchfunc)\nlocal result = { }\n\nfunction makeabsolute(value)\nif (type(value) == \"table\") then\nfor _,item in ipairs(value) do\nmakeabsolute(item)\nend\nelse\nif value:find(\"*\") then\nmakeabsolute(matchfunc(value))\nelse\ntable.insert(result, path.getabsolute(value))\nend\nend\nend\n\nmakeabsolute(value)\nreturn premake.setarray(ctype, fieldname, result)\nend\n\nfunction premake.setdirarray(ctype, fieldname, value)\nreturn domatchedarray(ctype, fieldname, value, os.matchdirs)\nend\n\nfunction premake.setfilearray(ctype, fieldname, value)\nreturn domatchedarray(ctype, fieldname, value, os.matchfiles)\nend\n\n\n\n\nfunction premake.setstring(ctype, fieldname, value, allowed)\n-- find the container for this value\nlocal container, err = premake.getobject(ctype)\nif (not container) then\nerror(err, 4)\nend\n\n-- if a value was provided, set it\nif (value) then\nvalue, err = premake.checkvalue(value, allowed)\nif (not value) then \nerror(err, 4)\nend\n\ncontainer[fieldname] = value\nend\n\nreturn container[fieldname]\nend\n\n\n\n\nlocal function accessor(name, value)\nlocal kind = premake.fields[name].kind\nlocal scope = premake.fields[name].scope\nlocal allowed = premake.fields[name].allowed\n\nif (kind == \"string\" or kind == \"path\" and value) then\nif type(value) ~= \"string\" then\nerror(\"string value expected\", 3)\nend\nend\n\nif (kind == \"string\") then\nreturn premake.setstring(scope, name, value, allowed)\nelseif (kind == \"path\") then\nif value then value = path.getabsolute(value) end\nreturn premake.setstring(scope, name, value)\nelseif (kind == \"list\") then\nreturn premake.setarray(scope, name, value, allowed)\nelseif (kind == \"dirlist\") then\nreturn premake.setdirarray(scope, name, value)\nelseif (kind == \"filelist\") then\nreturn premake.setfilearray(scope, name, value)\nend\nend\n\n\n\n\nfor name,_ in pairs(premake.fields) do\n_G[name] = function(value)\nreturn accessor(name, value)\nend\nend\n\n\n\n\nfunction configuration(keywords)\nif not keywords then\nreturn premake.CurrentConfiguration\nend\n\nlocal container, err = premake.getobject(\"container\")\nif (not container) then\nerror(err, 2)\nend\n\nlocal cfg = { }\ntable.insert(container.blocks, cfg)\npremake.CurrentConfiguration = cfg\n\n-- create a keyword list using just the indexed keyword items\ncfg.keywords = { }\nfor _, word in ipairs(table.join({}, keywords)) do\ntable.insert(cfg.keywords, premake.escapekeyword(word))\nend\n\n-- if file patterns are specified, convert them to Lua patterns and add them too\nif keywords.files then\nfor _, pattern in ipairs(table.join({}, keywords.files)) do\npattern = pattern:gsub(\"%.\", \"%%.\")\nif pattern:find(\"**\", nil, true) then\npattern = pattern:gsub(\"%*%*\", \".*\")\nelse\npattern = pattern:gsub(\"%*\", \"[^/]*\")\nend\ntable.insert(cfg.keywords, \"^\" .. pattern .. \"$\")\nend\nend\n\n-- initialize list-type fields to empty tables\nfor name, field in pairs(premake.fields) do\nif (field.kind ~= \"string\" and field.kind ~= \"path\") then\ncfg[name] = { }\nend\nend\n\nreturn cfg\nend\n\n\nfunction project(name)\nif not name then\nreturn iif(type(premake.CurrentContainer) == \"project\", premake.CurrentContainer, nil)\nend\n\n-- identify the parent solution\nlocal sln\nif (type(premake.CurrentContainer) == \"project\") then\nsln = premake.CurrentContainer.solution\nelse\nsln = premake.CurrentContainer\nend\nif (type(sln) ~= \"solution\") then\nerror(\"no active solution\", 2)\nend\n\n-- if this is a new project, create it\npremake.CurrentContainer = sln.projects[name]\nif (not premake.CurrentContainer) then\nlocal prj = { }\npremake.CurrentContainer = prj\n\n-- add to master list keyed by both name and index\ntable.insert(sln.projects, prj)\nsln.projects[name] = prj\n\n-- attach a type\nsetmetatable(prj, {\n__type = \"project\",\n})\n\nprj.solution = sln\nprj.name = name\nprj.basedir = os.getcwd()\nprj.location = prj.basedir\nprj.uuid = os.uuid()\nprj.blocks = { }\nend\n\n-- add an empty, global configuration to the project\nconfiguration { }\n\nreturn premake.CurrentContainer\nend\n\n\nfunction solution(name)\nif not name then\nif type(premake.CurrentContainer) == \"project\" then\nreturn premake.CurrentContainer.solution\nelse\nreturn premake.CurrentContainer\nend\nend\n\npremake.CurrentContainer = _SOLUTIONS[name]\nif (not premake.CurrentContainer) then\nlocal sln = { }\npremake.CurrentContainer = sln\n\n-- add to master list keyed by both name and index\ntable.insert(_SOLUTIONS, sln)\n_SOLUTIONS[name] = sln\n\n-- attach a type\nsetmetatable(sln, { \n__type=\"solution\"\n})\n\nsln.name = name\nsln.location = os.getcwd()\nsln.projects = { }\nsln.blocks = { }\nsln.configurations = { }\nend\n\n-- add an empty, global configuration\nconfiguration { }\n\nreturn premake.CurrentContainer\nend\n\n\n", - "--\n\n\nlocal requiredactionfields =\n{\n\"description\",\n\"trigger\",\n}\n\nlocal requiredoptionfields = \n{\n\"description\",\n\"trigger\"\n}\n\n\n\nfunction newaction(a)\n-- some sanity checking\nlocal missing\nfor _, field in ipairs(requiredactionfields) do\nif (not a[field]) then\nmissing = field\nend\nend\n\nif (missing) then\nerror(\"action needs a \" .. missing, 2)\nend\n\n-- add it to the master list\npremake.actions[a.trigger] = a\nend\n\n\n\n\nfunction newoption(opt)\n-- some sanity checking\nlocal missing\nfor _, field in ipairs(requiredoptionfields) do\nif (not opt[field]) then\nmissing = field\nend\nend\n\nif (missing) then\nerror(\"action needs a \" .. missing, 2)\nend\n\n-- add it to the master list\npremake.options[opt.trigger] = opt\nend\n\n\n\n\nnewoption \n{\ntrigger = \"cc\",\nvalue = \"compiler\",\ndescription = \"Choose a C/C++ compiler set\",\nallowed = {\n{ \"gcc\", \"GNU GCC (gcc/g++)\" },\n{ \"ow\", \"OpenWatcom\" },\n}\n}\n\nnewoption\n{\ntrigger = \"dotnet\",\nvalue = \"value\",\ndescription = \"Choose a .NET compiler set\",\nallowed = {\n{ \"ms\", \"Microsoft .NET (csc)\" },\n{ \"mono\", \"Novell Mono (mcs)\" },\n{ \"pnet\", \"Portable.NET (cscc)\" },\n}\n}\n\nnewoption\n{\ntrigger = \"file\",\nvalue = \"filename\",\ndescription = \"Process the specified Premake script file\"\n}\n\nnewoption\n{\ntrigger = \"help\",\ndescription = \"Display this information\"\n}\n\nnewoption\n{\ntrigger = \"os\",\nvalue = \"value\",\ndescription = \"Generate files for a different operating system\",\nallowed = {\n{ \"bsd\", \"OpenBSD, NetBSD, or FreeBSD\" },\n{ \"linux\", \"Linux\" },\n{ \"macosx\", \"Apple Mac OS X\" },\n{ \"windows\", \"Microsoft Windows\" },\n}\n}\n\nnewoption\n{\ntrigger = \"platform\",\nvalue = \"value\",\ndescription = \"Add target architecture (if supported by action)\",\nallowed = {\n{ \"x32\", \"32-bit\" },\n{ \"x64\", \"64-bit\" },\n{ \"universal\", \"Mac OS X Universal, 32- and 64-bit\" },\n{ \"universal32\", \"Mac OS X Universal, 32-bit only\" },\n{ \"universal64\", \"Mac OS X Universal, 64-bit only\" },\n{ \"ps3\", \"Playstation 3 (experimental)\" },\n{ \"xbox360\", \"Xbox 360 (experimental)\" },\n}\n}\n\nnewoption\n{\ntrigger = \"scripts\",\nvalue = \"path\",\ndescription = \"Search for additional scripts on the given path\"\n}\n\nnewoption\n{\ntrigger = \"version\",\ndescription = \"Display version information\"\n}\n", - "--\n\n\npremake.csc = { }\n\n\n\nlocal flags =\n{\nFatalWarning = \"/warnaserror\",\nOptimize = \"/optimize\",\nOptimizeSize = \"/optimize\",\nOptimizeSpeed = \"/optimize\",\nSymbols = \"/debug\",\nUnsafe = \"/unsafe\"\n}\n\n\n\nfunction premake.csc.getbuildaction(fcfg)\nlocal ext = path.getextension(fcfg.name):lower()\nif fcfg.buildaction == \"Compile\" or ext == \".cs\" then\nreturn \"Compile\"\nelseif fcfg.buildaction == \"Embed\" or ext == \".resx\" then\nreturn \"EmbeddedResource\"\nelseif fcfg.buildaction == \"Copy\" or ext == \".asax\" or ext == \".aspx\" then\nreturn \"Content\"\nelse\nreturn \"None\"\nend\nend\n\n\n\n\nfunction premake.csc.getcompilervar(cfg)\nif (_OPTIONS.dotnet == \"ms\") then\nreturn \"csc\"\nelseif (_OPTIONS.dotnet == \"mono\") then\nreturn \"gmcs\"\nelse\nreturn \"cscc\"\nend\nend\n\n\n\n\nfunction premake.csc.getflags(cfg)\nlocal result = table.translate(cfg.flags, flags)\nreturn result\nend\n\n\n\n\nfunction premake.csc.getkind(cfg)\nif (cfg.kind == \"ConsoleApp\") then\nreturn \"Exe\"\nelseif (cfg.kind == \"WindowedApp\") then\nreturn \"WinExe\"\nelseif (cfg.kind == \"SharedLib\") then\nreturn \"Library\"\nend\nend", - "--\n\n\npremake.gcc = { }\npremake.targetstyle = \"linux\"\n\n\n\npremake.gcc.cc = \"gcc\"\npremake.gcc.cxx = \"g++\"\npremake.gcc.ar = \"ar\"\n\n\n\nlocal cflags =\n{\nExtraWarnings = \"-Wall\",\nFatalWarnings = \"-Werror\",\nNoFramePointer = \"-fomit-frame-pointer\",\nOptimize = \"-O2\",\nOptimizeSize = \"-Os\",\nOptimizeSpeed = \"-O3\",\nSymbols = \"-g\",\n}\n\nlocal cxxflags =\n{\nNoExceptions = \"-fno-exceptions\",\nNoRTTI = \"-fno-rtti\",\n}\n\n\n\npremake.gcc.platforms = \n{\nNative = { \ncppflags = \"-MMD\", \n},\nx32 = { \ncppflags = \"-MMD\",\nflags = \"-m32\",\nldflags = \"-L/usr/lib32\", \n},\nx64 = { \ncppflags = \"-MMD\",\nflags = \"-m64\",\nldflags = \"-L/usr/lib64\",\n},\nUniversal = { \ncppflags = \"\",\nflags = \"-arch i386 -arch x86_64 -arch ppc -arch ppc64\",\n},\nUniversal32 = { \ncppflags = \"\",\nflags = \"-arch i386 -arch ppc\",\n},\nUniversal64 = { \ncppflags = \"\",\nflags = \"-arch x86_64 -arch ppc64\",\n},\nPS3 = {\ncc = \"ppu-lv2-g++\",\ncxx = \"ppu-lv2-g++\",\nar = \"ppu-lv2-ar\",\ncppflags = \"-MMD\",\n}\n}\n\nlocal platforms = premake.gcc.platforms\n\n\n\nfunction premake.gcc.getcppflags(cfg)\nreturn platforms[cfg.platform].cppflags\nend\n\n\nfunction premake.gcc.getcflags(cfg)\nlocal result = table.translate(cfg.flags, cflags)\ntable.insert(result, platforms[cfg.platform].flags)\nif cfg.system == \"Windows\" and cfg.kind == \"SharedLib\" then\ntable.insert(result, \"-fPIC\")\nend\nreturn result\nend\n\n\nfunction premake.gcc.getcxxflags(cfg)\nlocal result = table.translate(cfg.flags, cxxflags)\nreturn result\nend\n\n\n\n\nfunction premake.gcc.getldflags(cfg)\nlocal result = { }\n\n-- OS X has a bug, see http://lists.apple.com/archives/Darwin-dev/2006/Sep/msg00084.html\nif not cfg.flags.Symbols then\nif cfg.system == \"MacOSX\" then\ntable.insert(result, \"-Wl,-x\")\nelse\ntable.insert(result, \"-s\")\nend\nend\n\nif cfg.kind == \"SharedLib\" then\nif cfg.system == \"MacOSX\" then\nresult = table.join(result, { \"-dynamiclib\", \"-flat_namespace\" })\nelse\ntable.insert(result, \"-shared\")\nend\n\nif cfg.system == \"Windows\" and not cfg.flags.NoImportLib then\ntable.insert(result, '-Wl,--out-implib=\"'..premake.gettarget(cfg, \"link\", \"linux\").fullpath..'\"')\nend\nend\n\nif cfg.kind == \"WindowedApp\" then\nif cfg.system == \"Windows\" then\ntable.insert(result, \"-mwindows\")\nend\nend\n\nlocal platform = platforms[cfg.platform]\ntable.insert(result, platform.flags)\ntable.insert(result, platform.ldflags)\nreturn result\nend\n\n\n\nfunction premake.gcc.getlinkflags(cfg)\nlocal result = { }\nfor _, value in ipairs(premake.getlinks(cfg, \"all\", \"directory\")) do\ntable.insert(result, '-L' .. _MAKE.esc(value))\nend\nfor _, value in ipairs(premake.getlinks(cfg, \"all\", \"basename\")) do\ntable.insert(result, '-l' .. _MAKE.esc(value))\nend\nreturn result\nend\n\n\n\n\nfunction premake.gcc.getdefines(defines)\nlocal result = { }\nfor _,def in ipairs(defines) do\ntable.insert(result, '-D' .. def)\nend\nreturn result\nend\n\n\n\n\nfunction premake.gcc.getincludedirs(includedirs)\nlocal result = { }\nfor _,dir in ipairs(includedirs) do\ntable.insert(result, \"-I\" .. _MAKE.esc(dir))\nend\nreturn result\nend\n", + "--\n\n\nlocal requiredactionfields =\n{\n\"description\",\n\"trigger\",\n}\n\nlocal requiredoptionfields = \n{\n\"description\",\n\"trigger\"\n}\n\n\n\nfunction newaction(a)\n-- some sanity checking\nlocal missing\nfor _, field in ipairs(requiredactionfields) do\nif (not a[field]) then\nmissing = field\nend\nend\n\nif (missing) then\nerror(\"action needs a \" .. missing, 2)\nend\n\n-- add it to the master list\npremake.actions[a.trigger] = a\nend\n\n\n\n\nfunction newoption(opt)\n-- some sanity checking\nlocal missing\nfor _, field in ipairs(requiredoptionfields) do\nif (not opt[field]) then\nmissing = field\nend\nend\n\nif (missing) then\nerror(\"action needs a \" .. missing, 2)\nend\n\n-- add it to the master list\npremake.options[opt.trigger] = opt\nend\n\n\n\n\nnewoption \n{\ntrigger = \"cc\",\nvalue = \"compiler\",\ndescription = \"Choose a C/C++ compiler set\",\nallowed = {\n{ \"gcc\", \"GNU GCC (gcc/g++)\" },\n{ \"ow\", \"OpenWatcom\" },\n}\n}\n\nnewoption\n{\ntrigger = \"dotnet\",\nvalue = \"value\",\ndescription = \"Choose a .NET compiler set\",\nallowed = {\n{ \"msnet\", \"Microsoft .NET (csc)\" },\n{ \"mono\", \"Novell Mono (mcs)\" },\n{ \"pnet\", \"Portable.NET (cscc)\" },\n}\n}\n\nnewoption\n{\ntrigger = \"file\",\nvalue = \"filename\",\ndescription = \"Process the specified Premake script file\"\n}\n\nnewoption\n{\ntrigger = \"help\",\ndescription = \"Display this information\"\n}\n\nnewoption\n{\ntrigger = \"os\",\nvalue = \"value\",\ndescription = \"Generate files for a different operating system\",\nallowed = {\n{ \"bsd\", \"OpenBSD, NetBSD, or FreeBSD\" },\n{ \"linux\", \"Linux\" },\n{ \"macosx\", \"Apple Mac OS X\" },\n{ \"windows\", \"Microsoft Windows\" },\n}\n}\n\nnewoption\n{\ntrigger = \"platform\",\nvalue = \"value\",\ndescription = \"Add target architecture (if supported by action)\",\nallowed = {\n{ \"x32\", \"32-bit\" },\n{ \"x64\", \"64-bit\" },\n{ \"universal\", \"Mac OS X Universal, 32- and 64-bit\" },\n{ \"universal32\", \"Mac OS X Universal, 32-bit only\" },\n{ \"universal64\", \"Mac OS X Universal, 64-bit only\" },\n{ \"ps3\", \"Playstation 3 (experimental)\" },\n{ \"xbox360\", \"Xbox 360 (experimental)\" },\n}\n}\n\nnewoption\n{\ntrigger = \"scripts\",\nvalue = \"path\",\ndescription = \"Search for additional scripts on the given path\"\n}\n\nnewoption\n{\ntrigger = \"version\",\ndescription = \"Display version information\"\n}\n", + "--\n\n\npremake.dotnet = { }\npremake.dotnet.targetstyle = \"windows\"\n\n\n\nlocal flags =\n{\nFatalWarning = \"/warnaserror\",\nOptimize = \"/optimize\",\nOptimizeSize = \"/optimize\",\nOptimizeSpeed = \"/optimize\",\nSymbols = \"/debug\",\nUnsafe = \"/unsafe\"\n}\n\n\n\nfunction premake.dotnet.getbuildaction(fcfg)\nlocal ext = path.getextension(fcfg.name):lower()\nif fcfg.buildaction == \"Compile\" or ext == \".cs\" then\nreturn \"Compile\"\nelseif fcfg.buildaction == \"Embed\" or ext == \".resx\" then\nreturn \"EmbeddedResource\"\nelseif fcfg.buildaction == \"Copy\" or ext == \".asax\" or ext == \".aspx\" then\nreturn \"Content\"\nelse\nreturn \"None\"\nend\nend\n\n\n\n\nfunction premake.dotnet.getcompilervar(cfg)\nif (_OPTIONS.dotnet == \"msnet\") then\nreturn \"csc\"\nelseif (_OPTIONS.dotnet == \"mono\") then\nreturn \"gmcs\"\nelse\nreturn \"cscc\"\nend\nend\n\n\n\n\nfunction premake.dotnet.getflags(cfg)\nlocal result = table.translate(cfg.flags, flags)\nreturn result\nend\n\n\n\n\nfunction premake.dotnet.getkind(cfg)\nif (cfg.kind == \"ConsoleApp\") then\nreturn \"Exe\"\nelseif (cfg.kind == \"WindowedApp\") then\nreturn \"WinExe\"\nelseif (cfg.kind == \"SharedLib\") then\nreturn \"Library\"\nend\nend", + "--\n\n\npremake.gcc = { }\npremake.gcc.targetstyle = \"linux\"\n\n\n\npremake.gcc.cc = \"gcc\"\npremake.gcc.cxx = \"g++\"\npremake.gcc.ar = \"ar\"\n\n\n\nlocal cflags =\n{\nExtraWarnings = \"-Wall\",\nFatalWarnings = \"-Werror\",\nNoFramePointer = \"-fomit-frame-pointer\",\nOptimize = \"-O2\",\nOptimizeSize = \"-Os\",\nOptimizeSpeed = \"-O3\",\nSymbols = \"-g\",\n}\n\nlocal cxxflags =\n{\nNoExceptions = \"-fno-exceptions\",\nNoRTTI = \"-fno-rtti\",\n}\n\n\n\npremake.gcc.platforms = \n{\nNative = { \ncppflags = \"-MMD\", \n},\nx32 = { \ncppflags = \"-MMD\",\nflags = \"-m32\",\nldflags = \"-L/usr/lib32\", \n},\nx64 = { \ncppflags = \"-MMD\",\nflags = \"-m64\",\nldflags = \"-L/usr/lib64\",\n},\nUniversal = { \ncppflags = \"\",\nflags = \"-arch i386 -arch x86_64 -arch ppc -arch ppc64\",\n},\nUniversal32 = { \ncppflags = \"\",\nflags = \"-arch i386 -arch ppc\",\n},\nUniversal64 = { \ncppflags = \"\",\nflags = \"-arch x86_64 -arch ppc64\",\n},\nPS3 = {\ncc = \"ppu-lv2-g++\",\ncxx = \"ppu-lv2-g++\",\nar = \"ppu-lv2-ar\",\ncppflags = \"-MMD\",\n}\n}\n\nlocal platforms = premake.gcc.platforms\n\n\n\nfunction premake.gcc.getcppflags(cfg)\nreturn platforms[cfg.platform].cppflags\nend\n\n\nfunction premake.gcc.getcflags(cfg)\nlocal result = table.translate(cfg.flags, cflags)\ntable.insert(result, platforms[cfg.platform].flags)\nif cfg.system == \"Windows\" and cfg.kind == \"SharedLib\" then\ntable.insert(result, \"-fPIC\")\nend\nreturn result\nend\n\n\nfunction premake.gcc.getcxxflags(cfg)\nlocal result = table.translate(cfg.flags, cxxflags)\nreturn result\nend\n\n\n\n\nfunction premake.gcc.getldflags(cfg)\nlocal result = { }\n\n-- OS X has a bug, see http://lists.apple.com/archives/Darwin-dev/2006/Sep/msg00084.html\nif not cfg.flags.Symbols then\nif cfg.system == \"MacOSX\" then\ntable.insert(result, \"-Wl,-x\")\nelse\ntable.insert(result, \"-s\")\nend\nend\n\nif cfg.kind == \"SharedLib\" then\nif cfg.system == \"MacOSX\" then\nresult = table.join(result, { \"-dynamiclib\", \"-flat_namespace\" })\nelse\ntable.insert(result, \"-shared\")\nend\n\nif cfg.system == \"Windows\" and not cfg.flags.NoImportLib then\ntable.insert(result, '-Wl,--out-implib=\"'..premake.gettarget(cfg, \"link\", \"linux\").fullpath..'\"')\nend\nend\n\nif cfg.kind == \"WindowedApp\" then\nif cfg.system == \"Windows\" then\ntable.insert(result, \"-mwindows\")\nend\nend\n\nlocal platform = platforms[cfg.platform]\ntable.insert(result, platform.flags)\ntable.insert(result, platform.ldflags)\nreturn result\nend\n\n\n\nfunction premake.gcc.getlinkflags(cfg)\nlocal result = { }\nfor _, value in ipairs(premake.getlinks(cfg, \"all\", \"directory\")) do\ntable.insert(result, '-L' .. _MAKE.esc(value))\nend\nfor _, value in ipairs(premake.getlinks(cfg, \"all\", \"basename\")) do\ntable.insert(result, '-l' .. _MAKE.esc(value))\nend\nreturn result\nend\n\n\n\n\nfunction premake.gcc.getdefines(defines)\nlocal result = { }\nfor _,def in ipairs(defines) do\ntable.insert(result, '-D' .. def)\nend\nreturn result\nend\n\n\n\n\nfunction premake.gcc.getincludedirs(includedirs)\nlocal result = { }\nfor _,dir in ipairs(includedirs) do\ntable.insert(result, \"-I\" .. _MAKE.esc(dir))\nend\nreturn result\nend\n", + "--\n\n\npremake.msc = { }\npremake.msc.targetstyle = \"windows\"\n", "--\n\npremake.ow = { }\npremake.ow.targetstyle = \"windows\"\n\n\n\npremake.ow.cc = \"WCL386\"\npremake.ow.cxx = \"WCL386\"\npremake.ow.ar = \"ar\"\n\n\n\nlocal cflags =\n{\nExtraWarnings = \"-wx\",\nFatalWarning = \"-we\",\nOptimize = \"-ox\",\nOptimizeSize = \"-os\",\nOptimizeSpeed = \"-ot\",\nSymbols = \"-d2\",\n}\n\nlocal cxxflags =\n{\nNoExceptions = \"-xd\",\nNoRTTI = \"-xr\",\n}\n\n\n\n\npremake.ow.platforms = \n{\nNative = { \nflags = \"\" \n},\n}\n\n\n\n\nfunction premake.ow.getcppflags(cfg)\nreturn \"\"\nend\n\nfunction premake.ow.getcflags(cfg)\nlocal result = table.translate(cfg.flags, cflags)\nif (cfg.flags.Symbols) then\ntable.insert(result, \"-hw\") -- Watcom debug format for Watcom debugger\nend\nreturn result\nend\n\nfunction premake.ow.getcxxflags(cfg)\nlocal result = table.translate(cfg.flags, cxxflags)\nreturn result\nend\n\n\n\n\nfunction premake.ow.getldflags(cfg)\nlocal result = { }\n\nif (cfg.flags.Symbols) then\ntable.insert(result, \"op symf\")\nend\n\nreturn result\nend\n\n\n\nfunction premake.ow.getlinkflags(cfg)\nlocal result = { }\nreturn result\nend\n\n\n\n\nfunction premake.ow.getdefines(defines)\nlocal result = { }\nfor _,def in ipairs(defines) do\ntable.insert(result, '-D' .. def)\nend\nreturn result\nend\n\n\n\n\nfunction premake.ow.getincludedirs(includedirs)\nlocal result = { }\nfor _,dir in ipairs(includedirs) do\ntable.insert(result, '-I \"' .. dir .. '\"')\nend\nreturn result\nend\n\n", "--\n\n\n\nfunction premake.checkoptions()\nfor key, value in pairs(_OPTIONS) do\n-- is this a valid option?\nlocal opt = premake.options[key]\nif (not opt) then\nreturn false, \"invalid option '\" .. key .. \"'\"\nend\n\n-- does it need a value?\nif (opt.value and value == \"\") then\nreturn false, \"no value specified for option '\" .. key .. \"'\"\nend\n\n-- is the value allowed?\nif (opt.allowed) then\nfor _, match in ipairs(opt.allowed) do\nif (match[1] == value) then return true end\nend\nreturn false, \"invalid value '\" .. value .. \"' for option '\" .. key .. \"'\"\nend\nend\nreturn true\nend\n\n\n\n\nfunction premake.checkprojects()\nlocal action = premake.actions[_ACTION]\n\nfor _, sln in ipairs(_SOLUTIONS) do\n\n-- every solution must have at least one project\nif (#sln.projects == 0) then\nreturn nil, \"solution '\" .. sln.name .. \"' needs at least one project\"\nend\n\n-- every solution must provide a list of configurations\nif (#sln.configurations == 0) then\nreturn nil, \"solution '\" .. sln.name .. \"' needs configurations\"\nend\n\nfor prj in premake.eachproject(sln) do\n\n-- every project must have a language\nif (not prj.language) then\nreturn nil, \"project '\" ..prj.name .. \"' needs a language\"\nend\n\n-- and the action must support it\nif (action.valid_languages) then\nif (not table.contains(action.valid_languages, prj.language)) then\nreturn nil, \"the \" .. action.shortname .. \" action does not support \" .. prj.language .. \" projects\"\nend\nend\n\nfor cfg in premake.eachconfig(prj) do\n\n-- every config must have a kind\nif (not cfg.kind) then\nreturn nil, \"project '\" ..prj.name .. \"' needs a kind in configuration '\" .. cfgname .. \"'\"\nend\n\n-- and the action must support it\nif (action.valid_kinds) then\nif (not table.contains(action.valid_kinds, cfg.kind)) then\nreturn nil, \"the \" .. action.shortname .. \" action does not support \" .. cfg.kind .. \" projects\"\nend\nend\n\nend\nend\nend\nreturn true\nend\n\n\n\nfunction premake.checktools()\nlocal action = premake.actions[_ACTION]\nif (not action.valid_tools) then \nreturn true \nend\n\nfor tool, values in pairs(action.valid_tools) do\nif (_OPTIONS[tool]) then\nif (not table.contains(values, _OPTIONS[tool])) then\nreturn nil, \"the \" .. action.shortname .. \" action does not support /\" .. tool .. \"=\" .. _OPTIONS[tool] .. \" (yet)\"\nend\nelse\n_OPTIONS[tool] = values[1]\nend\nend\n\nreturn true\nend\n", "--\n\n\nfunction premake.showhelp()\n\n-- sort the lists of actions and options into alphabetical order\nactions = { }\nfor name,_ in pairs(premake.actions) do table.insert(actions, name) end\ntable.sort(actions)\n\noptions = { }\nfor name,_ in pairs(premake.options) do table.insert(options, name) end\ntable.sort(options)\n\n\n-- display the basic usage\nprintf(\"Premake %s, a build script generator\", _PREMAKE_VERSION)\nprintf(_PREMAKE_COPYRIGHT)\nprintf(\"%s %s\", _VERSION, _COPYRIGHT)\nprintf(\"\")\nprintf(\"Usage: premake4 [options] action [arguments]\")\nprintf(\"\")\n\n\n-- display all options\nprintf(\"OPTIONS\")\nprintf(\"\")\nfor _,name in ipairs(options) do\nlocal opt = premake.options[name]\nlocal trigger = opt.trigger\nlocal description = opt.description\n\nif (opt.value) then trigger = trigger .. \"=\" .. opt.value end\nif (opt.allowed) then description = description .. \"; one of:\" end\n\nprintf(\" --%-15s %s\", trigger, description) \nif (opt.allowed) then\nfor _, value in ipairs(opt.allowed) do\nprintf(\" %-14s %s\", value[1], value[2])\nend\nend\nprintf(\"\")\nend\n\n-- display all actions\nprintf(\"ACTIONS\")\nprintf(\"\")\nfor _,name in ipairs(actions) do\nprintf(\" %-17s %s\", name, premake.actions[name].description)\nend\nprintf(\"\")\n\n\n-- see more\nprintf(\"For additional information, see http://industriousone.com/premake\")\n\nend\n\n\n", @@ -23,20 +24,20 @@ const char* builtin_scripts[] = { "--\n\nfunction premake.codelite_project(prj)\n_p('')\n_p('', premake.esc(prj.name))\n\npremake.walksources(prj, prj.files, premake.codelite_files)\n\nlocal types = { \nConsoleApp = \"Executable\", \nWindowedApp = \"Executable\", \nStaticLib = \"Static Library\",\nSharedLib = \"Dynamic Library\",\n}\n_p(' ', types[prj.kind])\n\n-- build a list of supported target platforms; I don't support cross-compiling yet\nlocal platforms = premake.filterplatforms(prj.solution, premake[_OPTIONS.cc].platforms, \"Native\")\nfor i = #platforms, 1, -1 do\nif premake.platforms[platforms[i]].iscrosscompiler then\ntable.remove(platforms, i)\nend\nend \n\nfor _, platform in ipairs(platforms) do\nfor cfg in premake.eachconfig(prj, platform) do\nlocal name = premake.esc(cfg.longname)\nlocal compiler = iif(cfg.language == \"C\", \"gcc\", \"g++\")\n_p(' ', name, compiler, types[cfg.kind])\n\nlocal fname = premake.esc(cfg.buildtarget.fullpath)\nlocal objdir = premake.esc(cfg.objectsdir)\nlocal runcmd = cfg.buildtarget.name\nlocal rundir = cfg.buildtarget.directory\nlocal pause = iif(cfg.kind == \"WindowedApp\", \"no\", \"yes\")\n_p(' ', fname, objdir, runcmd, rundir, pause)\n\n-- begin compiler block --\nlocal flags = premake.esc(table.join(premake.gcc.getcflags(cfg), premake.gcc.getcxxflags(cfg), cfg.buildoptions))\n_p(' ', table.concat(flags, \";\"))\nfor _,v in ipairs(cfg.includedirs) do\n_p(' ', premake.esc(v))\nend\nfor _,v in ipairs(cfg.defines) do\n_p(' ', premake.esc(v))\nend\n_p(' ')\n-- end compiler block --\n\n-- begin linker block --\nflags = premake.esc(table.join(premake.gcc.getldflags(cfg), cfg.linkoptions))\n_p(' ', table.concat(flags, \";\"))\nfor _,v in ipairs(premake.getlinks(cfg, \"all\", \"directory\")) do\n_p(' ', premake.esc(v))\nend\nfor _,v in ipairs(premake.getlinks(cfg, \"all\", \"basename\")) do\n_p(' ', premake.esc(v))\nend\n_p(' ')\n-- end linker block --\n\n-- begin resource compiler block --\nif premake.findfile(cfg, \".rc\") then\nlocal defines = table.implode(table.join(cfg.defines, cfg.resdefines), \"-D\", \";\", \"\")\nlocal options = table.concat(cfg.resoptions, \";\")\n_p(' ', defines, options)\nfor _,v in ipairs(table.join(cfg.includedirs, cfg.resincludedirs)) do\n_p(' ', premake.esc(v))\nend\n_p(' ')\nelse\n_p(' ')\nend\n-- end resource compiler block --\n\n-- begin build steps --\nif #cfg.prebuildcommands > 0 then\n_p(' ')\nfor _,v in ipairs(cfg.prebuildcommands) do\n_p(' %s', premake.esc(v))\nend\n_p(' ')\nend\nif #cfg.postbuildcommands > 0 then\n_p(' ')\nfor _,v in ipairs(cfg.postbuildcommands) do\n_p(' %s', premake.esc(v))\nend\n_p(' ')\nend\n-- end build steps --\n\n_p(' ')\n_p(' ')\n_p(' ')\n_p(' ')\n_p(' ')\n_p(' None')\n_p(' ')\n_p(' ')\n_p(' ')\n_p(' ')\n_p(' ')\n_p(' ')\n_p(' ')\nend\nend\n_p(' ')\n\nfor _, platform in ipairs(platforms) do\nfor cfg in premake.eachconfig(prj, platform) do\n_p(' ', cfg.longname)\nfor _,dep in ipairs(premake.getdependencies(prj)) do\n_p(' ', dep.name)\nend\n_p(' ')\nend\nend\n\n_p('')\nend\n\n\n\n\nfunction premake.codelite_files(prj, fname, state, nestlevel)\nlocal indent = string.rep(\" \", nestlevel + 1)\n\nif (state == \"GroupStart\") then\nio.write(indent .. '\\n')\nelseif (state == \"GroupEnd\") then\nio.write(indent .. '\\n')\nelse\nio.write(indent .. '\\n')\nend\nend\n\n\n\n", "--\n\nfunction premake.make_solution(sln)\n-- create a shortcut to the compiler interface\nlocal cc = premake[_OPTIONS.cc]\n\n-- build a list of supported target platforms that also includes a generic build\nlocal platforms = premake.filterplatforms(sln, cc.platforms, \"Native\")\n\n-- write a header showing the build options\nlocal cfgpairs = { }\nfor _, platform in ipairs(platforms) do\nfor _, cfgname in ipairs(sln.configurations) do\ntable.insert(cfgpairs, premake.getconfigname(cfgname, platform, true))\nend\nend\n_p('# %s solution makefile autogenerated by Premake', premake.actions[_ACTION].shortname)\n_p('# Usage: make [ config=config_name ]')\n_p('# Where {config_name} is one of: %s.', table.implode(cfgpairs, '\"', '\"', ', '))\n_p('')\n\n-- set a default configuration\n_p('ifndef config')\n_p(' config=%s', _MAKE.esc(premake.getconfigname(sln.configurations[1], platforms[1], true)))\n_p('endif')\n_p('export config')\n_p('')\n\n-- list the projects included in the solution\n_p('PROJECTS := %s', table.concat(_MAKE.esc(table.extract(sln.projects, \"name\")), \" \"))\n_p('')\n_p('.PHONY: all clean $(PROJECTS)')\n_p('')\n_p('all: $(PROJECTS)')\n_p('')\n\n-- write the project build rules\nfor _, prj in ipairs(sln.projects) do\n\n-- before each project rule, build a list of dependencies for the project. If any of\n-- these dependencies change, the project needs to be rebuilt\nfor _, platform in ipairs(platforms) do\nfor cfg in premake.eachconfig(prj, platform) do\n_p('ifeq ($(config),%s)', _MAKE.esc(cfg.shortname))\n_p(' DEPENDENCIES := %s', table.concat(_MAKE.esc(table.extract(premake.getdependencies(cfg), \"name\")), \" \"))\n_p('endif')\nend\nend\n_p('')\n\n_p('%s: ${DEPENDENCIES}', _MAKE.esc(prj.name))\n_p('\\t@echo ==== Building %s ====', prj.name)\n_p('\\t@${MAKE} --no-print-directory -C %s -f %s', _MAKE.esc(path.getrelative(sln.location, prj.location)), _MAKE.esc(_MAKE.getmakefilename(prj, true)))\n_p('')\nend\n\n-- clean rules\n_p('clean:')\nfor _ ,prj in ipairs(sln.projects) do\n_p('\\t@${MAKE} --no-print-directory -C %s -f %s clean', _MAKE.esc(path.getrelative(sln.location, prj.location)), _MAKE.esc(_MAKE.getmakefilename(prj, true)))\nend\n_p('')\n\nend\n", "--\n\nfunction premake.make_cpp(prj)\n-- create a shortcut to the compiler interface\nlocal cc = premake[_OPTIONS.cc]\n\n-- build a list of supported target platforms that also includes a generic build\nlocal platforms = premake.filterplatforms(prj.solution, cc.platforms, \"Native\")\n\npremake.gmake_cpp_header(prj, cc, platforms)\n\nfor _, platform in ipairs(platforms) do\nfor cfg in premake.eachconfig(prj, platform) do\npremake.gmake_cpp_config(cfg, cc)\nend\nend\n\n-- list intermediate files\n_p('OBJECTS := \\\\')\nfor _, file in ipairs(prj.files) do\nif path.iscppfile(file) then\n_p('\\t$(OBJDIR)/%s.o \\\\', _MAKE.esc(path.getbasename(file)))\nend\nend\n_p('')\n \n_p('RESOURCES := \\\\')\nfor _, file in ipairs(prj.files) do\nif path.isresourcefile(file) then\n_p('\\t$(OBJDIR)/%s.res \\\\', _MAKE.esc(path.getbasename(file)))\nend\nend\n_p('')\n \n-- set up support commands like mkdir, rmdir, etc. based on the shell\n_p('SHELLTYPE := msdos')\n_p('ifeq (,$(ComSpec)$(COMSPEC))')\n_p(' SHELLTYPE := posix')\n_p('endif')\n_p('ifeq (/bin,$(findstring /bin,$(SHELL)))')\n_p(' SHELLTYPE := posix')\n_p('endif')\n_p('ifeq (posix,$(SHELLTYPE))')\n_p(' define MKDIR_RULE')\n_p('\\t@echo Creating $@')\n_p('\\t$(SILENT) mkdir -p $@')\n_p(' endef')\n_p('else')\n_p(' define MKDIR_RULE')\n_p('\\t@echo Creating $@')\n_p('\\t$(SILENT) mkdir $(subst /,\\\\\\\\,$@)')\n_p(' endef')\n_p('endif')\n_p('')\n\n-- main build rule(s)\n_p('.PHONY: clean prebuild prelink')\n_p('')\n\nif os.is(\"MacOSX\") and prj.kind == \"WindowedApp\" then\n_p('all: $(TARGETDIR) $(OBJDIR) prebuild $(OBJECTS) $(RESOURCES) prelink $(TARGET) $(dir $(TARGETDIR))PkgInfo $(dir $(TARGETDIR))Info.plist')\nelse\n_p('all: $(TARGETDIR) $(OBJDIR) prebuild $(OBJECTS) $(RESOURCES) prelink $(TARGET)')\nend\n_p('')\n\n_p('$(TARGET): $(OBJECTS) $(LDDEPS) $(RESOURCES)')\n_p('\\t@echo Linking %s', prj.name)\n_p('\\t@$(LINKCMD)')\n_p('\\t$(POSTBUILDCMDS)')\n_p('')\n\n-- create destination directories\n_p('$(TARGETDIR):')\n_p('\\t$(MKDIR_RULE)')\n_p('')\n\n_p('$(OBJDIR):')\n_p('\\t$(MKDIR_RULE)')\n_p('')\n\n-- Mac OS X specific targets\nif os.is(\"MacOSX\") and prj.kind == \"WindowedApp\" then\n_p('$(dir $(TARGETDIR))PkgInfo:')\n_p('$(dir $(TARGETDIR))Info.plist:')\n_p('')\nend\n\n-- clean target\n_p('clean:')\n_p('\\t@echo Cleaning %s', prj.name)\n_p('ifeq (posix,$(SHELLTYPE))')\n_p('\\t$(SILENT) rm -f $(TARGET)')\n_p('\\t$(SILENT) rm -rf $(OBJDIR)')\n_p('else')\n_p('\\t$(SILENT) if exist $(subst /,\\\\\\\\,$(TARGET)) del $(subst /,\\\\\\\\,$(TARGET))')\n_p('\\t$(SILENT) if exist $(subst /,\\\\\\\\,$(OBJDIR)) rmdir /s /q $(subst /,\\\\\\\\,$(OBJDIR))')\n_p('endif')\n_p('')\n\n-- custom build step targets\n_p('prebuild:')\n_p('\\t$(PREBUILDCMDS)')\n_p('')\n\n_p('prelink:')\n_p('\\t$(PRELINKCMDS)')\n_p('')\n\n-- per-file rules\nfor _, file in ipairs(prj.files) do\nif path.iscppfile(file) then\n_p('$(OBJDIR)/%s.o: %s', _MAKE.esc(path.getbasename(file)), _MAKE.esc(file))\n_p('\\t@echo $(notdir $<)')\nif (path.iscfile(file)) then\n_p('\\t$(SILENT) $(CC) $(CFLAGS) -o $@ -c $<')\nelse\n_p('\\t$(SILENT) $(CXX) $(CXXFLAGS) -o $@ -c $<')\nend\nelseif (path.getextension(file) == \".rc\") then\n_p('$(OBJDIR)/%s.res: %s', _MAKE.esc(path.getbasename(file)), _MAKE.esc(file))\n_p('\\t@echo $(notdir $<)')\n_p('\\t$(SILENT) windres $< -O coff -o $@ $(RESFLAGS)')\nend\nend\n_p('')\n\n-- include the dependencies, built by GCC (with the -MMD flag)\n_p('-include $(OBJECTS:%%.o=%%.d)')\nend\n\n\n\n\nfunction premake.gmake_cpp_header(prj, cc, platforms)\n_p('# %s project makefile autogenerated by Premake', premake.actions[_ACTION].shortname)\n\n-- set up the environment\n_p('ifndef config')\n_p(' config=%s', _MAKE.esc(premake.getconfigname(prj.solution.configurations[1], platforms[1], true)))\n_p('endif')\n_p('')\n\n_p('ifndef verbose')\n_p(' SILENT = @')\n_p('endif')\n_p('')\n\n_p('ifndef CC')\n_p(' CC = %s', cc.cc)\n_p('endif')\n_p('')\n\n_p('ifndef CXX')\n_p(' CXX = %s', cc.cxx)\n_p('endif')\n_p('')\n\n_p('ifndef AR')\n_p(' AR = %s', cc.ar)\n_p('endif')\n_p('')\nend\n\n\n\nfunction premake.gmake_cpp_config(cfg, cc)\n\n_p('ifeq ($(config),%s)', _MAKE.esc(cfg.shortname))\n\n-- if this platform requires a special compiler or linker, list it now\nlocal platform = cc.platforms[cfg.platform]\nif platform.cc then\n_p(' CC = %s', platform.cc)\nend\nif platform.cxx then\n_p(' CXX = %s', platform.cxx)\nend\nif platform.ar then\n_p(' AR = %s', platform.ar)\nend\n\n_p(' TARGETDIR = %s', _MAKE.esc(cfg.buildtarget.directory))\n_p(' TARGET = $(TARGETDIR)/%s', _MAKE.esc(cfg.buildtarget.name))\n_p(' OBJDIR = %s', _MAKE.esc(cfg.objectsdir))\n_p(' DEFINES += %s', table.concat(cc.getdefines(cfg.defines), \" \"))\n_p(' INCLUDES += %s', table.concat(cc.getincludedirs(cfg.includedirs), \" \"))\n_p(' CPPFLAGS += %s $(DEFINES) $(INCLUDES)', cc.getcppflags(cfg))\n_p(' CFLAGS += $(CPPFLAGS) $(ARCH) %s', table.concat(table.join(cc.getcflags(cfg), cfg.buildoptions), \" \"))\n_p(' CXXFLAGS += $(CFLAGS) %s', table.concat(cc.getcxxflags(cfg), \" \"))\n_p(' LDFLAGS += %s', table.concat(table.join(cc.getldflags(cfg), cc.getlinkflags(cfg), cfg.linkoptions), \" \"))\n_p(' RESFLAGS += $(DEFINES) $(INCLUDES) %s', table.concat(table.join(cc.getdefines(cfg.resdefines), cc.getincludedirs(cfg.resincludedirs), cfg.resoptions), \" \"))\n_p(' LDDEPS += %s', table.concat(_MAKE.esc(premake.getlinks(cfg, \"siblings\", \"fullpath\")), \" \"))\n\nif cfg.kind == \"StaticLib\" then\n_p(' LINKCMD = $(AR) -rcs $(TARGET) $(OBJECTS)')\nelse\n_p(' LINKCMD = $(%s) -o $(TARGET) $(OBJECTS) $(LDFLAGS) $(RESOURCES) $(ARCH)', iif(cfg.language == \"C\", \"CC\", \"CXX\"))\nend\n\n_p(' define PREBUILDCMDS')\nif #cfg.prebuildcommands > 0 then\n_p('\\t@echo Running pre-build commands')\n_p('\\t%s', table.implode(cfg.prebuildcommands, \"\", \"\", \"\\n\\t\"))\nend\n_p(' endef')\n\n_p(' define PRELINKCMDS')\nif #cfg.prelinkcommands > 0 then\n_p('\\t@echo Running pre-link commands')\n_p('\\t%s', table.implode(cfg.prelinkcommands, \"\", \"\", \"\\n\\t\"))\nend\n_p(' endef')\n\n_p(' define POSTBUILDCMDS')\nif #cfg.postbuildcommands > 0 then\n_p('\\t@echo Running post-build commands')\n_p('\\t%s', table.implode(cfg.postbuildcommands, \"\", \"\", \"\\n\\t\"))\nend\n_p(' endef')\n\n_p('endif')\n_p('')\nend\n", - "--\n\n\nlocal function getresourcefilename(cfg, fname)\nif path.getextension(fname) == \".resx\" then\n local name = cfg.buildtarget.basename .. \".\"\n local dir = path.getdirectory(fname)\n if dir ~= \".\" then \nname = name .. path.translate(dir, \".\") .. \".\"\nend\nreturn \"$(OBJDIR)/\" .. name .. path.getbasename(fname) .. \".resources\"\nelse\nreturn fname\nend\nend\n\n\n\nfunction premake.make_csharp(prj)\nlocal csc = premake.csc\n\n-- Do some processing up front: build a list of configuration-dependent libraries.\n-- Libraries that are built to a location other than $(TARGETDIR) will need to\n-- be copied so they can be found at runtime.\nlocal cfglibs = { }\nlocal cfgpairs = { }\nlocal anycfg\nfor cfg in premake.eachconfig(prj) do\nanycfg = cfg\ncfglibs[cfg] = premake.getlinks(cfg, \"siblings\", \"fullpath\")\ncfgpairs[cfg] = { }\nfor _, fname in ipairs(cfglibs[cfg]) do\nif path.getdirectory(fname) ~= cfg.buildtarget.directory then\ncfgpairs[cfg][\"$(TARGETDIR)/\"..path.getname(fname)] = fname\nend\nend\nend\n\n-- sort the files into categories, based on their build action\nlocal sources = {}\nlocal embedded = { }\nlocal copypairs = { }\n\nfor fcfg in premake.eachfile(prj) do\nlocal action = csc.getbuildaction(fcfg)\nif action == \"Compile\" then\ntable.insert(sources, fcfg.name)\nelseif action == \"EmbeddedResource\" then\ntable.insert(embedded, fcfg.name)\nelseif action == \"Content\" then\ncopypairs[\"$(TARGETDIR)/\"..path.getname(fcfg.name)] = fcfg.name\nelseif path.getname(fcfg.name):lower() == \"app.config\" then\ncopypairs[\"$(TARGET).config\"] = fcfg.name\nend\nend\n\n-- Any assemblies that are on the library search paths should be copied\n-- to $(TARGETDIR) so they can be found at runtime\nlocal paths = table.translate(prj.libdirs, function(v) return path.join(prj.basedir, v) end)\npaths = table.join({prj.basedir}, paths)\nfor _, libname in ipairs(premake.getlinks(prj, \"system\", \"fullpath\")) do\nlocal libdir = os.pathsearch(libname..\".dll\", unpack(paths))\nif (libdir) then\nlocal target = \"$(TARGETDIR)/\"..path.getname(libname)\nlocal source = path.getrelative(prj.basedir, path.join(libdir, libname))..\".dll\"\ncopypairs[target] = source\nend\nend\n\n-- end of preprocessing --\n\n\n-- set up the environment\n_p('# %s project makefile autogenerated by Premake', premake.actions[_ACTION].shortname)\n_p('')\n\n_p('ifndef config')\n_p(' config=%s', _MAKE.esc(prj.configurations[1]:lower()))\n_p('endif')\n_p('')\n\n_p('ifndef verbose')\n_p(' SILENT = @')\n_p('endif')\n_p('')\n\n_p('ifndef CSC')\n_p(' CSC=%s', csc.getcompilervar(prj))\n_p('endif')\n_p('')\n\n_p('ifndef RESGEN')\n_p(' RESGEN=resgen')\n_p('endif')\n_p('')\n\n-- Platforms aren't support for .NET projects, but I need the ability to match\n-- the buildcfg:platform identifiers with a block of settings. So enumerate the\n-- pairs the same way I do for C/C++ projects, but always use the generic settings\nlocal platforms = premake.filterplatforms(prj.solution, premake[_OPTIONS.cc].platforms)\ntable.insert(platforms, 1, \"\")\n\n-- write the configuration blocks\nfor cfg in premake.eachconfig(prj) do\n_p('ifneq (,$(findstring %s,$(config)))', _MAKE.esc(cfg.name:lower()))\n_p(' TARGETDIR := %s', _MAKE.esc(cfg.buildtarget.directory))\n_p(' OBJDIR := %s', _MAKE.esc(cfg.objectsdir))\n_p(' DEPENDS := %s', table.concat(_MAKE.esc(premake.getlinks(cfg, \"dependencies\", \"fullpath\")), \" \"))\n_p(' REFERENCES := %s', table.implode(_MAKE.esc(cfglibs[cfg]), \"/r:\", \"\", \" \"))\n_p(' FLAGS += %s %s', table.concat(csc.getflags(cfg), \" \"), table.implode(cfg.defines, \"/d:\", \"\", \" \"))\n\n_p(' define PREBUILDCMDS')\nif #cfg.prebuildcommands > 0 then\n_p('\\t@echo Running pre-build commands')\n_p('\\t%s', table.implode(cfg.prebuildcommands, \"\", \"\", \"\\n\\t\"))\nend\n_p(' endef')\n\n_p(' define PRELINKCMDS')\nif #cfg.prelinkcommands > 0 then\n_p('\\t@echo Running pre-link commands')\n_p('\\t%s', table.implode(cfg.prelinkcommands, \"\", \"\", \"\\n\\t\"))\nend\n_p(' endef')\n\n_p(' define POSTBUILDCMDS')\nif #cfg.postbuildcommands > 0 then\n_p('\\t@echo Running post-build commands')\n_p('\\t%s', table.implode(cfg.postbuildcommands, \"\", \"\", \"\\n\\t\"))\nend\n_p(' endef')\n\n_p('endif')\n_p('')\nend\n\n-- set project level values\n_p('# To maintain compatibility with VS.NET, these values must be set at the project level')\n_p('TARGET := $(TARGETDIR)/%s', _MAKE.esc(prj.buildtarget.name))\n_p('FLAGS += /t:%s %s', csc.getkind(prj):lower(), table.implode(_MAKE.esc(prj.libdirs), \"/lib:\", \"\", \" \"))\n_p('REFERENCES += %s', table.implode(_MAKE.esc(premake.getlinks(prj, \"system\", \"basename\")), \"/r:\", \".dll\", \" \"))\n_p('')\n\n-- list source files\n_p('SOURCES := \\\\')\nfor _, fname in ipairs(sources) do\n_p('\\t%s \\\\', _MAKE.esc(path.translate(fname)))\nend\n_p('')\n\n_p('EMBEDFILES := \\\\')\nfor _, fname in ipairs(embedded) do\n_p('\\t%s \\\\', _MAKE.esc(getresourcefilename(prj, fname)))\nend\n_p('')\n\n_p('COPYFILES += \\\\')\nfor target, source in pairs(cfgpairs[anycfg]) do\n_p('\\t%s \\\\', _MAKE.esc(target))\nend\nfor target, source in pairs(copypairs) do\n_p('\\t%s \\\\', _MAKE.esc(target))\nend\n_p('')\n\n-- set up support commands like mkdir, rmdir, etc. based on the shell\n_p('SHELLTYPE := msdos')\n_p('ifeq (,$(ComSpec)$(COMSPEC))')\n_p(' SHELLTYPE := posix')\n_p('endif')\n_p('ifeq (/bin,$(findstring /bin,$(SHELL)))')\n_p(' SHELLTYPE := posix')\n_p('endif')\n_p('ifeq (posix,$(SHELLTYPE))')\n_p(' define MKDIR_RULE')\n_p('\\t@echo Creating $@')\n_p('\\t$(SILENT) mkdir -p $@')\n_p(' endef')\n_p(' define COPY_RULE')\n_p('\\t@echo Copying $(notdir $@)')\n_p('\\t$(SILENT) cp -fR $^ $@')\n_p(' endef')\n_p('else')\n_p(' define MKDIR_RULE')\n_p('\\t@echo Creating $@')\n_p('\\t$(SILENT) mkdir $(subst /,\\\\\\\\,$@)')\n_p(' endef')\n_p(' define COPY_RULE')\n_p('\\t@echo Copying $(notdir $@)')\n_p('\\t$(SILENT) copy /Y $(subst /,\\\\\\\\,$^) $(subst /,\\\\\\\\,$@)')\n_p(' endef')\n_p('endif')\n\n-- main build rule(s)\n_p('.PHONY: clean prebuild prelink')\n_p('')\n\n_p('all: $(TARGETDIR) $(OBJDIR) prebuild $(EMBEDFILES) $(COPYFILES) prelink $(TARGET)')\n_p('')\n\n_p('$(TARGET): $(SOURCES) $(EMBEDFILES) $(DEPENDS)')\n_p('\\t$(SILENT) $(CSC) /nologo /out:$@ $(FLAGS) $(REFERENCES) $(SOURCES) $(patsubst %%,/resource:%%,$(EMBEDFILES))')\n_p('\\t$(POSTBUILDCMDS)')\n_p('')\n\n-- create destination directories\n_p('$(TARGETDIR):')\n_p('\\t$(MKDIR_RULE)')\n_p('')\n\n_p('$(OBJDIR):')\n_p('\\t$(MKDIR_RULE)')\n_p('')\n\n-- clean target\n_p('clean:')\n_p('\\t@echo Cleaning %s', prj.name)\n_p('ifeq (posix,$(SHELLTYPE))')\n_p('\\t$(SILENT) rm -f $(TARGETDIR)/%s.* $(COPYFILES)', prj.buildtarget.basename)\n_p('\\t$(SILENT) rm -rf $(OBJDIR)')\n_p('else')\n_p('\\t$(SILENT) if exist $(subst /,\\\\\\\\,$(TARGETDIR)/%s.*) del $(subst /,\\\\\\\\,$(TARGETDIR)/%s.*)', prj.buildtarget.basename, prj.buildtarget.basename)\nfor target, source in pairs(cfgpairs[anycfg]) do\n_p('\\t$(SILENT) if exist $(subst /,\\\\\\\\,%s) del $(subst /,\\\\\\\\,%s)', target, target)\nend\nfor target, source in pairs(copypairs) do\n_p('\\t$(SILENT) if exist $(subst /,\\\\\\\\,%s) del $(subst /,\\\\\\\\,%s)', target, target)\nend\n_p('\\t$(SILENT) if exist $(subst /,\\\\\\\\,$(OBJDIR)) rmdir /s /q $(subst /,\\\\\\\\,$(OBJDIR))')\n_p('endif')\n_p('')\n\n-- custom build step targets\n_p('prebuild:')\n_p('\\t$(PREBUILDCMDS)')\n_p('')\n\n_p('prelink:')\n_p('\\t$(PRELINKCMDS)')\n_p('')\n\n-- per-file rules\n_p('# Per-configuration copied file rules')\nfor cfg in premake.eachconfig(prj) do\n_p('ifneq (,$(findstring %s,$(config)))', _MAKE.esc(cfg.name:lower()))\nfor target, source in pairs(cfgpairs[cfg]) do\n_p('%s: %s', _MAKE.esc(target), _MAKE.esc(source))\n_p('\\t$(COPY_RULE)')\nend\n_p('endif')\nend\n_p('')\n\n_p('# Copied file rules')\nfor target, source in pairs(copypairs) do\n_p('%s: %s', _MAKE.esc(target), _MAKE.esc(source))\n_p('\\t$(COPY_RULE)')\n_p('')\nend\n\n_p('# Embedded file rules')\nfor _, fname in ipairs(embedded) do \nif path.getextension(fname) == \".resx\" then\n_p('%s: %s', _MAKE.esc(getresourcefilename(prj, fname)), _MAKE.esc(fname))\n_p('\\t$(SILENT) $(RESGEN) $^ $@')\nend\n_p('')\nend\n\nend\n", + "--\n\n\nlocal function getresourcefilename(cfg, fname)\nif path.getextension(fname) == \".resx\" then\n local name = cfg.buildtarget.basename .. \".\"\n local dir = path.getdirectory(fname)\n if dir ~= \".\" then \nname = name .. path.translate(dir, \".\") .. \".\"\nend\nreturn \"$(OBJDIR)/\" .. name .. path.getbasename(fname) .. \".resources\"\nelse\nreturn fname\nend\nend\n\n\n\nfunction premake.make_csharp(prj)\nlocal csc = premake.dotnet\n\n-- Do some processing up front: build a list of configuration-dependent libraries.\n-- Libraries that are built to a location other than $(TARGETDIR) will need to\n-- be copied so they can be found at runtime.\nlocal cfglibs = { }\nlocal cfgpairs = { }\nlocal anycfg\nfor cfg in premake.eachconfig(prj) do\nanycfg = cfg\ncfglibs[cfg] = premake.getlinks(cfg, \"siblings\", \"fullpath\")\ncfgpairs[cfg] = { }\nfor _, fname in ipairs(cfglibs[cfg]) do\nif path.getdirectory(fname) ~= cfg.buildtarget.directory then\ncfgpairs[cfg][\"$(TARGETDIR)/\"..path.getname(fname)] = fname\nend\nend\nend\n\n-- sort the files into categories, based on their build action\nlocal sources = {}\nlocal embedded = { }\nlocal copypairs = { }\n\nfor fcfg in premake.eachfile(prj) do\nlocal action = csc.getbuildaction(fcfg)\nif action == \"Compile\" then\ntable.insert(sources, fcfg.name)\nelseif action == \"EmbeddedResource\" then\ntable.insert(embedded, fcfg.name)\nelseif action == \"Content\" then\ncopypairs[\"$(TARGETDIR)/\"..path.getname(fcfg.name)] = fcfg.name\nelseif path.getname(fcfg.name):lower() == \"app.config\" then\ncopypairs[\"$(TARGET).config\"] = fcfg.name\nend\nend\n\n-- Any assemblies that are on the library search paths should be copied\n-- to $(TARGETDIR) so they can be found at runtime\nlocal paths = table.translate(prj.libdirs, function(v) return path.join(prj.basedir, v) end)\npaths = table.join({prj.basedir}, paths)\nfor _, libname in ipairs(premake.getlinks(prj, \"system\", \"fullpath\")) do\nlocal libdir = os.pathsearch(libname..\".dll\", unpack(paths))\nif (libdir) then\nlocal target = \"$(TARGETDIR)/\"..path.getname(libname)\nlocal source = path.getrelative(prj.basedir, path.join(libdir, libname))..\".dll\"\ncopypairs[target] = source\nend\nend\n\n-- end of preprocessing --\n\n\n-- set up the environment\n_p('# %s project makefile autogenerated by Premake', premake.actions[_ACTION].shortname)\n_p('')\n\n_p('ifndef config')\n_p(' config=%s', _MAKE.esc(prj.configurations[1]:lower()))\n_p('endif')\n_p('')\n\n_p('ifndef verbose')\n_p(' SILENT = @')\n_p('endif')\n_p('')\n\n_p('ifndef CSC')\n_p(' CSC=%s', csc.getcompilervar(prj))\n_p('endif')\n_p('')\n\n_p('ifndef RESGEN')\n_p(' RESGEN=resgen')\n_p('endif')\n_p('')\n\n-- Platforms aren't support for .NET projects, but I need the ability to match\n-- the buildcfg:platform identifiers with a block of settings. So enumerate the\n-- pairs the same way I do for C/C++ projects, but always use the generic settings\nlocal platforms = premake.filterplatforms(prj.solution, premake[_OPTIONS.cc].platforms)\ntable.insert(platforms, 1, \"\")\n\n-- write the configuration blocks\nfor cfg in premake.eachconfig(prj) do\n_p('ifneq (,$(findstring %s,$(config)))', _MAKE.esc(cfg.name:lower()))\n_p(' TARGETDIR := %s', _MAKE.esc(cfg.buildtarget.directory))\n_p(' OBJDIR := %s', _MAKE.esc(cfg.objectsdir))\n_p(' DEPENDS := %s', table.concat(_MAKE.esc(premake.getlinks(cfg, \"dependencies\", \"fullpath\")), \" \"))\n_p(' REFERENCES := %s', table.implode(_MAKE.esc(cfglibs[cfg]), \"/r:\", \"\", \" \"))\n_p(' FLAGS += %s %s', table.concat(csc.getflags(cfg), \" \"), table.implode(cfg.defines, \"/d:\", \"\", \" \"))\n\n_p(' define PREBUILDCMDS')\nif #cfg.prebuildcommands > 0 then\n_p('\\t@echo Running pre-build commands')\n_p('\\t%s', table.implode(cfg.prebuildcommands, \"\", \"\", \"\\n\\t\"))\nend\n_p(' endef')\n\n_p(' define PRELINKCMDS')\nif #cfg.prelinkcommands > 0 then\n_p('\\t@echo Running pre-link commands')\n_p('\\t%s', table.implode(cfg.prelinkcommands, \"\", \"\", \"\\n\\t\"))\nend\n_p(' endef')\n\n_p(' define POSTBUILDCMDS')\nif #cfg.postbuildcommands > 0 then\n_p('\\t@echo Running post-build commands')\n_p('\\t%s', table.implode(cfg.postbuildcommands, \"\", \"\", \"\\n\\t\"))\nend\n_p(' endef')\n\n_p('endif')\n_p('')\nend\n\n-- set project level values\n_p('# To maintain compatibility with VS.NET, these values must be set at the project level')\n_p('TARGET := $(TARGETDIR)/%s', _MAKE.esc(prj.buildtarget.name))\n_p('FLAGS += /t:%s %s', csc.getkind(prj):lower(), table.implode(_MAKE.esc(prj.libdirs), \"/lib:\", \"\", \" \"))\n_p('REFERENCES += %s', table.implode(_MAKE.esc(premake.getlinks(prj, \"system\", \"basename\")), \"/r:\", \".dll\", \" \"))\n_p('')\n\n-- list source files\n_p('SOURCES := \\\\')\nfor _, fname in ipairs(sources) do\n_p('\\t%s \\\\', _MAKE.esc(path.translate(fname)))\nend\n_p('')\n\n_p('EMBEDFILES := \\\\')\nfor _, fname in ipairs(embedded) do\n_p('\\t%s \\\\', _MAKE.esc(getresourcefilename(prj, fname)))\nend\n_p('')\n\n_p('COPYFILES += \\\\')\nfor target, source in pairs(cfgpairs[anycfg]) do\n_p('\\t%s \\\\', _MAKE.esc(target))\nend\nfor target, source in pairs(copypairs) do\n_p('\\t%s \\\\', _MAKE.esc(target))\nend\n_p('')\n\n-- set up support commands like mkdir, rmdir, etc. based on the shell\n_p('SHELLTYPE := msdos')\n_p('ifeq (,$(ComSpec)$(COMSPEC))')\n_p(' SHELLTYPE := posix')\n_p('endif')\n_p('ifeq (/bin,$(findstring /bin,$(SHELL)))')\n_p(' SHELLTYPE := posix')\n_p('endif')\n_p('ifeq (posix,$(SHELLTYPE))')\n_p(' define MKDIR_RULE')\n_p('\\t@echo Creating $@')\n_p('\\t$(SILENT) mkdir -p $@')\n_p(' endef')\n_p(' define COPY_RULE')\n_p('\\t@echo Copying $(notdir $@)')\n_p('\\t$(SILENT) cp -fR $^ $@')\n_p(' endef')\n_p('else')\n_p(' define MKDIR_RULE')\n_p('\\t@echo Creating $@')\n_p('\\t$(SILENT) mkdir $(subst /,\\\\\\\\,$@)')\n_p(' endef')\n_p(' define COPY_RULE')\n_p('\\t@echo Copying $(notdir $@)')\n_p('\\t$(SILENT) copy /Y $(subst /,\\\\\\\\,$^) $(subst /,\\\\\\\\,$@)')\n_p(' endef')\n_p('endif')\n\n-- main build rule(s)\n_p('.PHONY: clean prebuild prelink')\n_p('')\n\n_p('all: $(TARGETDIR) $(OBJDIR) prebuild $(EMBEDFILES) $(COPYFILES) prelink $(TARGET)')\n_p('')\n\n_p('$(TARGET): $(SOURCES) $(EMBEDFILES) $(DEPENDS)')\n_p('\\t$(SILENT) $(CSC) /nologo /out:$@ $(FLAGS) $(REFERENCES) $(SOURCES) $(patsubst %%,/resource:%%,$(EMBEDFILES))')\n_p('\\t$(POSTBUILDCMDS)')\n_p('')\n\n-- create destination directories\n_p('$(TARGETDIR):')\n_p('\\t$(MKDIR_RULE)')\n_p('')\n\n_p('$(OBJDIR):')\n_p('\\t$(MKDIR_RULE)')\n_p('')\n\n-- clean target\n_p('clean:')\n_p('\\t@echo Cleaning %s', prj.name)\n_p('ifeq (posix,$(SHELLTYPE))')\n_p('\\t$(SILENT) rm -f $(TARGETDIR)/%s.* $(COPYFILES)', prj.buildtarget.basename)\n_p('\\t$(SILENT) rm -rf $(OBJDIR)')\n_p('else')\n_p('\\t$(SILENT) if exist $(subst /,\\\\\\\\,$(TARGETDIR)/%s.*) del $(subst /,\\\\\\\\,$(TARGETDIR)/%s.*)', prj.buildtarget.basename, prj.buildtarget.basename)\nfor target, source in pairs(cfgpairs[anycfg]) do\n_p('\\t$(SILENT) if exist $(subst /,\\\\\\\\,%s) del $(subst /,\\\\\\\\,%s)', target, target)\nend\nfor target, source in pairs(copypairs) do\n_p('\\t$(SILENT) if exist $(subst /,\\\\\\\\,%s) del $(subst /,\\\\\\\\,%s)', target, target)\nend\n_p('\\t$(SILENT) if exist $(subst /,\\\\\\\\,$(OBJDIR)) rmdir /s /q $(subst /,\\\\\\\\,$(OBJDIR))')\n_p('endif')\n_p('')\n\n-- custom build step targets\n_p('prebuild:')\n_p('\\t$(PREBUILDCMDS)')\n_p('')\n\n_p('prelink:')\n_p('\\t$(PRELINKCMDS)')\n_p('')\n\n-- per-file rules\n_p('# Per-configuration copied file rules')\nfor cfg in premake.eachconfig(prj) do\n_p('ifneq (,$(findstring %s,$(config)))', _MAKE.esc(cfg.name:lower()))\nfor target, source in pairs(cfgpairs[cfg]) do\n_p('%s: %s', _MAKE.esc(target), _MAKE.esc(source))\n_p('\\t$(COPY_RULE)')\nend\n_p('endif')\nend\n_p('')\n\n_p('# Copied file rules')\nfor target, source in pairs(copypairs) do\n_p('%s: %s', _MAKE.esc(target), _MAKE.esc(source))\n_p('\\t$(COPY_RULE)')\n_p('')\nend\n\n_p('# Embedded file rules')\nfor _, fname in ipairs(embedded) do \nif path.getextension(fname) == \".resx\" then\n_p('%s: %s', _MAKE.esc(getresourcefilename(prj, fname)), _MAKE.esc(fname))\n_p('\\t$(SILENT) $(RESGEN) $^ $@')\nend\n_p('')\nend\n\nend\n", "--\n\nfunction premake.vs2002_solution(sln)\nio.eol = '\\r\\n'\n\n_p('Microsoft Visual Studio Solution File, Format Version 7.00')\n\n-- Write out the list of project entries\nfor prj in premake.eachproject(sln) do\nlocal projpath = path.translate(path.getrelative(sln.location, _VS.projectfile(prj)))\n_p('Project(\"{%s}\") = \"%s\", \"%s\", \"{%s}\"', _VS.tool(prj), prj.name, projpath, prj.uuid)\n_p('EndProject')\nend\n\n_p('Global')\n_p('\\tGlobalSection(SolutionConfiguration) = preSolution')\nfor i, cfgname in ipairs(sln.configurations) do\n_p('\\t\\tConfigName.%d = %s', i - 1, cfgname)\nend\n_p('\\tEndGlobalSection')\n\n_p('\\tGlobalSection(ProjectDependencies) = postSolution')\n_p('\\tEndGlobalSection')\n\n_p('\\tGlobalSection(ProjectConfiguration) = postSolution')\nfor prj in premake.eachproject(sln) do\nfor _, cfgname in ipairs(sln.configurations) do\n_p('\\t\\t{%s}.%s.ActiveCfg = %s|%s', prj.uuid, cfgname, cfgname, _VS.arch(prj))\n_p('\\t\\t{%s}.%s.Build.0 = %s|%s', prj.uuid, cfgname, cfgname, _VS.arch(prj))\nend\nend\n_p('\\tEndGlobalSection')\n_p('\\tGlobalSection(ExtensibilityGlobals) = postSolution')\n_p('\\tEndGlobalSection')\n_p('\\tGlobalSection(ExtensibilityAddIns) = postSolution')\n_p('\\tEndGlobalSection')\n\n_p('EndGlobal')\nend\n", - "--\n\n--\n-- Figure out what elements a particular file need in its item block,\n-- based on its build action and any related files in the project.\n-- \nlocal function getelements(prj, action, fname)\n\nif action == \"Compile\" and fname:endswith(\".cs\") then\nreturn \"SubTypeCode\"\nend\n\nif action == \"EmbeddedResource\" and fname:endswith(\".resx\") then\n-- is there a matching *.cs file?\nlocal basename = fname:sub(1, -6)\nlocal testname = path.getname(basename .. \".cs\")\nif premake.findfile(prj, testname) then\nreturn \"Dependency\", testname\nend\nend\n\nreturn \"None\"\nend\n\n\n\nfunction premake.vs2002_csproj(prj)\nio.eol = \"\\r\\n\"\n_p('')\n\n_p('\\t')\n\n_p('\\t\\t')\n\n-- Write out project-wide settings\n_p('\\t\\t\\t')\n\n-- Write out configuration blocks\nfor cfg in premake.eachconfig(prj) do\n_p('\\t\\t\\t\\t')\nend\n_p('\\t\\t\\t')\n\n-- List assembly references\n_p('\\t\\t\\t')\nfor _, ref in ipairs(premake.getlinks(prj, \"siblings\", \"object\")) do\n_p('\\t\\t\\t\\t')\nend\nfor _, linkname in ipairs(premake.getlinks(prj, \"system\", \"fullpath\")) do\n_p('\\t\\t\\t\\t')\nend\n_p('\\t\\t\\t')\n\n_p('\\t\\t')\n\n-- List source files\n_p('\\t\\t')\n_p('\\t\\t\\t')\nfor fcfg in premake.eachfile(prj) do\nlocal action = premake.csc.getbuildaction(fcfg)\nlocal fname = path.translate(premake.esc(fcfg.name), \"\\\\\")\nlocal elements, dependency = getelements(prj, action, fcfg.name)\n\n_p('\\t\\t\\t\\t')\nend\n_p('\\t\\t\\t')\n_p('\\t\\t')\n\n_p('\\t')\n_p('')\n\nend\n", + "--\n\n--\n-- Figure out what elements a particular file need in its item block,\n-- based on its build action and any related files in the project.\n-- \nlocal function getelements(prj, action, fname)\n\nif action == \"Compile\" and fname:endswith(\".cs\") then\nreturn \"SubTypeCode\"\nend\n\nif action == \"EmbeddedResource\" and fname:endswith(\".resx\") then\n-- is there a matching *.cs file?\nlocal basename = fname:sub(1, -6)\nlocal testname = path.getname(basename .. \".cs\")\nif premake.findfile(prj, testname) then\nreturn \"Dependency\", testname\nend\nend\n\nreturn \"None\"\nend\n\n\n\nfunction premake.vs2002_csproj(prj)\nio.eol = \"\\r\\n\"\n_p('')\n\n_p('\\t')\n\n_p('\\t\\t')\n\n-- Write out project-wide settings\n_p('\\t\\t\\t')\n\n-- Write out configuration blocks\nfor cfg in premake.eachconfig(prj) do\n_p('\\t\\t\\t\\t')\nend\n_p('\\t\\t\\t')\n\n-- List assembly references\n_p('\\t\\t\\t')\nfor _, ref in ipairs(premake.getlinks(prj, \"siblings\", \"object\")) do\n_p('\\t\\t\\t\\t')\nend\nfor _, linkname in ipairs(premake.getlinks(prj, \"system\", \"fullpath\")) do\n_p('\\t\\t\\t\\t')\nend\n_p('\\t\\t\\t')\n\n_p('\\t\\t')\n\n-- List source files\n_p('\\t\\t')\n_p('\\t\\t\\t')\nfor fcfg in premake.eachfile(prj) do\nlocal action = premake.dotnet.getbuildaction(fcfg)\nlocal fname = path.translate(premake.esc(fcfg.name), \"\\\\\")\nlocal elements, dependency = getelements(prj, action, fcfg.name)\n\n_p('\\t\\t\\t\\t')\nend\n_p('\\t\\t\\t')\n_p('\\t\\t')\n\n_p('\\t')\n_p('')\n\nend\n", "--\n\nfunction premake.vs2002_csproj_user(prj)\nio.eol = \"\\r\\n\"\n\n_p('')\n_p('\\t')\n_p('\\t\\t')\n\n-- Visual Studio wants absolute paths\nlocal refpaths = table.translate(prj.libdirs, function(v) return path.getabsolute(prj.location .. \"/\" .. v) end)\n_p('\\t\\t\\t', path.translate(table.concat(refpaths, \";\"), \"\\\\\"))\n\nfor cfg in premake.eachconfig(prj) do\n_p('\\t\\t\\t\\t')\nend\n\n_p('\\t\\t\\t')\n_p('\\t\\t')\n_p('\\t\\t')\n\n_p('\\t')\n_p('')\n\nend\n", - "--\n\n\n\nlocal function buildstepsblock(name, steps)\n_p('\\t\\t\\t 0 then\n_p('\\t\\t\\t\\tCommandLine=\"%s\"', premake.esc(table.implode(steps, \"\", \"\", \"\\r\\n\")))\nend\n_p('\\t\\t\\t/>')\nend\n\n\n\nlocal function getsections(version, platform)\nif version == \"vs2002\" then\nreturn {\n\"VCCLCompilerTool\",\n\"VCCustomBuildTool\",\n\"VCLinkerTool\",\n\"VCMIDLTool\",\n\"VCPostBuildEventTool\",\n\"VCPreBuildEventTool\",\n\"VCPreLinkEventTool\",\n\"VCResourceCompilerTool\",\n\"VCWebServiceProxyGeneratorTool\",\n\"VCWebDeploymentTool\"\n}\nend\nif version == \"vs2003\" then\nreturn {\n\"VCCLCompilerTool\",\n\"VCCustomBuildTool\",\n\"VCLinkerTool\",\n\"VCMIDLTool\",\n\"VCPostBuildEventTool\",\n\"VCPreBuildEventTool\",\n\"VCPreLinkEventTool\",\n\"VCResourceCompilerTool\",\n\"VCWebServiceProxyGeneratorTool\",\n\"VCXMLDataGeneratorTool\",\n\"VCWebDeploymentTool\",\n\"VCManagedWrapperGeneratorTool\",\n\"VCAuxiliaryManagedWrapperGeneratorTool\"\n}\nend\nif platform == \"Xbox360\" then\nreturn {\n\"VCPreBuildEventTool\",\n\"VCCustomBuildTool\",\n\"VCXMLDataGeneratorTool\",\n\"VCWebServiceProxyGeneratorTool\",\n\"VCMIDLTool\",\n\"VCCLX360CompilerTool\",\n\"VCManagedResourceCompilerTool\",\n\"VCResourceCompilerTool\",\n\"VCPreLinkEventTool\",\n\"VCX360LinkerTool\",\n\"VCALinkTool\",\n\"VCX360ImageTool\",\n\"VCBscMakeTool\",\n\"VCX360DeploymentTool\",\n\"VCPostBuildEventTool\",\n\"DebuggerTool\",\n}\nelse\nreturn {\n\"VCPreBuildEventTool\",\n\"VCCustomBuildTool\",\n\"VCXMLDataGeneratorTool\",\n\"VCWebServiceProxyGeneratorTool\",\n\"VCMIDLTool\",\n\"VCCLCompilerTool\",\n\"VCManagedResourceCompilerTool\",\n\"VCResourceCompilerTool\",\n\"VCPreLinkEventTool\",\n\"VCLinkerTool\",\n\"VCALinkTool\",\n\"VCManifestTool\",\n\"VCXDCMakeTool\",\n\"VCBscMakeTool\",\n\"VCFxCopTool\",\n\"VCAppVerifierTool\",\n\"VCWebDeploymentTool\",\n\"VCPostBuildEventTool\"\n}\nend\nend\n\n\n\n\nfunction premake.vs200x_vcproj_platforms(prj)\nlocal used = { }\n_p('\\t')\nfor _, cfg in ipairs(prj.solution.vstudio_configs) do\nif cfg.isreal and not table.contains(used, cfg.platform) then\ntable.insert(used, cfg.platform)\n_p('\\t\\t')\nend\nend\n_p('\\t')\nend\n\n\n\n\nfunction premake.vs200x_vcproj(prj)\nio.eol = \"\\r\\n\"\n_p('')\n\n-- Write opening project block\n_p(' \"vs2003\" then\n_p('\\tRootNamespace=\"%s\"', prj.name)\nend\n_p('\\tKeyword=\"%s\"', iif(prj.flags.Managed, \"ManagedCProj\", \"Win32Proj\"))\n_p('\\t>')\n\n-- list the target platforms\npremake.vs200x_vcproj_platforms(prj)\n\nif _ACTION > \"vs2003\" then\n_p('\\t')\n_p('\\t')\nend\n\n_p('\\t')\nfor _, cfginfo in ipairs(prj.solution.vstudio_configs) do\nif cfginfo.isreal then\nlocal cfg = premake.getconfig(prj, cfginfo.buildcfg, cfginfo.src_platform)\n\n-- Start a configuration\n_p('\\t\\t')\n\nfor _, block in ipairs(getsections(_ACTION, cfginfo.src_platform)) do\n\n-- Compiler block --\nif block == \"VCCLCompilerTool\" or block == \"VCCLX360CompilerTool\" then\n_p('\\t\\t\\t 0 then\n_p('\\t\\t\\t\\tAdditionalOptions=\"%s\"', table.concat(premake.esc(cfg.buildoptions), \" \"))\nend\n_p('\\t\\t\\t\\tOptimization=\"%s\"', _VS.optimization(cfg))\nif cfg.flags.NoFramePointer then\n_p('\\t\\t\\t\\tOmitFramePointers=\"%s\"', _VS.bool(true))\nend\nif #cfg.includedirs > 0 then\n_p('\\t\\t\\t\\tAdditionalIncludeDirectories=\"%s\"', table.concat(premake.esc(cfg.includedirs), \";\"))\nend\nif #cfg.defines > 0 then\n_p('\\t\\t\\t\\tPreprocessorDefinitions=\"%s\"', table.concat(premake.esc(cfg.defines), \";\"))\nend\nif cfg.flags.Symbols and not cfg.flags.Managed then\n_p('\\t\\t\\t\\tMinimalRebuild=\"%s\"', _VS.bool(true))\nend\nif cfg.flags.NoExceptions then\n_p('\\t\\t\\t\\tExceptionHandling=\"%s\"', iif(_ACTION < \"vs2005\", \"FALSE\", 0))\nelseif cfg.flags.SEH and _ACTION > \"vs2003\" then\n_p('\\t\\t\\t\\tExceptionHandling=\"2\"')\nend\nif _VS.optimization(cfg) == 0 and not cfg.flags.Managed then\n_p('\\t\\t\\t\\tBasicRuntimeChecks=\"3\"')\nend\nif _VS.optimization(cfg) ~= 0 then\n_p('\\t\\t\\t\\tStringPooling=\"%s\"', _VS.bool(true))\nend\n_p('\\t\\t\\t\\tRuntimeLibrary=\"%s\"', _VS.runtime(cfg))\n_p('\\t\\t\\t\\tEnableFunctionLevelLinking=\"%s\"', _VS.bool(true))\nif _ACTION < \"vs2005\" and not cfg.flags.NoRTTI then\n_p('\\t\\t\\t\\tRuntimeTypeInfo=\"%s\"', _VS.bool(true))\nelseif _ACTION > \"vs2003\" and cfg.flags.NoRTTI then\n_p('\\t\\t\\t\\tRuntimeTypeInfo=\"%s\"', _VS.bool(false))\nend\nif cfg.flags.NativeWChar then\n_p('\\t\\t\\t\\tTreatWChar_tAsBuiltInType=\"%s\"', _VS.bool(true))\nelseif cfg.flags.NoNativeWChar then\n_p('\\t\\t\\t\\tTreatWChar_tAsBuiltInType=\"%s\"', _VS.bool(false))\nend\nif not cfg.flags.NoPCH and cfg.pchheader then\n_p('\\t\\t\\t\\tUsePrecompiledHeader=\"%s\"', iif(_ACTION < \"vs2005\", 3, 2))\n_p('\\t\\t\\t\\tPrecompiledHeaderThrough=\"%s\"', cfg.pchheader)\nelse\n_p('\\t\\t\\t\\tUsePrecompiledHeader=\"%s\"', iif(_ACTION > \"vs2003\" or cfg.flags.NoPCH, 0, 2))\nend\n_p('\\t\\t\\t\\tWarningLevel=\"%s\"', iif(cfg.flags.ExtraWarnings, 4, 3))\nif cfg.flags.FatalWarnings then\n_p('\\t\\t\\t\\tWarnAsError=\"%s\"', _VS.bool(true))\nend\nif _ACTION < \"vs2008\" and not cfg.flags.Managed then\n_p('\\t\\t\\t\\tDetect64BitPortabilityProblems=\"%s\"', _VS.bool(not cfg.flags.No64BitChecks))\nend\n_p('\\t\\t\\t\\tProgramDataBaseFileName=\"$(OutDir)\\\\$(ProjectName).pdb\"')\n_p('\\t\\t\\t\\tDebugInformationFormat=\"%s\"', _VS.symbols(cfg))\n_p('\\t\\t\\t/>')\n-- End compiler block --\n\n-- Linker block --\nelseif block == \"VCLinkerTool\" or block == \"VCX360LinkerTool\" then\n_p('\\t\\t\\t 0 then\n_p('\\t\\t\\t\\tAdditionalOptions=\"%s\"', table.concat(premake.esc(cfg.linkoptions), \" \"))\nend\nif #cfg.links > 0 then\n_p('\\t\\t\\t\\tAdditionalDependencies=\"%s\"', table.concat(premake.getlinks(cfg, \"all\", \"fullpath\"), \" \"))\nend\n_p('\\t\\t\\t\\tOutputFile=\"$(OutDir)\\\\%s\"', cfg.buildtarget.name)\n_p('\\t\\t\\t\\tLinkIncremental=\"%s\"', iif(_VS.optimization(cfg) == 0, 2, 1))\n_p('\\t\\t\\t\\tAdditionalLibraryDirectories=\"%s\"', table.concat(premake.esc(path.translate(cfg.libdirs)) , \";\"))\nlocal deffile = premake.findfile(cfg, \".def\")\nif deffile then\n_p('\\t\\t\\t\\tModuleDefinitionFile=\"%s\"', deffile)\nend\nif cfg.flags.NoManifest then\n_p('\\t\\t\\t\\tGenerateManifest=\"%s\"', _VS.bool(false))\nend\n_p('\\t\\t\\t\\tGenerateDebugInformation=\"%s\"', _VS.bool(_VS.symbols(cfg) ~= 0))\nif _VS.symbols(cfg) ~= 0 then\n_p('\\t\\t\\t\\tProgramDatabaseFile=\"$(OutDir)\\\\$(ProjectName).pdb\"')\nend\n_p('\\t\\t\\t\\tSubSystem=\"%s\"', iif(cfg.kind == \"ConsoleApp\", 1, 2))\nif _VS.optimization(cfg) ~= 0 then\n_p('\\t\\t\\t\\tOptimizeReferences=\"2\"')\n_p('\\t\\t\\t\\tEnableCOMDATFolding=\"2\"')\nend\nif (cfg.kind == \"ConsoleApp\" or cfg.kind == \"WindowedApp\") and not cfg.flags.WinMain then\n_p('\\t\\t\\t\\tEntryPointSymbol=\"mainCRTStartup\"')\nend\nif cfg.kind == \"SharedLib\" then\nlocal implibname = path.translate(premake.gettarget(cfg, \"link\", \"windows\").fullpath, \"\\\\\")\n_p('\\t\\t\\t\\tImportLibrary=\"%s\"', iif(cfg.flags.NoImportLib, cfg.objectsdir .. \"\\\\\" .. path.getname(implibname), implibname))\nend\n_p('\\t\\t\\t\\tTargetMachine=\"1\"')\nelse\n_p('\\t\\t\\t\\tName=\"VCLibrarianTool\"')\nif #cfg.links > 0 then\n_p('\\t\\t\\t\\tAdditionalDependencies=\"%s\"', table.concat(premake.getlinks(cfg, \"all\", \"fullpath\"), \" \"))\nend\n_p('\\t\\t\\t\\tOutputFile=\"$(OutDir)\\\\%s\"', cfg.buildtarget.name)\n_p('\\t\\t\\t\\tAdditionalLibraryDirectories=\"%s\"', table.concat(premake.esc(path.translate(cfg.libdirs)) , \";\"))\nend\n_p('\\t\\t\\t/>')\n-- End linker block --\n\n-- Resource compiler --\nelseif block == \"VCResourceCompilerTool\" then\n_p('\\t\\t\\t 0 then\n_p('\\t\\t\\t\\tAdditionalOptions=\"%s\"', table.concat(premake.esc(cfg.resoptions), \" \"))\nend\nif #cfg.defines > 0 or #cfg.resdefines > 0 then\n_p('\\t\\t\\t\\tPreprocessorDefinitions=\"%s\"', table.concat(premake.esc(table.join(cfg.defines, cfg.resdefines)), \";\"))\nend\nif #cfg.includedirs > 0 or #cfg.resincludedirs > 0 then\n_p('\\t\\t\\t\\tAdditionalIncludeDirectories=\"%s\"', table.concat(premake.esc(table.join(cfg.includedirs, cfg.resincludedirs)), \";\"))\nend\n_p('\\t\\t\\t/>')\n-- End resource compiler --\n\n-- Build event blocks --\nelseif block == \"VCPreBuildEventTool\" then\nbuildstepsblock(\"VCPreBuildEventTool\", cfg.prebuildcommands)\nelseif block == \"VCPreLinkEventTool\" then\nbuildstepsblock(\"VCPreLinkEventTool\", cfg.prelinkcommands)\nelseif block == \"VCPostBuildEventTool\" then\nbuildstepsblock(\"VCPostBuildEventTool\", cfg.postbuildcommands)\n-- End build event blocks --\n\n-- Xbox 360 custom sections --\nelseif block == \"VCX360DeploymentTool\" then\n_p('\\t\\t\\t')\n\nelseif block == \"DebuggerTool\" then\n_p('\\t\\t\\t')\n-- End Xbox 360 custom sections --\n\nelse\n_p('\\t\\t\\t')\nend\n\nend\n\n_p('\\t\\t')\nend\nend\n_p('\\t')\n\n_p('\\t')\n_p('\\t')\n\n_p('\\t')\npremake.walksources(prj, prj.files, _VS.files)\n_p('\\t')\n\n_p('\\t')\n_p('\\t')\n_p('')\nend\n\n\n", + "--\n\n\n\nfunction premake.vs200x_vcproj_platforms(prj)\nlocal used = { }\n_p('\\t')\nfor _, cfg in ipairs(prj.solution.vstudio_configs) do\nif cfg.isreal and not table.contains(used, cfg.platform) then\ntable.insert(used, cfg.platform)\n_p('\\t\\t')\nend\nend\n_p('\\t')\nend\n\n\n\n\nfunction premake.vs200x_vcproj_VCCLCompilerTool(cfg)\n_p('\\t\\t\\t 0 then\n_p('\\t\\t\\t\\tAdditionalOptions=\"%s\"', table.concat(premake.esc(cfg.buildoptions), \" \"))\nend\n\n_p('\\t\\t\\t\\tOptimization=\"%s\"', _VS.optimization(cfg))\n\nif cfg.flags.NoFramePointer then\n_p('\\t\\t\\t\\tOmitFramePointers=\"%s\"', _VS.bool(true))\nend\n\nif #cfg.includedirs > 0 then\n_p('\\t\\t\\t\\tAdditionalIncludeDirectories=\"%s\"', premake.esc(path.translate(table.concat(cfg.includedirs, \";\"), '\\\\')))\nend\n\nif #cfg.defines > 0 then\n_p('\\t\\t\\t\\tPreprocessorDefinitions=\"%s\"', premake.esc(table.concat(cfg.defines, \";\")))\nend\n\nif cfg.flags.Symbols and not cfg.flags.Managed then\n_p('\\t\\t\\t\\tMinimalRebuild=\"%s\"', _VS.bool(true))\nend\n\nif cfg.flags.NoExceptions then\n_p('\\t\\t\\t\\tExceptionHandling=\"%s\"', iif(_ACTION < \"vs2005\", \"FALSE\", 0))\nelseif cfg.flags.SEH and _ACTION > \"vs2003\" then\n_p('\\t\\t\\t\\tExceptionHandling=\"2\"')\nend\n\nif _VS.optimization(cfg) == 0 and not cfg.flags.Managed then\n_p('\\t\\t\\t\\tBasicRuntimeChecks=\"3\"')\nend\nif _VS.optimization(cfg) ~= 0 then\n_p('\\t\\t\\t\\tStringPooling=\"%s\"', _VS.bool(true))\nend\n\n_p('\\t\\t\\t\\tRuntimeLibrary=\"%s\"', _VS.runtime(cfg))\n_p('\\t\\t\\t\\tEnableFunctionLevelLinking=\"%s\"', _VS.bool(true))\n\nif _ACTION < \"vs2005\" and not cfg.flags.NoRTTI then\n_p('\\t\\t\\t\\tRuntimeTypeInfo=\"%s\"', _VS.bool(true))\nelseif _ACTION > \"vs2003\" and cfg.flags.NoRTTI then\n_p('\\t\\t\\t\\tRuntimeTypeInfo=\"%s\"', _VS.bool(false))\nend\n\nif cfg.flags.NativeWChar then\n_p('\\t\\t\\t\\tTreatWChar_tAsBuiltInType=\"%s\"', _VS.bool(true))\nelseif cfg.flags.NoNativeWChar then\n_p('\\t\\t\\t\\tTreatWChar_tAsBuiltInType=\"%s\"', _VS.bool(false))\nend\n\nif not cfg.flags.NoPCH and cfg.pchheader then\n_p('\\t\\t\\t\\tUsePrecompiledHeader=\"%s\"', iif(_ACTION < \"vs2005\", 3, 2))\n_p('\\t\\t\\t\\tPrecompiledHeaderThrough=\"%s\"', cfg.pchheader)\nelse\n_p('\\t\\t\\t\\tUsePrecompiledHeader=\"%s\"', iif(_ACTION > \"vs2003\" or cfg.flags.NoPCH, 0, 2))\nend\n\n_p('\\t\\t\\t\\tWarningLevel=\"%s\"', iif(cfg.flags.ExtraWarnings, 4, 3))\n\nif cfg.flags.FatalWarnings then\n_p('\\t\\t\\t\\tWarnAsError=\"%s\"', _VS.bool(true))\nend\n\nif _ACTION < \"vs2008\" and not cfg.flags.Managed then\n_p('\\t\\t\\t\\tDetect64BitPortabilityProblems=\"%s\"', _VS.bool(not cfg.flags.No64BitChecks))\nend\n\n_p('\\t\\t\\t\\tProgramDataBaseFileName=\"$(OutDir)\\\\$(ProjectName).pdb\"')\n_p('\\t\\t\\t\\tDebugInformationFormat=\"%s\"', _VS.symbols(cfg))\n_p('\\t\\t\\t/>')\nend\n\n\n\n\nfunction premake.vs200x_vcproj_VCLinkerTool(cfg)\n_p('\\t\\t\\t 0 then\n_p('\\t\\t\\t\\tAdditionalOptions=\"%s\"', table.concat(premake.esc(cfg.linkoptions), \" \"))\nend\n\nif #cfg.links > 0 then\n_p('\\t\\t\\t\\tAdditionalDependencies=\"%s\"', table.concat(premake.getlinks(cfg, \"all\", \"fullpath\"), \" \"))\nend\n\n_p('\\t\\t\\t\\tOutputFile=\"$(OutDir)\\\\%s\"', cfg.buildtarget.name)\n_p('\\t\\t\\t\\tLinkIncremental=\"%s\"', iif(_VS.optimization(cfg) == 0, 2, 1))\n_p('\\t\\t\\t\\tAdditionalLibraryDirectories=\"%s\"', table.concat(premake.esc(path.translate(cfg.libdirs, '\\\\')) , \";\"))\n\nlocal deffile = premake.findfile(cfg, \".def\")\nif deffile then\n_p('\\t\\t\\t\\tModuleDefinitionFile=\"%s\"', deffile)\nend\n\nif cfg.flags.NoManifest then\n_p('\\t\\t\\t\\tGenerateManifest=\"%s\"', _VS.bool(false))\nend\n\n_p('\\t\\t\\t\\tGenerateDebugInformation=\"%s\"', _VS.bool(_VS.symbols(cfg) ~= 0))\n\nif _VS.symbols(cfg) ~= 0 then\n_p('\\t\\t\\t\\tProgramDatabaseFile=\"$(OutDir)\\\\$(ProjectName).pdb\"')\nend\n\n_p('\\t\\t\\t\\tSubSystem=\"%s\"', iif(cfg.kind == \"ConsoleApp\", 1, 2))\n\nif _VS.optimization(cfg) ~= 0 then\n_p('\\t\\t\\t\\tOptimizeReferences=\"2\"')\n_p('\\t\\t\\t\\tEnableCOMDATFolding=\"2\"')\nend\n\nif (cfg.kind == \"ConsoleApp\" or cfg.kind == \"WindowedApp\") and not cfg.flags.WinMain then\n_p('\\t\\t\\t\\tEntryPointSymbol=\"mainCRTStartup\"')\nend\n\nif cfg.kind == \"SharedLib\" then\nlocal implibname = path.translate(premake.gettarget(cfg, \"link\", \"windows\").fullpath, \"\\\\\")\n_p('\\t\\t\\t\\tImportLibrary=\"%s\"', iif(cfg.flags.NoImportLib, cfg.objectsdir .. \"\\\\\" .. path.getname(implibname), implibname))\nend\n\n_p('\\t\\t\\t\\tTargetMachine=\"1\"')\n\nelse\n_p('\\t\\t\\t\\tName=\"VCLibrarianTool\"')\n\nif #cfg.links > 0 then\n_p('\\t\\t\\t\\tAdditionalDependencies=\"%s\"', table.concat(premake.getlinks(cfg, \"all\", \"fullpath\"), \" \"))\nend\n\n_p('\\t\\t\\t\\tOutputFile=\"$(OutDir)\\\\%s\"', cfg.buildtarget.name)\n_p('\\t\\t\\t\\tAdditionalLibraryDirectories=\"%s\"', table.concat(premake.esc(path.translate(cfg.libdirs)) , \";\"))\nend\n\n_p('\\t\\t\\t/>')\nend\n\n\n\nfunction premake.vs200x_vcproj_VCCLCompilerTool_GCC(cfg)\n_p('\\t\\t\\t 0 then\n_p('\\t\\t\\t\\tAdditionalOptions=\"%s\"', premake.esc(table.concat(buildoptions, \" \")))\nend\n\nif #cfg.includedirs > 0 then\n_p('\\t\\t\\t\\tAdditionalIncludeDirectories=\"%s\"', premake.esc(path.translate(table.concat(cfg.includedirs, \";\"), '\\\\')))\nend\n\nif #cfg.defines > 0 then\n_p('\\t\\t\\t\\tPreprocessorDefinitions=\"%s\"', table.concat(premake.esc(cfg.defines), \";\"))\nend\n\n_p('\\t\\t\\t\\tProgramDataBaseFileName=\"$(OutDir)\\\\$(ProjectName).pdb\"')\n_p('\\t\\t\\t\\tDebugInformationFormat=\"0\"')\n_p('\\t\\t\\t\\tCompileAs=\"0\"')\n_p('\\t\\t\\t/>')\nend\n\nfunction premake.vs200x_vcproj_VCLinkerTool_GCC(cfg)\n_p('\\t\\t\\t 0 then\n_p('\\t\\t\\t\\tAdditionalOptions=\"%s\"', table.concat(premake.esc(cfg.linkoptions), \" \"))\nend\n\nif #cfg.links > 0 then\n_p('\\t\\t\\t\\tAdditionalDependencies=\"%s\"', table.concat(premake.getlinks(cfg, \"all\", \"fullpath\"), \" \"))\nend\n\n_p('\\t\\t\\t\\tOutputFile=\"$(OutDir)\\\\%s\"', cfg.buildtarget.name)\n_p('\\t\\t\\t\\tLinkIncremental=\"%s\"', iif(_VS.optimization(cfg) == 0, 2, 1))\n_p('\\t\\t\\t\\tAdditionalLibraryDirectories=\"%s\"', table.concat(premake.esc(path.translate(cfg.libdirs, '\\\\')) , \";\"))\n\nlocal deffile = premake.findfile(cfg, \".def\")\nif deffile then\n_p('\\t\\t\\t\\tModuleDefinitionFile=\"%s\"', deffile)\nend\n\nif cfg.flags.NoManifest then\n_p('\\t\\t\\t\\tGenerateManifest=\"%s\"', _VS.bool(false))\nend\n\n_p('\\t\\t\\t\\tGenerateDebugInformation=\"%s\"', _VS.bool(_VS.symbols(cfg) ~= 0))\n\nif _VS.symbols(cfg) ~= 0 then\n_p('\\t\\t\\t\\tProgramDatabaseFile=\"$(OutDir)\\\\$(ProjectName).pdb\"')\nend\n\n_p('\\t\\t\\t\\tSubSystem=\"%s\"', iif(cfg.kind == \"ConsoleApp\", 1, 2))\n\nif _VS.optimization(cfg) ~= 0 then\n_p('\\t\\t\\t\\tOptimizeReferences=\"2\"')\n_p('\\t\\t\\t\\tEnableCOMDATFolding=\"2\"')\nend\n\nif (cfg.kind == \"ConsoleApp\" or cfg.kind == \"WindowedApp\") and not cfg.flags.WinMain then\n_p('\\t\\t\\t\\tEntryPointSymbol=\"mainCRTStartup\"')\nend\n\nif cfg.kind == \"SharedLib\" then\nlocal implibname = path.translate(premake.gettarget(cfg, \"link\", \"windows\").fullpath, \"\\\\\")\n_p('\\t\\t\\t\\tImportLibrary=\"%s\"', iif(cfg.flags.NoImportLib, cfg.objectsdir .. \"\\\\\" .. path.getname(implibname), implibname))\nend\n\n_p('\\t\\t\\t\\tTargetMachine=\"1\"')\n\nelse\n_p('\\t\\t\\t\\tName=\"VCLibrarianTool\"')\n\nlocal buildoptions = table.join(premake.gcc.getldflags(cfg), cfg.linkoptions)\nif #buildoptions > 0 then\n_p('\\t\\t\\t\\tAdditionalOptions=\"%s\"', premake.esc(table.concat(buildoptions, \" \")))\nend\n\nif #cfg.links > 0 then\n_p('\\t\\t\\t\\tAdditionalDependencies=\"%s\"', table.concat(premake.getlinks(cfg, \"all\", \"fullpath\"), \" \"))\nend\n\n_p('\\t\\t\\t\\tOutputFile=\"$(OutDir)\\\\%s\"', cfg.buildtarget.name)\n_p('\\t\\t\\t\\tAdditionalLibraryDirectories=\"%s\"', premake.esc(path.translate(table.concat(cfg.libdirs, \";\"))))\nend\n\n_p('\\t\\t\\t/>')\nend\n\n\n\n\nfunction premake.vs200x_vcproj_VCResourceCompilerTool(cfg)\n_p('\\t\\t\\t 0 then\n_p('\\t\\t\\t\\tAdditionalOptions=\"%s\"', table.concat(premake.esc(cfg.resoptions), \" \"))\nend\n\nif #cfg.defines > 0 or #cfg.resdefines > 0 then\n_p('\\t\\t\\t\\tPreprocessorDefinitions=\"%s\"', table.concat(premake.esc(table.join(cfg.defines, cfg.resdefines)), \";\"))\nend\n\nif #cfg.includedirs > 0 or #cfg.resincludedirs > 0 then\nlocal dirs = table.join(cfg.includedirs, cfg.resincludedirs)\n_p('\\t\\t\\t\\tAdditionalIncludeDirectories=\"%s\"', premake.esc(path.translate(table.concat(dirs, \";\"), '\\\\')))\nend\n\n_p('\\t\\t\\t/>')\nend\n\n\n\n\nfunction premake.vs200x_vcproj_buildstepsblock(name, steps)\n_p('\\t\\t\\t 0 then\n_p('\\t\\t\\t\\tCommandLine=\"%s\"', premake.esc(table.implode(steps, \"\", \"\", \"\\r\\n\")))\nend\n_p('\\t\\t\\t/>')\nend\n\n\n\n\nlocal blockmap = \n{\nVCCLCompilerTool = premake.vs200x_vcproj_VCCLCompilerTool,\nVCCLCompilerTool_GCC = premake.vs200x_vcproj_VCCLCompilerTool_GCC,\nVCLinkerTool = premake.vs200x_vcproj_VCLinkerTool,\nVCResourceCompilerTool = premake.vs200x_vcproj_VCResourceCompilerTool,\n}\n\n\n\nlocal function getsections(version, platform)\nif version == \"vs2002\" then\nreturn {\n\"VCCLCompilerTool\",\n\"VCCustomBuildTool\",\n\"VCLinkerTool\",\n\"VCMIDLTool\",\n\"VCPostBuildEventTool\",\n\"VCPreBuildEventTool\",\n\"VCPreLinkEventTool\",\n\"VCResourceCompilerTool\",\n\"VCWebServiceProxyGeneratorTool\",\n\"VCWebDeploymentTool\"\n}\nend\nif version == \"vs2003\" then\nreturn {\n\"VCCLCompilerTool\",\n\"VCCustomBuildTool\",\n\"VCLinkerTool\",\n\"VCMIDLTool\",\n\"VCPostBuildEventTool\",\n\"VCPreBuildEventTool\",\n\"VCPreLinkEventTool\",\n\"VCResourceCompilerTool\",\n\"VCWebServiceProxyGeneratorTool\",\n\"VCXMLDataGeneratorTool\",\n\"VCWebDeploymentTool\",\n\"VCManagedWrapperGeneratorTool\",\n\"VCAuxiliaryManagedWrapperGeneratorTool\"\n}\nend\nif platform == \"Xbox360\" then\nreturn {\n\"VCPreBuildEventTool\",\n\"VCCustomBuildTool\",\n\"VCXMLDataGeneratorTool\",\n\"VCWebServiceProxyGeneratorTool\",\n\"VCMIDLTool\",\n\"VCCLCompilerTool\",\n\"VCManagedResourceCompilerTool\",\n\"VCResourceCompilerTool\",\n\"VCPreLinkEventTool\",\n\"VCX360LinkerTool\",\n\"VCALinkTool\",\n\"VCX360ImageTool\",\n\"VCBscMakeTool\",\n\"VCX360DeploymentTool\",\n\"VCPostBuildEventTool\",\n\"DebuggerTool\",\n}\nend\nif platform == \"PS3\" then\nreturn {\n\"VCPreBuildEventTool\",\n\"VCCustomBuildTool\",\n\"VCXMLDataGeneratorTool\",\n\"VCWebServiceProxyGeneratorTool\",\n\"VCMIDLTool\",\n\"VCCLCompilerTool_GCC\",\n\"VCManagedResourceCompilerTool\",\n\"VCResourceCompilerTool\",\n\"VCPreLinkEventTool\",\n\"VCLinkerTool_GCC\",\n\"VCALinkTool\",\n\"VCManifestTool\",\n\"VCXDCMakeTool\",\n\"VCBscMakeTool\",\n\"VCFxCopTool\",\n\"VCAppVerifierTool\",\n\"VCWebDeploymentTool\",\n\"VCPostBuildEventTool\"\n}\nelse\nreturn {\n\"VCPreBuildEventTool\",\n\"VCCustomBuildTool\",\n\"VCXMLDataGeneratorTool\",\n\"VCWebServiceProxyGeneratorTool\",\n\"VCMIDLTool\",\n\"VCCLCompilerTool\",\n\"VCManagedResourceCompilerTool\",\n\"VCResourceCompilerTool\",\n\"VCPreLinkEventTool\",\n\"VCLinkerTool\",\n\"VCALinkTool\",\n\"VCManifestTool\",\n\"VCXDCMakeTool\",\n\"VCBscMakeTool\",\n\"VCFxCopTool\",\n\"VCAppVerifierTool\",\n\"VCWebDeploymentTool\",\n\"VCPostBuildEventTool\"\n}\nend\nend\n\n\n\n\nfunction premake.vs200x_vcproj(prj)\nio.eol = \"\\r\\n\"\n_p('')\n\n-- Write opening project block\n_p(' \"vs2003\" then\n_p('\\tRootNamespace=\"%s\"', prj.name)\nend\n_p('\\tKeyword=\"%s\"', iif(prj.flags.Managed, \"ManagedCProj\", \"Win32Proj\"))\n_p('\\t>')\n\n-- list the target platforms\npremake.vs200x_vcproj_platforms(prj)\n\nif _ACTION > \"vs2003\" then\n_p('\\t')\n_p('\\t')\nend\n\n_p('\\t')\nfor _, cfginfo in ipairs(prj.solution.vstudio_configs) do\nif cfginfo.isreal then\nlocal cfg = premake.getconfig(prj, cfginfo.src_buildcfg, cfginfo.src_platform)\n\n-- Start a configuration\n_p('\\t\\t')\n\nfor _, block in ipairs(getsections(_ACTION, cfginfo.src_platform)) do\n\nif blockmap[block] then\nblockmap[block](cfg)\n\n-- Build event blocks --\nelseif block == \"VCPreBuildEventTool\" then\npremake.vs200x_vcproj_buildstepsblock(\"VCPreBuildEventTool\", cfg.prebuildcommands)\nelseif block == \"VCPreLinkEventTool\" then\npremake.vs200x_vcproj_buildstepsblock(\"VCPreLinkEventTool\", cfg.prelinkcommands)\nelseif block == \"VCPostBuildEventTool\" then\npremake.vs200x_vcproj_buildstepsblock(\"VCPostBuildEventTool\", cfg.postbuildcommands)\n-- End build event blocks --\n\n-- Xbox 360 custom sections --\nelseif block == \"VCX360DeploymentTool\" then\n_p('\\t\\t\\t')\n\nelseif block == \"DebuggerTool\" then\n_p('\\t\\t\\t')\n-- End Xbox 360 custom sections --\n\nelse\n_p('\\t\\t\\t')\nend\n\nend\n\n_p('\\t\\t')\nend\nend\n_p('\\t')\n\n_p('\\t')\n_p('\\t')\n\n_p('\\t')\npremake.walksources(prj, prj.files, _VS.files)\n_p('\\t')\n\n_p('\\t')\n_p('\\t')\n_p('')\nend\n\n\n\n", "--\n\nfunction premake.vs2003_solution(sln)\nio.eol = '\\r\\n'\n\n_p('Microsoft Visual Studio Solution File, Format Version 8.00')\n\n-- Write out the list of project entries\nfor prj in premake.eachproject(sln) do\nlocal projpath = path.translate(path.getrelative(sln.location, _VS.projectfile(prj)))\n_p('Project(\"{%s}\") = \"%s\", \"%s\", \"{%s}\"', _VS.tool(prj), prj.name, projpath, prj.uuid)\n\nlocal deps = premake.getdependencies(prj)\nif #deps > 0 then\n_p('\\tProjectSection(ProjectDependencies) = postProject')\nfor _, dep in ipairs(deps) do\n_p('\\t\\t{%s} = {%s}', dep.uuid, dep.uuid)\nend\n_p('\\tEndProjectSection')\nend\n\n_p('EndProject')\nend\n\n_p('Global')\n_p('\\tGlobalSection(SolutionConfiguration) = preSolution')\nfor _, cfgname in ipairs(sln.configurations) do\n_p('\\t\\t%s = %s', cfgname, cfgname)\nend\n_p('\\tEndGlobalSection')\n\n_p('\\tGlobalSection(ProjectDependencies) = postSolution')\n_p('\\tEndGlobalSection')\n\n_p('\\tGlobalSection(ProjectConfiguration) = postSolution')\nfor prj in premake.eachproject(sln) do\nfor _, cfgname in ipairs(sln.configurations) do\n_p('\\t\\t{%s}.%s.ActiveCfg = %s|%s', prj.uuid, cfgname, cfgname, _VS.arch(prj))\n_p('\\t\\t{%s}.%s.Build.0 = %s|%s', prj.uuid, cfgname, cfgname, _VS.arch(prj))\nend\nend\n_p('\\tEndGlobalSection')\n\n_p('\\tGlobalSection(ExtensibilityGlobals) = postSolution')\n_p('\\tEndGlobalSection')\n_p('\\tGlobalSection(ExtensibilityAddIns) = postSolution')\n_p('\\tEndGlobalSection')\n\n_p('EndGlobal')\nend\n", "--\n\n\nfunction premake.vs2005_solution(sln)\nio.eol = '\\r\\n'\n\n-- Precompute Visual Studio configurations\nsln.vstudio_configs = premake.vstudio_buildconfigs(sln)\n\n-- Mark the file as Unicode\n_p('\\239\\187\\191')\n\n-- Write the solution file version header\n_p('Microsoft Visual Studio Solution File, Format Version %s', iif(_ACTION == 'vs2005', '9.00', '10.00'))\n_p('# Visual Studio %s', iif(_ACTION == 'vs2005', '2005', '2008'))\n\n-- Write out the list of project entries\nfor prj in premake.eachproject(sln) do\n-- Build a relative path from the solution file to the project file\nlocal projpath = path.translate(path.getrelative(sln.location, _VS.projectfile(prj)), \"\\\\\")\n\n_p('Project(\"{%s}\") = \"%s\", \"%s\", \"{%s}\"', _VS.tool(prj), prj.name, projpath, prj.uuid)\nlocal deps = premake.getdependencies(prj)\nif #deps > 0 then\n_p('\\tProjectSection(ProjectDependencies) = postProject')\nfor _, dep in ipairs(deps) do\n_p('\\t\\t{%s} = {%s}', dep.uuid, dep.uuid)\nend\n_p('\\tEndProjectSection')\nend\n_p('EndProject')\nend\n\n_p('Global')\npremake.vs2005_solution_platforms(sln)\npremake.vs2005_solution_project_platforms(sln)\npremake.vs2005_solution_properties(sln)\n_p('EndGlobal')\nend\n\n\n\n\nfunction premake.vs2005_solution_platforms(sln)\n_p('\\tGlobalSection(SolutionConfigurationPlatforms) = preSolution')\nfor _, cfg in ipairs(sln.vstudio_configs) do\n_p('\\t\\t%s = %s', cfg.name, cfg.name)\nend\n_p('\\tEndGlobalSection')\nend\n\n\n\n\nfunction premake.vs2005_solution_project_platforms(sln)\n_p('\\tGlobalSection(ProjectConfigurationPlatforms) = postSolution')\nfor prj in premake.eachproject(sln) do\nfor _, cfg in ipairs(sln.vstudio_configs) do\n\n-- .NET projects always map to the \"Any CPU\" platform (for now, at \n-- least). For C++, \"Any CPU\" and \"Mixed Platforms\" map to the first\n-- C++ compatible target platform in the solution list.\nlocal mapped\nif premake.isdotnetproject(prj) then\nmapped = \"Any CPU\"\nelse\nif cfg.platform == \"Any CPU\" or cfg.platform == \"Mixed Platforms\" then\nmapped = sln.vstudio_configs[3].platform\nelse\nmapped = cfg.platform\nend\nend\n\n_p('\\t\\t{%s}.%s.ActiveCfg = %s|%s', prj.uuid, cfg.name, cfg.buildcfg, mapped)\nif mapped == cfg.platform or cfg.platform == \"Mixed Platforms\" then\n_p('\\t\\t{%s}.%s.Build.0 = %s|%s', prj.uuid, cfg.name, cfg.buildcfg, mapped)\nend\nend\nend\n_p('\\tEndGlobalSection')\nend\n\n\n\n\nfunction premake.vs2005_solution_properties(sln)\n_p('\\tGlobalSection(SolutionProperties) = preSolution')\n_p('\\t\\tHideSolutionNode = FALSE')\n_p('\\tEndGlobalSection')\nend\n", - "--\n\n--\n-- Figure out what elements a particular source code file need in its item\n-- block, based on its build action and any related files in the project.\n-- \n\nfunction getelements(prj, action, fname)\n\nif action == \"Compile\" and fname:endswith(\".cs\") then\nif fname:endswith(\".Designer.cs\") then\n-- is there a matching *.cs file?\nlocal basename = fname:sub(1, -13)\nlocal testname = basename .. \".cs\"\nif premake.findfile(prj, testname) then\nreturn \"Dependency\", testname\nend\n-- is there a matching *.resx file?\ntestname = basename .. \".resx\"\nif premake.findfile(prj, testname) then\nreturn \"AutoGen\", testname\nend\nelse\n-- is there a *.Designer.cs file?\nlocal basename = fname:sub(1, -4)\nlocal testname = basename .. \".Designer.cs\"\nif premake.findfile(prj, testname) then\nreturn \"SubTypeForm\"\nend\nend\nend\n\nif action == \"EmbeddedResource\" and fname:endswith(\".resx\") then\n-- is there a matching *.cs file?\nlocal basename = fname:sub(1, -6)\nlocal testname = path.getname(basename .. \".cs\")\nif premake.findfile(prj, testname) then\nif premake.findfile(prj, basename .. \".Designer.cs\") then\nreturn \"DesignerType\", testname\nelse\nreturn \"Dependency\", testname\nend\nelse\n-- is there a matching *.Designer.cs?\ntestname = path.getname(basename .. \".Designer.cs\")\nif premake.findfile(prj, testname) then\nreturn \"AutoGenerated\"\nend\nend\nend\n\nif action == \"Content\" then\nreturn \"CopyNewest\"\nend\n\nreturn \"None\"\nend\n\n\nfunction premake.vs2005_csproj(prj)\nio.eol = \"\\r\\n\"\n\nlocal vsversion, toolversion\nif _ACTION == \"vs2005\" then\nvsversion = \"8.0.50727\"\ntoolversion = nil\nelseif _ACTION == \"vs2008\" then\nvsversion = \"9.0.50727\"\ntoolversion = \"3.5\"\nend\n\nif toolversion then\n_p('', toolversion)\nelse\n_p('')\nend\n\n_p(' ')\n_p(' %s', premake.esc(prj.solution.configurations[1]))\n_p(' AnyCPU')\n_p(' %s', vsversion)\n_p(' 2.0')\n_p(' {%s}', prj.uuid)\n_p(' %s', premake.csc.getkind(prj))\n_p(' Properties')\n_p(' %s', prj.buildtarget.basename)\n_p(' %s', prj.buildtarget.basename)\n_p(' ')\n\nfor cfg in premake.eachconfig(prj) do\n_p(' ', premake.esc(cfg.name))\nif cfg.flags.Symbols then\n_p(' true')\n_p(' full')\nelse\n_p(' pdbonly')\nend\n_p(' %s', iif(cfg.flags.Optimize or cfg.flags.OptimizeSize or cfg.flags.OptimizeSpeed, \"true\", \"false\"))\n_p(' %s', cfg.buildtarget.directory)\n_p(' %s', table.concat(premake.esc(cfg.defines), \";\"))\n_p(' prompt')\n_p(' 4')\nif cfg.flags.Unsafe then\n_p(' true')\nend\nif cfg.flags.FatalWarnings then\n_p(' true')\nend\n_p(' ')\nend\n\n_p(' ')\nfor _, prj in ipairs(premake.getlinks(prj, \"siblings\", \"object\")) do\n_p(' ', path.translate(path.getrelative(prj.location, _VS.projectfile(prj)), \"\\\\\"))\n_p(' {%s}', prj.uuid)\n_p(' %s', premake.esc(prj.name))\n_p(' ')\nend\nfor _, linkname in ipairs(premake.getlinks(prj, \"system\", \"basename\")) do\n_p(' ', premake.esc(linkname))\nend\n_p(' ')\n\n_p(' ')\nfor fcfg in premake.eachfile(prj) do\nlocal action = premake.csc.getbuildaction(fcfg)\nlocal fname = path.translate(premake.esc(fcfg.name), \"\\\\\")\nlocal elements, dependency = getelements(prj, action, fcfg.name)\nif elements == \"None\" then\n_p(' <%s Include=\"%s\" />', action, fname)\nelse\n_p(' <%s Include=\"%s\">', action, fname)\nif elements == \"AutoGen\" then\n_p(' True')\nelseif elements == \"AutoGenerated\" then\n_p(' Designer')\n_p(' ResXFileCodeGenerator')\n_p(' %s.Designer.cs', premake.esc(path.getbasename(fcfg.name)))\nelseif elements == \"SubTypeDesigner\" then\n_p(' Designer')\nelseif elements == \"SubTypeForm\" then\n_p(' Form')\nelseif elements == \"PreserveNewest\" then\n_p(' PreserveNewest')\nend\nif dependency then\n_p(' %s', path.translate(premake.esc(dependency), \"\\\\\"))\nend\n_p(' ', action)\nend\nend\n_p(' ')\n\n_p(' ')\n_p(' ')\n_p('')\nend\n\n", + "--\n\n--\n-- Figure out what elements a particular source code file need in its item\n-- block, based on its build action and any related files in the project.\n-- \n\nlocal function getelements(prj, action, fname)\n\nif action == \"Compile\" and fname:endswith(\".cs\") then\nif fname:endswith(\".Designer.cs\") then\n-- is there a matching *.cs file?\nlocal basename = fname:sub(1, -13)\nlocal testname = basename .. \".cs\"\nif premake.findfile(prj, testname) then\nreturn \"Dependency\", testname\nend\n-- is there a matching *.resx file?\ntestname = basename .. \".resx\"\nif premake.findfile(prj, testname) then\nreturn \"AutoGen\", testname\nend\nelse\n-- is there a *.Designer.cs file?\nlocal basename = fname:sub(1, -4)\nlocal testname = basename .. \".Designer.cs\"\nif premake.findfile(prj, testname) then\nreturn \"SubTypeForm\"\nend\nend\nend\n\nif action == \"EmbeddedResource\" and fname:endswith(\".resx\") then\n-- is there a matching *.cs file?\nlocal basename = fname:sub(1, -6)\nlocal testname = path.getname(basename .. \".cs\")\nif premake.findfile(prj, testname) then\nif premake.findfile(prj, basename .. \".Designer.cs\") then\nreturn \"DesignerType\", testname\nelse\nreturn \"Dependency\", testname\nend\nelse\n-- is there a matching *.Designer.cs?\ntestname = path.getname(basename .. \".Designer.cs\")\nif premake.findfile(prj, testname) then\nreturn \"AutoGenerated\"\nend\nend\nend\n\nif action == \"Content\" then\nreturn \"CopyNewest\"\nend\n\nreturn \"None\"\nend\n\n\nfunction premake.vs2005_csproj(prj)\nio.eol = \"\\r\\n\"\n\nlocal vsversion, toolversion\nif _ACTION == \"vs2005\" then\nvsversion = \"8.0.50727\"\ntoolversion = nil\nelseif _ACTION == \"vs2008\" then\nvsversion = \"9.0.21022\"\ntoolversion = \"3.5\"\nend\n\nif toolversion then\n_p('', toolversion)\nelse\n_p('')\nend\n\n_p(' ')\n_p(' %s', premake.esc(prj.solution.configurations[1]))\n_p(' AnyCPU')\n_p(' %s', vsversion)\n_p(' 2.0')\n_p(' {%s}', prj.uuid)\n_p(' %s', premake.dotnet.getkind(prj))\n_p(' Properties')\n_p(' %s', prj.buildtarget.basename)\n_p(' %s', prj.buildtarget.basename)\n_p(' ')\n\nfor cfg in premake.eachconfig(prj) do\n_p(' ', premake.esc(cfg.name))\nif cfg.flags.Symbols then\n_p(' true')\n_p(' full')\nelse\n_p(' pdbonly')\nend\n_p(' %s', iif(cfg.flags.Optimize or cfg.flags.OptimizeSize or cfg.flags.OptimizeSpeed, \"true\", \"false\"))\n_p(' %s', cfg.buildtarget.directory)\n_p(' %s', table.concat(premake.esc(cfg.defines), \";\"))\n_p(' prompt')\n_p(' 4')\nif cfg.flags.Unsafe then\n_p(' true')\nend\nif cfg.flags.FatalWarnings then\n_p(' true')\nend\n_p(' ')\nend\n\n_p(' ')\nfor _, ref in ipairs(premake.getlinks(prj, \"siblings\", \"object\")) do\n_p(' ', path.translate(path.getrelative(prj.location, _VS.projectfile(ref)), \"\\\\\"))\n_p(' {%s}', ref.uuid)\n_p(' %s', premake.esc(ref.name))\n_p(' ')\nend\nfor _, linkname in ipairs(premake.getlinks(prj, \"system\", \"basename\")) do\n_p(' ', premake.esc(linkname))\nend\n_p(' ')\n\n_p(' ')\nfor fcfg in premake.eachfile(prj) do\nlocal action = premake.dotnet.getbuildaction(fcfg)\nlocal fname = path.translate(premake.esc(fcfg.name), \"\\\\\")\nlocal elements, dependency = getelements(prj, action, fcfg.name)\nif elements == \"None\" then\n_p(' <%s Include=\"%s\" />', action, fname)\nelse\n_p(' <%s Include=\"%s\">', action, fname)\nif elements == \"AutoGen\" then\n_p(' True')\nelseif elements == \"AutoGenerated\" then\n_p(' Designer')\n_p(' ResXFileCodeGenerator')\n_p(' %s.Designer.cs', premake.esc(path.getbasename(fcfg.name)))\nelseif elements == \"SubTypeDesigner\" then\n_p(' Designer')\nelseif elements == \"SubTypeForm\" then\n_p(' Form')\nelseif elements == \"PreserveNewest\" then\n_p(' PreserveNewest')\nend\nif dependency then\n_p(' %s', path.translate(premake.esc(dependency), \"\\\\\"))\nend\n_p(' ', action)\nend\nend\n_p(' ')\n\n_p(' ')\n_p(' ')\n_p('')\n\nend\n\n", "--\n\nfunction premake.vs2005_csproj_user(prj)\nio.eol = \"\\r\\n\"\n\n_p('')\n_p(' ')\n\nlocal refpaths = table.translate(prj.libdirs, function(v) return path.getabsolute(prj.location .. \"/\" .. v) end)\n_p(' %s', path.translate(table.concat(refpaths, \";\"), \"\\\\\"))\n_p(' ')\n_p('')\n\nend\n", "--\n\n\n\nlocal function cleantemplatefiles(this, templates)\nif (templates) then\nfor _,tmpl in ipairs(templates) do\nlocal fname = premake.getoutputname(this, tmpl[1])\nos.remove(fname)\nend\nend\nend\n\n\n\nnewaction {\ntrigger = \"clean\",\ndescription = \"Remove all binaries and generated files\",\ntargetstyle = \"windows\",\n\nexecute = function()\nlocal solutions = { }\nlocal projects = { }\nlocal targets = { }\n\nlocal cwd = os.getcwd()\nlocal function rebase(parent, dir)\nreturn path.rebase(dir, parent.location, cwd)\nend\n\n-- Walk the tree. Build a list of object names to pass to the cleaners,\n-- and delete any toolset agnostic files along the way.\nfor _,sln in ipairs(_SOLUTIONS) do\ntable.insert(solutions, path.join(sln.location, sln.name))\n\nfor prj in premake.eachproject(sln) do\ntable.insert(projects, path.join(prj.location, prj.name))\n\nif (prj.objectsdir) then\nos.rmdir(rebase(prj, prj.objectsdir))\nend\n\nfor cfg in premake.eachconfig(prj) do\ntable.insert(targets, path.join(rebase(cfg, cfg.buildtarget.directory), cfg.buildtarget.basename))\n\n-- remove all possible permutations of the target binary\nos.remove(rebase(cfg, premake.gettarget(cfg, \"build\", \"windows\").fullpath))\nos.remove(rebase(cfg, premake.gettarget(cfg, \"build\", \"linux\", \"linux\").fullpath))\nos.remove(rebase(cfg, premake.gettarget(cfg, \"build\", \"linux\", \"macosx\").fullpath))\nif (cfg.kind == \"WindowedApp\") then\nos.rmdir(rebase(cfg, premake.gettarget(cfg, \"build\", \"linux\", \"linux\").fullpath .. \".app\"))\nend\n\n-- if there is an import library, remove that too\nos.remove(rebase(cfg, premake.gettarget(cfg, \"link\", \"windows\").fullpath))\nos.remove(rebase(cfg, premake.gettarget(cfg, \"link\", \"linux\").fullpath))\n\nos.rmdir(rebase(cfg, cfg.objectsdir))\nend\nend\nend\n\n-- Walk the tree again. Delete templated and toolset-specific files\nfor _,action in pairs(premake.actions) do\nfor _,sln in ipairs(_SOLUTIONS) do\ncleantemplatefiles(sln, action.solutiontemplates)\nfor prj in premake.eachproject(sln) do\ncleantemplatefiles(prj, action.projecttemplates)\nend\nend\n\nif (type(action.onclean) == \"function\") then\naction.onclean(solutions, projects, targets)\nend\nend\nend,\n}\n", "--\n\n\nnewaction {\ntrigger = \"codeblocks\",\nshortname = \"Code::Blocks\",\ndescription = \"Code::Blocks Studio\",\n\nvalid_kinds = { \"ConsoleApp\", \"WindowedApp\", \"StaticLib\", \"SharedLib\" },\n\nvalid_languages = { \"C\", \"C++\" },\n\nvalid_tools = {\ncc = { \"gcc\", \"ow\" },\n},\n\nsolutiontemplates = {\n{ \".workspace\", premake.codeblocks_workspace },\n},\n\nprojecttemplates = {\n{ \".cbp\", premake.codeblocks_cbp },\n},\n\nonclean = function(solutions, projects, targets)\nfor _,name in ipairs(projects) do\nos.remove(name .. \".depend\")\nos.remove(name .. \".layout\")\nend\nend\n}\n", - "--\n\nnewaction {\ntrigger = \"codelite\",\nshortname = \"CodeLite\",\ndescription = \"CodeLite (experimental)\",\ntargetstyle = \"linux\",\n\nvalid_kinds = { \"ConsoleApp\", \"WindowedApp\", \"StaticLib\", \"SharedLib\" },\n\nvalid_languages = { \"C\", \"C++\" },\n\nvalid_tools = {\ncc = { \"gcc\" },\n},\n\nsolutiontemplates = {\n{ \".workspace\", premake.codelite_workspace },\n},\n\nprojecttemplates = {\n{ \".project\", premake.codelite_project },\n},\n\nonclean = function(solutions, projects, targets)\nfor _,name in ipairs(solutions) do\nos.remove(name .. \"_wsp.mk\")\nos.remove(name .. \".tags\")\nend\nfor _,name in ipairs(projects) do\nos.remove(name .. \".mk\")\nos.remove(name .. \".list\")\nos.remove(name .. \".out\")\nend\nend\n}\n", - "--\n\n_MAKE = { }\n\n\n\nfunction _MAKE.esc(value)\nif (type(value) == \"table\") then\nlocal result = { }\nfor _,v in ipairs(value) do\ntable.insert(result, _MAKE.esc(v))\nend\nreturn result\nelse\nlocal result\nresult = value:gsub(\" \", \"\\\\ \")\nresult = result:gsub(\"\\\\\", \"\\\\\\\\\")\nreturn result\nend\nend\n\n\n\n\nfunction _MAKE.getmakefilename(this, searchprjs)\n-- how many projects/solutions use this location?\nlocal count = 0\nfor _,sln in ipairs(_SOLUTIONS) do\nif (sln.location == this.location) then count = count + 1 end\nif (searchprjs) then\nfor _,prj in ipairs(sln.projects) do\nif (prj.location == this.location) then count = count + 1 end\nend\nend\nend\n\nif (count == 1) then\nreturn \"Makefile\"\nelse\nreturn this.name .. \".make\"\nend\nend\n\n\n\nfunction _MAKE.getnames(tbl)\nlocal result = table.extract(tbl, \"name\")\nfor k,v in pairs(result) do\nresult[k] = _MAKE.esc(v)\nend\nreturn result\nend\n\n\n\nnewaction {\ntrigger = \"gmake\",\nshortname = \"GNU Make\",\ndescription = \"GNU makefiles for POSIX, MinGW, and Cygwin\",\ntargetstyle = \"linux\",\n\nvalid_kinds = { \"ConsoleApp\", \"WindowedApp\", \"StaticLib\", \"SharedLib\" },\n\nvalid_languages = { \"C\", \"C++\", \"C#\" },\n\nvalid_tools = {\ncc = { \"gcc\" },\ndotnet = { \"mono\", \"ms\", \"pnet\" },\n},\n\nsolutiontemplates = {\n{\nfunction(this) return _MAKE.getmakefilename(this, false) end, \npremake.make_solution\n},\n},\n\nprojecttemplates = {\n{ \nfunction(this) return _MAKE.getmakefilename(this, true) end, \npremake.make_cpp,\nfunction(this) return this.language == \"C\" or this.language == \"C++\" end\n},\n{\nfunction(this) return _MAKE.getmakefilename(this, true) end,\npremake.make_csharp,\nfunction(this) return this.language == \"C#\" end\n},\n},\n}\n", - "--\n\n_VS = { }\n\n\n\npremake.vstudio_platforms = { \nany = \"Any CPU\", \nmixed = \"Mixed Platforms\", \nNative = \"Win32\",\nx32 = \"Win32\", \nx64 = \"x64\",\nPS3 = \"PS3\",\nXbox360 = \"Xbox 360\",\n}\n\n\n\n\nfunction _VS.arch(prj)\nif (prj.language == \"C#\") then\nif (_ACTION < \"vs2005\") then\nreturn \".NET\"\nelse\nreturn \"Any CPU\"\nend\nelse\nreturn \"Win32\"\nend\nend\n\n\n\n\nfunction _VS.bool(value)\nif (_ACTION < \"vs2005\") then\nreturn iif(value, \"TRUE\", \"FALSE\")\nelse\nreturn iif(value, \"true\", \"false\")\nend\nend\n\n\n\n\nfunction premake.vstudio_buildconfigs(sln)\nlocal cfgs = { }\n\nlocal platforms = premake.filterplatforms(sln, premake.vstudio_platforms, \"Native\")\n\n-- .NET projects add \"Any CPU\", mixed mode solutions add \"Mixed Platforms\"\nlocal hascpp = premake.hascppproject(sln)\nlocal hasdotnet = premake.hasdotnetproject(sln)\nif hasdotnet then\ntable.insert(platforms, 1, \"any\")\nend\nif hasdotnet and hascpp then\ntable.insert(platforms, 2, \"mixed\")\nend\n\nfor _, buildcfg in ipairs(sln.configurations) do\nfor _, platform in ipairs(platforms) do\nlocal entry = { }\nentry.src_platform = platform\n\n-- PS3 is funky and needs special handling; it's more of a build\n-- configuration than a platform from Visual Studio's point of view\nif platform ~= \"PS3\" then\nentry.buildcfg = buildcfg\nentry.platform = premake.vstudio_platforms[platform]\nelse\nentry.buildcfg = platform .. \" \" .. buildcfg\nentry.platform = \"Win32\"\nend\n\n-- create a name the way VS likes it\nentry.name = entry.buildcfg .. \"|\" .. entry.platform\n\n-- flag the \"fake\" platforms added for .NET\nentry.isreal = (platform ~= \"any\" and platform ~= \"mixed\")\n\ntable.insert(cfgs, entry)\nend\nend\n\nreturn cfgs\nend\n\n\n\n\nfunction _VS.cfgtype(cfg)\nif (cfg.kind == \"SharedLib\") then\nreturn 2\nelseif (cfg.kind == \"StaticLib\") then\nreturn 4\nelse\nreturn 1\nend\nend\n\n\n\n\nfunction _VS.onclean(solutions, projects, targets)\nfor _,name in ipairs(solutions) do\nos.remove(name .. \".suo\")\nos.remove(name .. \".ncb\")\nend\n\nfor _,name in ipairs(projects) do\nos.remove(name .. \".csproj.user\")\nos.remove(name .. \".csproj.webinfo\")\n\nlocal files = os.matchfiles(name .. \".vcproj.*.user\", name .. \".csproj.*.user\")\nfor _, fname in ipairs(files) do\nos.remove(fname)\nend\nend\n\nfor _,name in ipairs(targets) do\nos.remove(name .. \".pdb\")\nos.remove(name .. \".idb\")\nos.remove(name .. \".ilk\")\nos.remove(name .. \".vshost.exe\")\nos.remove(name .. \".exe.manifest\")\nend\nend\n\n\n\n\nlocal function output(indent, value)\nio.write(indent .. value .. \"\\r\\n\")\nend\n\nlocal function attrib(indent, name, value)\nio.write(indent .. \"\\t\" .. name .. '=\"' .. value .. '\"\\r\\n')\nend\n\nfunction _VS.files(prj, fname, state, nestlevel)\nlocal indent = string.rep(\"\\t\", nestlevel + 2)\n\nif (state == \"GroupStart\") then\noutput(indent, \"\")\n\nelseif (state == \"GroupEnd\") then\noutput(indent, \"\")\n\nelse\noutput(indent, \"\")\nif (not prj.flags.NoPCH and prj.pchsource == fname) then\nfor _, cfgname in ipairs(prj.configurations) do\noutput(indent, \"\\t\")\noutput(indent, \"\\t\\t\")\noutput(indent, \"\\t\")\nend\nend\noutput(indent, \"\")\nend\nend\n\n\n\n\nfunction _VS.optimization(cfg)\nlocal result = 0\nfor _, value in ipairs(cfg.flags) do\nif (value == \"Optimize\") then\nresult = 3\nelseif (value == \"OptimizeSize\") then\nresult = 1\nelseif (value == \"OptimizeSpeed\") then\nresult = 2\nend\nend\nreturn result\nend\n\n\n\n\nfunction _VS.projectfile(prj)\nlocal extension\nif (prj.language == \"C#\") then\nextension = \".csproj\"\nelse\nextension = \".vcproj\"\nend\n\nlocal fname = path.join(prj.location, prj.name)\nreturn fname..extension\nend\n\n\n\n\nfunction _VS.runtime(cfg)\nlocal debugbuild = (_VS.optimization(cfg) == 0)\nif (cfg.flags.StaticRuntime) then\nreturn iif(debugbuild, 1, 0)\nelse\nreturn iif(debugbuild, 3, 2)\nend\nend\n\n\n\n\nfunction _VS.symbols(cfg)\nif (not cfg.flags.Symbols) then\nreturn 0\nelse\n-- Edit-and-continue does't work if optimizing or managed C++\nif (cfg.flags.NoEditAndContinue or _VS.optimization(cfg) ~= 0 or cfg.flags.Managed) then\nreturn 3\nelse\nreturn 4\nend\nend\nend\n\n\n\n\nfunction _VS.tool(prj)\nif (prj.language == \"C#\") then\nreturn \"FAE04EC0-301F-11D3-BF4B-00C04F79EFBC\"\nelse\nreturn \"8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942\"\nend\nend\n\n\n\n\n\nnewaction {\ntrigger = \"vs2002\",\nshortname = \"Visual Studio 2002\",\ndescription = \"Microsoft Visual Studio 2002\",\ntargetstyle = \"windows\",\n\nvalid_kinds = { \"ConsoleApp\", \"WindowedApp\", \"StaticLib\", \"SharedLib\" },\n\nvalid_languages = { \"C\", \"C++\", \"C#\" },\n\nsolutiontemplates = {\n{ \".sln\", premake.vs2002_solution },\n},\n\nprojecttemplates = {\n{ \".vcproj\", premake.vs200x_vcproj, function(this) return this.language ~= \"C#\" end },\n{ \".csproj\", premake.vs2002_csproj, function(this) return this.language == \"C#\" end },\n{ \".csproj.user\", premake.vs2002_csproj_user, function(this) return this.language == \"C#\" end },\n},\n\nonclean = _VS.onclean,\n}\n\nnewaction {\ntrigger = \"vs2003\",\nshortname = \"Visual Studio 2003\",\ndescription = \"Microsoft Visual Studio 2003\",\ntargetstyle = \"windows\",\n\nvalid_kinds = { \"ConsoleApp\", \"WindowedApp\", \"StaticLib\", \"SharedLib\" },\n\nvalid_languages = { \"C\", \"C++\", \"C#\" },\n\nsolutiontemplates = {\n{ \".sln\", premake.vs2003_solution },\n},\n\nprojecttemplates = {\n{ \".vcproj\", premake.vs200x_vcproj, function(this) return this.language ~= \"C#\" end },\n{ \".csproj\", premake.vs2002_csproj, function(this) return this.language == \"C#\" end },\n{ \".csproj.user\", premake.vs2002_csproj_user, function(this) return this.language == \"C#\" end },\n},\n\nonclean = _VS.onclean,\n}\n\nnewaction {\ntrigger = \"vs2005\",\nshortname = \"Visual Studio 2005\",\ndescription = \"Microsoft Visual Studio 2005 (SharpDevelop, MonoDevelop)\",\ntargetstyle = \"windows\",\n\nvalid_kinds = { \"ConsoleApp\", \"WindowedApp\", \"StaticLib\", \"SharedLib\" },\n\nvalid_languages = { \"C\", \"C++\", \"C#\" },\n\nsolutiontemplates = {\n{ \".sln\", premake.vs2005_solution },\n},\n\nprojecttemplates = {\n{ \".vcproj\", premake.vs200x_vcproj, function(this) return this.language ~= \"C#\" end },\n{ \".csproj\", premake.vs2005_csproj, function(this) return this.language == \"C#\" end },\n{ \".csproj.user\", premake.vs2005_csproj_user, function(this) return this.language == \"C#\" end },\n},\n\nonclean = _VS.onclean,\n}\n\nnewaction {\ntrigger = \"vs2008\",\nshortname = \"Visual Studio 2008\",\ndescription = \"Microsoft Visual Studio 2008\",\ntargetstyle = \"windows\",\n\nvalid_kinds = { \"ConsoleApp\", \"WindowedApp\", \"StaticLib\", \"SharedLib\" },\n\nvalid_languages = { \"C\", \"C++\", \"C#\" },\n\nsolutiontemplates = {\n{ \".sln\", premake.vs2005_solution },\n},\n\nprojecttemplates = {\n{ \".vcproj\", premake.vs200x_vcproj, function(this) return this.language ~= \"C#\" end },\n{ \".csproj\", premake.vs2005_csproj, function(this) return this.language == \"C#\" end },\n{ \".csproj.user\", premake.vs2005_csproj_user, function(this) return this.language == \"C#\" end },\n},\n\nonclean = _VS.onclean,\n}\n", + "--\n\nnewaction {\ntrigger = \"codelite\",\nshortname = \"CodeLite\",\ndescription = \"CodeLite (experimental)\",\n\nvalid_kinds = { \"ConsoleApp\", \"WindowedApp\", \"StaticLib\", \"SharedLib\" },\n\nvalid_languages = { \"C\", \"C++\" },\n\nvalid_tools = {\ncc = { \"gcc\" },\n},\n\nsolutiontemplates = {\n{ \".workspace\", premake.codelite_workspace },\n},\n\nprojecttemplates = {\n{ \".project\", premake.codelite_project },\n},\n\nonclean = function(solutions, projects, targets)\nfor _,name in ipairs(solutions) do\nos.remove(name .. \"_wsp.mk\")\nos.remove(name .. \".tags\")\nend\nfor _,name in ipairs(projects) do\nos.remove(name .. \".mk\")\nos.remove(name .. \".list\")\nos.remove(name .. \".out\")\nend\nend\n}\n", + "--\n\n_MAKE = { }\n\n\n\nfunction _MAKE.esc(value)\nif (type(value) == \"table\") then\nlocal result = { }\nfor _,v in ipairs(value) do\ntable.insert(result, _MAKE.esc(v))\nend\nreturn result\nelse\nlocal result\nresult = value:gsub(\" \", \"\\\\ \")\nresult = result:gsub(\"\\\\\", \"\\\\\\\\\")\nreturn result\nend\nend\n\n\n\n\nfunction _MAKE.getmakefilename(this, searchprjs)\n-- how many projects/solutions use this location?\nlocal count = 0\nfor _,sln in ipairs(_SOLUTIONS) do\nif (sln.location == this.location) then count = count + 1 end\nif (searchprjs) then\nfor _,prj in ipairs(sln.projects) do\nif (prj.location == this.location) then count = count + 1 end\nend\nend\nend\n\nif (count == 1) then\nreturn \"Makefile\"\nelse\nreturn this.name .. \".make\"\nend\nend\n\n\n\nfunction _MAKE.getnames(tbl)\nlocal result = table.extract(tbl, \"name\")\nfor k,v in pairs(result) do\nresult[k] = _MAKE.esc(v)\nend\nreturn result\nend\n\n\n\nnewaction {\ntrigger = \"gmake\",\nshortname = \"GNU Make\",\ndescription = \"GNU makefiles for POSIX, MinGW, and Cygwin\",\n\nvalid_kinds = { \"ConsoleApp\", \"WindowedApp\", \"StaticLib\", \"SharedLib\" },\n\nvalid_languages = { \"C\", \"C++\", \"C#\" },\n\nvalid_tools = {\ncc = { \"gcc\" },\ndotnet = { \"mono\", \"msnet\", \"pnet\" },\n},\n\nsolutiontemplates = {\n{\nfunction(this) return _MAKE.getmakefilename(this, false) end, \npremake.make_solution\n},\n},\n\nprojecttemplates = {\n{ \nfunction(this) return _MAKE.getmakefilename(this, true) end, \npremake.make_cpp,\nfunction(this) return this.language == \"C\" or this.language == \"C++\" end\n},\n{\nfunction(this) return _MAKE.getmakefilename(this, true) end,\npremake.make_csharp,\nfunction(this) return this.language == \"C#\" end\n},\n},\n}\n", + "--\n\n_VS = { }\n\n\n\npremake.vstudio_platforms = { \nany = \"Any CPU\", \nmixed = \"Mixed Platforms\", \nNative = \"Win32\",\nx32 = \"Win32\", \nx64 = \"x64\",\nPS3 = \"PS3\",\nXbox360 = \"Xbox 360\",\n}\n\n\n\n\nfunction _VS.arch(prj)\nif (prj.language == \"C#\") then\nif (_ACTION < \"vs2005\") then\nreturn \".NET\"\nelse\nreturn \"Any CPU\"\nend\nelse\nreturn \"Win32\"\nend\nend\n\n\n\n\nfunction _VS.bool(value)\nif (_ACTION < \"vs2005\") then\nreturn iif(value, \"TRUE\", \"FALSE\")\nelse\nreturn iif(value, \"true\", \"false\")\nend\nend\n\n\n\n\nfunction premake.vstudio_buildconfigs(sln)\nlocal cfgs = { }\n\nlocal platforms = premake.filterplatforms(sln, premake.vstudio_platforms, \"Native\")\n\n-- .NET projects add \"Any CPU\", mixed mode solutions add \"Mixed Platforms\"\nlocal hascpp = premake.hascppproject(sln)\nlocal hasdotnet = premake.hasdotnetproject(sln)\nif hasdotnet then\ntable.insert(platforms, 1, \"any\")\nend\nif hasdotnet and hascpp then\ntable.insert(platforms, 2, \"mixed\")\nend\n\nfor _, buildcfg in ipairs(sln.configurations) do\nfor _, platform in ipairs(platforms) do\nlocal entry = { }\nentry.src_buildcfg = buildcfg\nentry.src_platform = platform\n\n-- PS3 is funky and needs special handling; it's more of a build\n-- configuration than a platform from Visual Studio's point of view\nif platform ~= \"PS3\" then\nentry.buildcfg = buildcfg\nentry.platform = premake.vstudio_platforms[platform]\nelse\nentry.buildcfg = platform .. \" \" .. buildcfg\nentry.platform = \"Win32\"\nend\n\n-- create a name the way VS likes it\nentry.name = entry.buildcfg .. \"|\" .. entry.platform\n\n-- flag the \"fake\" platforms added for .NET\nentry.isreal = (platform ~= \"any\" and platform ~= \"mixed\")\n\ntable.insert(cfgs, entry)\nend\nend\n\nreturn cfgs\nend\n\n\n\n\nfunction _VS.cfgtype(cfg)\nif (cfg.kind == \"SharedLib\") then\nreturn 2\nelseif (cfg.kind == \"StaticLib\") then\nreturn 4\nelse\nreturn 1\nend\nend\n\n\n\n\nfunction _VS.onclean(solutions, projects, targets)\nfor _,name in ipairs(solutions) do\nos.remove(name .. \".suo\")\nos.remove(name .. \".ncb\")\nend\n\nfor _,name in ipairs(projects) do\nos.remove(name .. \".csproj.user\")\nos.remove(name .. \".csproj.webinfo\")\n\nlocal files = os.matchfiles(name .. \".vcproj.*.user\", name .. \".csproj.*.user\")\nfor _, fname in ipairs(files) do\nos.remove(fname)\nend\nend\n\nfor _,name in ipairs(targets) do\nos.remove(name .. \".pdb\")\nos.remove(name .. \".idb\")\nos.remove(name .. \".ilk\")\nos.remove(name .. \".vshost.exe\")\nos.remove(name .. \".exe.manifest\")\nend\nend\n\n\n\n\nlocal function output(indent, value)\nio.write(indent .. value .. \"\\r\\n\")\nend\n\nlocal function attrib(indent, name, value)\nio.write(indent .. \"\\t\" .. name .. '=\"' .. value .. '\"\\r\\n')\nend\n\nfunction _VS.files(prj, fname, state, nestlevel)\nlocal indent = string.rep(\"\\t\", nestlevel + 2)\n\nif (state == \"GroupStart\") then\noutput(indent, \"\")\n\nelseif (state == \"GroupEnd\") then\noutput(indent, \"\")\n\nelse\noutput(indent, \"\")\nif (not prj.flags.NoPCH and prj.pchsource == fname) then\nfor _, cfgname in ipairs(prj.configurations) do\noutput(indent, \"\\t\")\noutput(indent, \"\\t\\t\")\noutput(indent, \"\\t\")\nend\nend\noutput(indent, \"\")\nend\nend\n\n\n\n\nfunction _VS.optimization(cfg)\nlocal result = 0\nfor _, value in ipairs(cfg.flags) do\nif (value == \"Optimize\") then\nresult = 3\nelseif (value == \"OptimizeSize\") then\nresult = 1\nelseif (value == \"OptimizeSpeed\") then\nresult = 2\nend\nend\nreturn result\nend\n\n\n\n\nfunction _VS.projectfile(prj)\nlocal extension\nif (prj.language == \"C#\") then\nextension = \".csproj\"\nelse\nextension = \".vcproj\"\nend\n\nlocal fname = path.join(prj.location, prj.name)\nreturn fname..extension\nend\n\n\n\n\nfunction _VS.runtime(cfg)\nlocal debugbuild = (_VS.optimization(cfg) == 0)\nif (cfg.flags.StaticRuntime) then\nreturn iif(debugbuild, 1, 0)\nelse\nreturn iif(debugbuild, 3, 2)\nend\nend\n\n\n\n\nfunction _VS.symbols(cfg)\nif (not cfg.flags.Symbols) then\nreturn 0\nelse\n-- Edit-and-continue does't work if optimizing or managed C++\nif (cfg.flags.NoEditAndContinue or _VS.optimization(cfg) ~= 0 or cfg.flags.Managed) then\nreturn 3\nelse\nreturn 4\nend\nend\nend\n\n\n\n\nfunction _VS.tool(prj)\nif (prj.language == \"C#\") then\nreturn \"FAE04EC0-301F-11D3-BF4B-00C04F79EFBC\"\nelse\nreturn \"8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942\"\nend\nend\n\n\n\n\n\nnewaction {\ntrigger = \"vs2002\",\nshortname = \"Visual Studio 2002\",\ndescription = \"Microsoft Visual Studio 2002\",\ntargetstyle = \"windows\",\n\nvalid_kinds = { \"ConsoleApp\", \"WindowedApp\", \"StaticLib\", \"SharedLib\" },\n\nvalid_languages = { \"C\", \"C++\", \"C#\" },\n\nvalid_tools = {\ncc = { \"msc\" },\ndotnet = { \"msnet\" },\n},\n\nsolutiontemplates = {\n{ \".sln\", premake.vs2002_solution },\n},\n\nprojecttemplates = {\n{ \".vcproj\", premake.vs200x_vcproj, function(this) return this.language ~= \"C#\" end },\n{ \".csproj\", premake.vs2002_csproj, function(this) return this.language == \"C#\" end },\n{ \".csproj.user\", premake.vs2002_csproj_user, function(this) return this.language == \"C#\" end },\n},\n\nonclean = _VS.onclean,\n}\n\nnewaction {\ntrigger = \"vs2003\",\nshortname = \"Visual Studio 2003\",\ndescription = \"Microsoft Visual Studio 2003\",\ntargetstyle = \"windows\",\n\nvalid_kinds = { \"ConsoleApp\", \"WindowedApp\", \"StaticLib\", \"SharedLib\" },\n\nvalid_languages = { \"C\", \"C++\", \"C#\" },\n\nvalid_tools = {\ncc = { \"msc\" },\ndotnet = { \"msnet\" },\n},\n\nsolutiontemplates = {\n{ \".sln\", premake.vs2003_solution },\n},\n\nprojecttemplates = {\n{ \".vcproj\", premake.vs200x_vcproj, function(this) return this.language ~= \"C#\" end },\n{ \".csproj\", premake.vs2002_csproj, function(this) return this.language == \"C#\" end },\n{ \".csproj.user\", premake.vs2002_csproj_user, function(this) return this.language == \"C#\" end },\n},\n\nonclean = _VS.onclean,\n}\n\nnewaction {\ntrigger = \"vs2005\",\nshortname = \"Visual Studio 2005\",\ndescription = \"Microsoft Visual Studio 2005 (SharpDevelop, MonoDevelop)\",\ntargetstyle = \"windows\",\n\nvalid_kinds = { \"ConsoleApp\", \"WindowedApp\", \"StaticLib\", \"SharedLib\" },\n\nvalid_languages = { \"C\", \"C++\", \"C#\" },\n\nvalid_tools = {\ncc = { \"msc\" },\ndotnet = { \"msnet\" },\n},\n\nsolutiontemplates = {\n{ \".sln\", premake.vs2005_solution },\n},\n\nprojecttemplates = {\n{ \".vcproj\", premake.vs200x_vcproj, function(this) return this.language ~= \"C#\" end },\n{ \".csproj\", premake.vs2005_csproj, function(this) return this.language == \"C#\" end },\n{ \".csproj.user\", premake.vs2005_csproj_user, function(this) return this.language == \"C#\" end },\n},\n\nonclean = _VS.onclean,\n}\n\nnewaction {\ntrigger = \"vs2008\",\nshortname = \"Visual Studio 2008\",\ndescription = \"Microsoft Visual Studio 2008\",\ntargetstyle = \"windows\",\n\nvalid_kinds = { \"ConsoleApp\", \"WindowedApp\", \"StaticLib\", \"SharedLib\" },\n\nvalid_languages = { \"C\", \"C++\", \"C#\" },\n\nvalid_tools = {\ncc = { \"msc\" },\ndotnet = { \"msnet\" },\n},\n\nsolutiontemplates = {\n{ \".sln\", premake.vs2005_solution },\n},\n\nprojecttemplates = {\n{ \".vcproj\", premake.vs200x_vcproj, function(this) return this.language ~= \"C#\" end },\n{ \".csproj\", premake.vs2005_csproj, function(this) return this.language == \"C#\" end },\n{ \".csproj.user\", premake.vs2005_csproj_user, function(this) return this.language == \"C#\" end },\n},\n\nonclean = _VS.onclean,\n}\n", "--\n\n\nlocal scriptfile = \"premake4.lua\"\nlocal shorthelp = \"Type 'premake4 --help' for help\"\nlocal versionhelp = \"premake4 (Premake Build Script Generator) %s\"\n\n\n\n\nlocal function doaction(name)\nlocal action = premake.actions[name]\n\n-- walk the session objects and generate files from the templates\nlocal function generatefiles(this, templates)\nif (not templates) then return end\nfor _,tmpl in ipairs(templates) do\nlocal output = true\nif (tmpl[3]) then\noutput = tmpl[3](this)\nend\nif (output) then\nlocal fname = path.getrelative(os.getcwd(), premake.getoutputname(this, tmpl[1]))\nprintf(\"Generating %s...\", fname)\nlocal f, err = io.open(fname, \"wb\")\nif (not f) then\nerror(err, 0)\nend\nio.output(f)\n\n-- call the template function to generate the output\ntmpl[2](this)\n\nio.output():close()\nend\nend\nend\n\nfor _,sln in ipairs(_SOLUTIONS) do\ngeneratefiles(sln, action.solutiontemplates)\nfor prj in premake.eachproject(sln) do\ngeneratefiles(prj, action.projecttemplates)\nend\nend\n\nif (action.execute) then\naction.execute()\nend\nend\n\n\n\nlocal function injectplatform(platform)\nif not platform then return true end\nplatform = premake.checkvalue(platform, premake.fields.platforms.allowed)\n\nfor _, sln in ipairs(_SOLUTIONS) do\nlocal platforms = sln.platforms or { }\n\n-- an empty table is equivalent to a native build\nif #platforms == 0 then\ntable.insert(platforms, \"Native\")\nend\n\n-- the solution must provide a native build in order to support this feature\nif not table.contains(platforms, \"Native\") then\nreturn false, sln.name .. \" does not target native platform\\nNative platform settings are required for the --platform feature.\"\nend\n\n-- add it to the end of the list, if it isn't in there already\nif not table.contains(platforms, platform) then\ntable.insert(platforms, platform)\nend\n\nsln.platforms = platforms\nend\n\nreturn true\nend\n\n\n\nfunction _premake_main(scriptpath)\n\n-- if running off the disk (in debug mode), load everything \n-- listed in _manifest.lua; the list divisions make sure\n-- everything gets initialized in the proper order.\n\nif (scriptpath) then\nlocal scripts = dofile(scriptpath .. \"/_manifest.lua\")\nfor _,v in ipairs(scripts) do\ndofile(scriptpath .. \"/\" .. v)\nend\nend\n\n\n-- If there is a project script available, run it to get the\n-- project information, available options and actions, etc.\n\nlocal fname = _OPTIONS[\"file\"] or scriptfile\nif (os.isfile(fname)) then\ndofile(fname)\nend\n\n\n-- Process special options\n\nif (_OPTIONS[\"version\"]) then\nprintf(versionhelp, _PREMAKE_VERSION)\nreturn 1\nend\n\nif (_OPTIONS[\"help\"]) then\npremake.showhelp()\nreturn 1\nend\n\n\n-- If no action was specified, show a short help message\n\nif (not _ACTION) then\nprint(shorthelp)\nreturn 1\nend\n\n\n-- If there wasn't a project script I've got to bail now\n\nif (not os.isfile(fname)) then\nerror(\"No Premake script (\"..scriptfile..\") found!\", 2)\nend\n\n\n-- Validate the command-line arguments. This has to happen after the\n-- script has run to allow for project-specific options\n\nif (not premake.actions[_ACTION]) then\nerror(\"Error: no such action '\".._ACTION..\"'\", 0)\nend\n\nok, err = premake.checkoptions()\nif (not ok) then error(\"Error: \" .. err, 0) end\n\n\n-- Sanity check the current project setup\n\nok, err = premake.checktools()\nif (not ok) then error(\"Error: \" .. err, 0) end\n\n\n-- If a platform was specified on the command line, inject it now\n\nok, err = injectplatform(_OPTIONS[\"platform\"])\nif (not ok) then error(\"Error: \" .. err, 0) end\n\n\n-- work-in-progress: build the configurations\nprint(\"Building configurations...\")\npremake.buildconfigs()\n\nok, err = premake.checkprojects()\nif (not ok) then error(\"Error: \" .. err, 0) end\n\n\n-- Hand over control to the action\nprintf(\"Running action '%s'...\", _ACTION)\ndoaction(_ACTION)\n\nprint(\"Done.\")\nreturn 0\n\nend\n", 0 }; diff --git a/src/tools/csc.lua b/src/tools/dotnet.lua similarity index 83% rename from src/tools/csc.lua rename to src/tools/dotnet.lua index 8997aa43..4ec2c2ad 100644 --- a/src/tools/csc.lua +++ b/src/tools/dotnet.lua @@ -1,11 +1,12 @@ -- --- csc.lua +-- dotnet.lua -- Interface for the C# compilers, all of which are flag compatible. -- Copyright (c) 2002-2008 Jason Perkins and the Premake project -- - premake.csc = { } + premake.dotnet = { } + premake.dotnet.targetstyle = "windows" -- @@ -27,7 +28,7 @@ -- Return the default build action for a given file, based on the file extension. -- - function premake.csc.getbuildaction(fcfg) + function premake.dotnet.getbuildaction(fcfg) local ext = path.getextension(fcfg.name):lower() if fcfg.buildaction == "Compile" or ext == ".cs" then return "Compile" @@ -46,8 +47,8 @@ -- Returns the compiler filename (they all use the same arguments) -- - function premake.csc.getcompilervar(cfg) - if (_OPTIONS.dotnet == "ms") then + function premake.dotnet.getcompilervar(cfg) + if (_OPTIONS.dotnet == "msnet") then return "csc" elseif (_OPTIONS.dotnet == "mono") then return "gmcs" @@ -62,7 +63,7 @@ -- Returns a list of compiler flags, based on the supplied configuration. -- - function premake.csc.getflags(cfg) + function premake.dotnet.getflags(cfg) local result = table.translate(cfg.flags, flags) return result end @@ -73,7 +74,7 @@ -- Translates the Premake kind into the CSC kind string. -- - function premake.csc.getkind(cfg) + function premake.dotnet.getkind(cfg) if (cfg.kind == "ConsoleApp") then return "Exe" elseif (cfg.kind == "WindowedApp") then diff --git a/src/tools/gcc.lua b/src/tools/gcc.lua index de026fb2..8e1f417a 100644 --- a/src/tools/gcc.lua +++ b/src/tools/gcc.lua @@ -6,7 +6,7 @@ premake.gcc = { } - premake.targetstyle = "linux" + premake.gcc.targetstyle = "linux" -- diff --git a/tests/test_configs.lua b/tests/test_configs.lua index 0b359685..a0764ae6 100644 --- a/tests/test_configs.lua +++ b/tests/test_configs.lua @@ -6,8 +6,10 @@ T.configs = { } - local prj + local prj, cfg function T.configs.setup() + _ACTION = "gmake" + solution "MySolution" configurations { "Debug", "Release" } platforms { "x32", "ps3" } @@ -20,6 +22,7 @@ prj = project "MyProject" language "C" kind "SharedLib" + targetdir "../bin" defines "PROJECT" configuration "Debug" @@ -38,26 +41,24 @@ defines "X86_64" premake.buildconfigs() + prj = premake.getconfig(prj) + cfg = premake.getconfig(prj, "Debug") end function T.configs.SolutionFields() - local cfg = premake.getconfig(prj) test.isequal("Debug:Release", table.concat(cfg.configurations,":")) end function T.configs.ProjectFields() - local cfg = premake.getconfig(prj) test.isequal("C", cfg.language) end function T.configs.ProjectWideSettings() - local cfg = premake.getconfig(prj) - test.isequal("SOLUTION:PROJECT:NATIVE", table.concat(cfg.defines,":")) + test.isequal("SOLUTION:PROJECT:NATIVE", table.concat(prj.defines,":")) end function T.configs.BuildCfgSettings() - local cfg = premake.getconfig(prj, "Debug") test.isequal("SOLUTION:SOLUTION_DEBUG:PROJECT:DEBUG:NATIVE", table.concat(cfg.defines,":")) end @@ -77,7 +78,6 @@ end function T.configs.SetsPlatformNativeName() - local cfg = premake.getconfig(prj, "Debug") test.isequal("Native", cfg.platform) end @@ -87,7 +87,6 @@ end function T.configs.SetsNativeShortName() - local cfg = premake.getconfig(prj, "Debug") test.isequal("debug", cfg.shortname) end @@ -97,21 +96,21 @@ end function T.configs.SetsNativeLongName() - local cfg = premake.getconfig(prj, "Debug") test.isequal("Debug", cfg.longname) end function T.configs.SetsProject() local cfg = premake.getconfig(prj, "Debug", "x32") - test.istrue(prj == cfg.project) + test.istrue(prj.project == cfg.project) end + + -- -- Target system testing -- function T.configs.SetsTargetSystem_OnNative() - local cfg = premake.getconfig(prj, "Debug") test.isequal(os.get(), cfg.system) end @@ -119,13 +118,14 @@ local cfg = premake.getconfig(prj, "Debug", "PS3") test.isequal("PS3", cfg.system) end + + -- -- Platform kind translation -- function T.configs.SetsTargetKind_OnSupportedKind() - local cfg = premake.getconfig(prj, "Debug") test.isequal("SharedLib", cfg.kind) end diff --git a/tests/test_gmake_cpp.lua b/tests/test_gmake_cpp.lua index 452c678e..4765c5f4 100644 --- a/tests/test_gmake_cpp.lua +++ b/tests/test_gmake_cpp.lua @@ -12,16 +12,16 @@ local sln, prj function T.gmake_cpp.setup() + _ACTION = "gmake" + _OPTIONS.os = "linux" + sln = solution "MySolution" configurations { "Debug", "Release" } platforms { "native" } prj = project "MyProject" language "C++" - kind "ConsoleApp" - - _ACTION = "gmake" - _OPTIONS.os = "linux" + kind "ConsoleApp" end local function prepare() @@ -108,7 +108,7 @@ ifeq ($(config),debugps3) CXX = ppu-lv2-g++ AR = ppu-lv2-ar TARGETDIR = . - TARGET = $(TARGETDIR)/MyProject + TARGET = $(TARGETDIR)/MyProject.elf OBJDIR = obj/PS3/Debug DEFINES += INCLUDES += diff --git a/tests/test_targets.lua b/tests/test_targets.lua index 2c6ca7af..794826ed 100644 --- a/tests/test_targets.lua +++ b/tests/test_targets.lua @@ -11,278 +11,382 @@ cfg = { } cfg.basedir = "." cfg.location = "." + cfg.targetdir = "../bin" cfg.language = "C++" cfg.project = { name = "MyProject" } cfg.flags = { } + cfg.objectsdir = "obj" + cfg.platform = "Native" end - -- --- C++ ConsoleApp naming conventions +-- Windows/C++/ConsoleApp tests -- - function T.targets.On_Console_Build_Windows_Windows() + function T.targets.ConsoleApp_Windows_Build_Windows() cfg.kind = "ConsoleApp" - test.isequal("MyProject.exe", premake.gettarget(cfg, "build", "windows", "windows").fullpath) + result = premake.gettarget(cfg, "build", "windows", "windows") + test.isequal([[..\bin\MyProject.exe]], result.fullpath) end - function T.targets.On_Console_Build_Windows_Linux() + function T.targets.ConsoleApp_Windows_Build_Linux() cfg.kind = "ConsoleApp" - test.isequal("MyProject.exe", premake.gettarget(cfg, "build", "windows", "linux").fullpath) + result = premake.gettarget(cfg, "build", "windows", "linux") + test.isequal([[..\bin\MyProject.exe]], result.fullpath) end - function T.targets.On_Console_Build_Windows_MacOSX() + function T.targets.ConsoleApp_Windows_Build_MacOSX() cfg.kind = "ConsoleApp" - test.isequal("MyProject.exe", premake.gettarget(cfg, "build", "windows", "macosx").fullpath) + result = premake.gettarget(cfg, "build", "windows", "macosx") + test.isequal([[..\bin\MyProject.exe]], result.fullpath) end - function T.targets.On_Console_Build_Linux_Windows() + function T.targets.ConsoleApp_Windows_Build_PS3() cfg.kind = "ConsoleApp" - test.isequal("MyProject.exe", premake.gettarget(cfg, "build", "linux", "windows").fullpath) + cfg.platform = "PS3" + result = premake.gettarget(cfg, "build", "windows", "windows") + test.isequal([[..\bin\MyProject.elf]], result.fullpath) end - function T.targets.On_Console_Build_Linux_Linux() + function T.targets.ConsoleApp_Windows_Build_Xbox360() cfg.kind = "ConsoleApp" - test.isequal("MyProject", premake.gettarget(cfg, "build", "linux", "linux").fullpath) + cfg.platform = "Xbox360" + result = premake.gettarget(cfg, "build", "windows", "windows") + test.isequal([[..\bin\MyProject.exe]], result.fullpath) end - function T.targets.On_Console_Build_Linux_MacOSX() - cfg.kind = "ConsoleApp" - test.isequal("MyProject", premake.gettarget(cfg, "build", "linux", "macosx").fullpath) - end - - -- --- C++ WindowedApp naming conventions +-- Windows/C++/WindowedApp tests -- - function T.targets.On_Windowed_Build_Windows_Windows() + function T.targets.WindowedApp_Windows_Build_Windows() cfg.kind = "WindowedApp" - test.isequal("MyProject.exe", premake.gettarget(cfg, "build", "windows", "windows").fullpath) + result = premake.gettarget(cfg, "build", "windows", "windows") + test.isequal([[..\bin\MyProject.exe]], result.fullpath) end - function T.targets.On_Windowed_Build_Windows_Linux() + function T.targets.WindowedApp_Windows_Build_Linux() cfg.kind = "WindowedApp" - test.isequal("MyProject.exe", premake.gettarget(cfg, "build", "windows", "windows").fullpath) + result = premake.gettarget(cfg, "build", "windows", "linux") + test.isequal([[..\bin\MyProject.exe]], result.fullpath) end - function T.targets.On_Windowed_Build_Windows_MacOSX() + function T.targets.WindowedApp_Windows_Build_MacOSX() cfg.kind = "WindowedApp" - test.isequal("MyProject.exe", premake.gettarget(cfg, "build", "windows", "macosx").fullpath) + result = premake.gettarget(cfg, "build", "windows", "macosx") + test.isequal([[..\bin\MyProject.exe]], result.fullpath) end - - function T.targets.On_Windowed_Build_Linux_Windows() + + function T.targets.WindowedApp_Windows_Build_PS3() cfg.kind = "WindowedApp" - test.isequal("MyProject.exe", premake.gettarget(cfg, "build", "linux", "windows").fullpath) + cfg.platform = "PS3" + result = premake.gettarget(cfg, "build", "windows", "windows") + test.isequal([[..\bin\MyProject.elf]], result.fullpath) end - - function T.targets.On_Windowed_Build_Linux_Linux() + + function T.targets.WindowedApp_Windows_Build_Xbox360() cfg.kind = "WindowedApp" - test.isequal("MyProject", premake.gettarget(cfg, "build", "linux", "linux").fullpath) + cfg.platform = "Xbox360" + result = premake.gettarget(cfg, "build", "windows", "windows") + test.isequal([[..\bin\MyProject.exe]], result.fullpath) end - function T.targets.On_Windowed_Build_Linux_MacOSX() - cfg.kind = "WindowedApp" - test.isequal("MyProject.app/Contents/MacOS/MyProject", premake.gettarget(cfg, "build", "linux", "macosx").fullpath) - end - - -- --- C++ SharedLib naming conventions +-- Windows/C++/SharedLib tests -- - function T.targets.On_Shared_Build_Windows_Windows() + function T.targets.SharedLib_Windows_Build_Windows() cfg.kind = "SharedLib" - test.isequal("MyProject.dll", premake.gettarget(cfg, "build", "windows", "windows").fullpath) + result = premake.gettarget(cfg, "build", "windows", "windows") + test.isequal([[..\bin\MyProject.dll]], result.fullpath) end - function T.targets.On_Shared_Build_Windows_Linux() + function T.targets.SharedLib_Windows_Build_Linux() cfg.kind = "SharedLib" - test.isequal("MyProject.dll", premake.gettarget(cfg, "build", "windows", "windows").fullpath) + result = premake.gettarget(cfg, "build", "windows", "linux") + test.isequal([[..\bin\MyProject.dll]], result.fullpath) end - function T.targets.On_Shared_Build_Windows_MacOSX() + function T.targets.SharedLib_Windows_Build_MacOSX() cfg.kind = "SharedLib" - test.isequal("MyProject.dll", premake.gettarget(cfg, "build", "windows", "macosx").fullpath) + result = premake.gettarget(cfg, "build", "windows", "macosx") + test.isequal([[..\bin\MyProject.dll]], result.fullpath) end - - function T.targets.On_Shared_Build_Linux_Windows() + + function T.targets.SharedLib_Windows_Build_Xbox360() cfg.kind = "SharedLib" - test.isequal("MyProject.dll", premake.gettarget(cfg, "build", "linux", "windows").fullpath) + cfg.platform = "Xbox360" + result = premake.gettarget(cfg, "build", "windows", "linux") + test.isequal([[..\bin\MyProject.dll]], result.fullpath) end - - function T.targets.On_Shared_Build_Linux_Linux() + + function T.targets.SharedLib_Windows_Link_Windows() cfg.kind = "SharedLib" - test.isequal("libMyProject.so", premake.gettarget(cfg, "build", "linux", "linux").fullpath) + result = premake.gettarget(cfg, "link", "windows", "windows") + test.isequal([[..\bin\MyProject.lib]], result.fullpath) end - - function T.targets.On_Shared_Build_Linux_MacOSX() + + function T.targets.SharedLib_Windows_Link_Linux() cfg.kind = "SharedLib" - test.isequal("libMyProject.so", premake.gettarget(cfg, "build", "linux", "macosx").fullpath) + result = premake.gettarget(cfg, "link", "windows", "linux") + test.isequal([[..\bin\MyProject.lib]], result.fullpath) end - function T.targets.On_Shared_Link_Windows_Windows() + function T.targets.SharedLib_Windows_Link_MacOSX() cfg.kind = "SharedLib" - test.isequal("MyProject.lib", premake.gettarget(cfg, "link", "windows", "windows").fullpath) + result = premake.gettarget(cfg, "link", "windows", "macosx") + test.isequal([[..\bin\MyProject.lib]], result.fullpath) end - function T.targets.On_Shared_Link_Windows_Linux() + function T.targets.SharedLib_Windows_Link_Xbox360() cfg.kind = "SharedLib" - test.isequal("MyProject.lib", premake.gettarget(cfg, "link", "windows", "linux").fullpath) - end - - function T.targets.On_Shared_Link_Windows_MacOSX() - cfg.kind = "SharedLib" - test.isequal("MyProject.lib", premake.gettarget(cfg, "link", "windows", "macosx").fullpath) - end - - function T.targets.On_Shared_Link_Linux_Windows() - cfg.kind = "SharedLib" - test.isequal("libMyProject.a", premake.gettarget(cfg, "link", "linux", "windows").fullpath) - end - - --- --- C++ StaticLib naming conventions --- - - function T.targets.On_Static_Build_Windows_Windows() - cfg.kind = "StaticLib" - test.isequal("MyProject.lib", premake.gettarget(cfg, "build", "windows", "windows").fullpath) - end - - function T.targets.On_Static_Build_Windows_Linux() - cfg.kind = "StaticLib" - test.isequal("MyProject.lib", premake.gettarget(cfg, "build", "windows", "windows").fullpath) - end - - function T.targets.On_Static_Build_Windows_MacOSX() - cfg.kind = "StaticLib" - test.isequal("MyProject.lib", premake.gettarget(cfg, "build", "windows", "macosx").fullpath) - end - - function T.targets.On_Static_Build_Linux_Windows() - cfg.kind = "StaticLib" - test.isequal("libMyProject.a", premake.gettarget(cfg, "build", "linux", "windows").fullpath) - end - - function T.targets.On_Static_Build_Linux_Linux() - cfg.kind = "StaticLib" - test.isequal("libMyProject.a", premake.gettarget(cfg, "build", "linux", "linux").fullpath) - end - - function T.targets.On_Static_Build_Linux_MacOSX() - cfg.kind = "StaticLib" - test.isequal("libMyProject.a", premake.gettarget(cfg, "build", "linux", "macosx").fullpath) - end - - function T.targets.On_Static_Link_Windows_Windows() - cfg.kind = "StaticLib" - test.isequal("MyProject.lib", premake.gettarget(cfg, "link", "windows", "windows").fullpath) - end - - function T.targets.On_Static_Link_Windows_Linux() - cfg.kind = "StaticLib" - test.isequal("MyProject.lib", premake.gettarget(cfg, "link", "windows", "windows").fullpath) - end - - function T.targets.On_Static_Link_Windows_MacOSX() - cfg.kind = "StaticLib" - test.isequal("MyProject.lib", premake.gettarget(cfg, "link", "windows", "macosx").fullpath) - end - - function T.targets.On_Static_Link_Linux_Windows() - cfg.kind = "StaticLib" - test.isequal("libMyProject.a", premake.gettarget(cfg, "link", "linux", "windows").fullpath) - end - - function T.targets.On_Static_Link_Linux_Linux() - cfg.kind = "StaticLib" - test.isequal("libMyProject.a", premake.gettarget(cfg, "link", "linux", "linux").fullpath) - end - - function T.targets.On_Static_Link_Linux_MacOSX() - cfg.kind = "StaticLib" - test.isequal("libMyProject.a", premake.gettarget(cfg, "link", "linux", "macosx").fullpath) + cfg.platform = "Xbox360" + result = premake.gettarget(cfg, "link", "windows", "macosx") + test.isequal([[..\bin\MyProject.lib]], result.fullpath) end -- --- C# naming conventions +-- Windows/C++/StaticLib tests -- - function T.targets.On_Cs_Console_Build_Linux_Linux() - cfg.language = "C#" + function T.targets.StaticLib_Windows_Build_Windows() + cfg.kind = "StaticLib" + result = premake.gettarget(cfg, "build", "windows", "windows") + test.isequal([[..\bin\MyProject.lib]], result.fullpath) + end + + function T.targets.StaticLib_Windows_Build_Linux() + cfg.kind = "StaticLib" + result = premake.gettarget(cfg, "build", "windows", "linux") + test.isequal([[..\bin\MyProject.lib]], result.fullpath) + end + + function T.targets.StaticLib_Windows_Build_MacOSX() + cfg.kind = "StaticLib" + result = premake.gettarget(cfg, "build", "windows", "macosx") + test.isequal([[..\bin\MyProject.lib]], result.fullpath) + end + + function T.targets.StaticLib_Windows_Build_PS3() + cfg.kind = "StaticLib" + cfg.platform = "PS3" + result = premake.gettarget(cfg, "build", "windows", "macosx") + test.isequal([[..\bin\libMyProject.a]], result.fullpath) + end + + function T.targets.StaticLib_Windows_Build_Xbox360() + cfg.kind = "StaticLib" + cfg.platform = "Xbox360" + result = premake.gettarget(cfg, "build", "windows", "macosx") + test.isequal([[..\bin\MyProject.lib]], result.fullpath) + end + + function T.targets.StaticLib_Windows_Link_Windows() + cfg.kind = "StaticLib" + result = premake.gettarget(cfg, "link", "windows", "windows") + test.isequal([[..\bin\MyProject.lib]], result.fullpath) + end + + function T.targets.StaticLib_Windows_Link_Linux() + cfg.kind = "StaticLib" + result = premake.gettarget(cfg, "link", "windows", "linux") + test.isequal([[..\bin\MyProject.lib]], result.fullpath) + end + + function T.targets.StaticLib_Windows_Link_MacOSX() + cfg.kind = "StaticLib" + result = premake.gettarget(cfg, "link", "windows", "macosx") + test.isequal([[..\bin\MyProject.lib]], result.fullpath) + end + + function T.targets.StaticLib_Windows_Link_PS3() + cfg.kind = "StaticLib" + cfg.platform = "PS3" + result = premake.gettarget(cfg, "link", "windows", "windows") + test.isequal([[..\bin\libMyProject.a]], result.fullpath) + end + + function T.targets.StaticLib_Windows_Link_Xbox360() + cfg.kind = "StaticLib" + cfg.platform = "Xbox360" + result = premake.gettarget(cfg, "link", "windows", "windows") + test.isequal([[..\bin\MyProject.lib]], result.fullpath) + end + + + +-- +-- Linux/C++/ConsoleApp tests +-- + + function T.targets.ConsoleApp_Linux_Build_Windows() + cfg.kind = "ConsoleApp" + result = premake.gettarget(cfg, "build", "linux", "windows") + test.isequal([[../bin/MyProject.exe]], result.fullpath) + end + + function T.targets.ConsoleApp_Linux_Build_Linux() + cfg.kind = "ConsoleApp" + result = premake.gettarget(cfg, "build", "linux", "linux") + test.isequal([[../bin/MyProject]], result.fullpath) + end + + function T.targets.ConsoleApp_Linux_Build_MacOSX() + cfg.kind = "ConsoleApp" + result = premake.gettarget(cfg, "build", "linux", "macosx") + test.isequal([[../bin/MyProject]], result.fullpath) + end + + function T.targets.ConsoleApp_Linux_Build_PS3() cfg.kind = "ConsoleApp" - test.isequal("MyProject.exe", premake.gettarget(cfg, "build", "linux", "linux").fullpath) + cfg.platform = "PS3" + result = premake.gettarget(cfg, "build", "linux", "linux") + test.isequal([[../bin/MyProject.elf]], result.fullpath) end - function T.targets.On_Cs_Windowed_Build_Linux_Linux() - cfg.language = "C#" + function T.targets.ConsoleApp_Linux_Build_Xbox360() + cfg.kind = "ConsoleApp" + cfg.platform = "Xbox360" + result = premake.gettarget(cfg, "build", "linux", "linux") + test.isequal([[../bin/MyProject.exe]], result.fullpath) + end + + + +-- +-- Linux/C++/WindowedApp tests +-- + + function T.targets.WindowedApp_Linux_Build_Windows() + cfg.kind = "WindowedApp" + result = premake.gettarget(cfg, "build", "linux", "windows") + test.isequal([[../bin/MyProject.exe]], result.fullpath) + end + + function T.targets.WindowedApp_Linux_Build_Linux() + cfg.kind = "WindowedApp" + result = premake.gettarget(cfg, "build", "linux", "linux") + test.isequal([[../bin/MyProject]], result.fullpath) + end + + function T.targets.WindowedApp_Linux_Build_MacOSX() + cfg.kind = "WindowedApp" + result = premake.gettarget(cfg, "build", "linux", "macosx") + test.isequal([[../bin/MyProject.app/Contents/MacOS/MyProject]], result.fullpath) + end + + function T.targets.WindowedApp_Linux_Build_PS3() cfg.kind = "WindowedApp" - test.isequal("MyProject.exe", premake.gettarget(cfg, "build", "linux", "linux").fullpath) + cfg.platform = "PS3" + result = premake.gettarget(cfg, "build", "linux", "linux") + test.isequal([[../bin/MyProject.elf]], result.fullpath) end - function T.targets.On_Cs_Shared_Build_Linux_Linux() - cfg.language = "C#" - cfg.kind = "SharedLib" - test.isequal("MyProject.dll", premake.gettarget(cfg, "build", "linux", "linux").fullpath) + function T.targets.WindowedApp_Linux_Build_Xbox360() + cfg.kind = "WindowedApp" + cfg.platform = "Xbox360" + result = premake.gettarget(cfg, "build", "linux", "linux") + test.isequal([[../bin/MyProject.exe]], result.fullpath) end - - + -- --- Field handling tests +-- Linux/C++/SharedLib tests -- - function T.targets.TargetName_OverridesProjectName() - cfg.kind = "ConsoleApp" - cfg.targetname = "MyTarget" - test.isequal("MyTarget.exe", premake.gettarget(cfg, "build", "windows").fullpath) + function T.targets.SharedLib_Linux_Build_Windows() + cfg.kind = "SharedLib" + result = premake.gettarget(cfg, "build", "linux", "windows") + test.isequal([[../bin/MyProject.dll]], result.fullpath) end - function T.targets.TargetDir_OverridesBaseDir() - cfg.kind = "ConsoleApp" - cfg.targetdir = "MyTarget" - test.isequal("MyTarget/MyProject.exe", premake.gettarget(cfg, "build", "windows").fullpath) + function T.targets.SharedLib_Linux_Build_Linux() + cfg.kind = "SharedLib" + result = premake.gettarget(cfg, "build", "linux", "linux") + test.isequal([[../bin/libMyProject.so]], result.fullpath) end - function T.targets.TargetExtension_OverridesDefault() - cfg.kind = "ConsoleApp" - cfg.targetextension = ".zmf" - test.isequal("MyProject.zmf", premake.gettarget(cfg, "build", "windows").fullpath) + function T.targets.SharedLib_Linux_Build_MacOSX() + cfg.kind = "SharedLib" + result = premake.gettarget(cfg, "build", "linux", "macosx") + test.isequal([[../bin/libMyProject.so]], result.fullpath) end - function T.targets.TargetPrefix_OverridesDefault() - cfg.kind = "ConsoleApp" - cfg.targetprefix = "zoo" - test.isequal("zooMyProject.exe", premake.gettarget(cfg, "build", "windows").fullpath) + function T.targets.SharedLib_Linux_Link_Windows() + cfg.kind = "SharedLib" + result = premake.gettarget(cfg, "link", "linux", "windows") + test.isequal([[../bin/libMyProject.a]], result.fullpath) + end + + function T.targets.SharedLib_Linux_Link_Linux() + cfg.kind = "SharedLib" + result = premake.gettarget(cfg, "link", "linux", "linux") + test.isequal([[../bin/libMyProject.so]], result.fullpath) + end + + function T.targets.SharedLib_Linux_Link_MacOSX() + cfg.kind = "SharedLib" + result = premake.gettarget(cfg, "link", "linux", "macosx") + test.isequal([[../bin/libMyProject.so]], result.fullpath) end - function T.targets.ImpLibName_UsedOnSharedLinks() - cfg.kind = "SharedLib" - cfg.implibname = "MyImports" - test.isequal("MyImports.lib", premake.gettarget(cfg, "link", "windows").fullpath) + +-- +-- Linux/C++/StaticLib tests +-- + + function T.targets.StaticLib_Linux_Build_Windows() + cfg.kind = "StaticLib" + result = premake.gettarget(cfg, "build", "linux", "windows") + test.isequal([[../bin/libMyProject.a]], result.fullpath) end - function T.targets.ImpLibDir_UsedOnSharedLinks() - cfg.kind = "SharedLib" - cfg.implibdir = "MyTarget" - test.isequal("MyTarget/MyProject.lib", premake.gettarget(cfg, "link", "windows").fullpath) + function T.targets.StaticLib_Linux_Build_Linux() + cfg.kind = "StaticLib" + result = premake.gettarget(cfg, "build", "linux", "linux") + test.isequal([[../bin/libMyProject.a]], result.fullpath) end - - function T.targets.ImpLibExtension_UsedOnSharedLinks() - cfg.kind = "SharedLib" - cfg.implibextension = ".zmf" - test.isequal("MyProject.zmf", premake.gettarget(cfg, "link", "windows").fullpath) + + function T.targets.StaticLib_Linux_Build_MacOSX() + cfg.kind = "StaticLib" + result = premake.gettarget(cfg, "build", "linux", "macosx") + test.isequal([[../bin/libMyProject.a]], result.fullpath) end - - function T.targets.ImpLibPrefix_UsedOnSharedLinks() - cfg.kind = "SharedLib" - cfg.implibprefix = "zoo" - test.isequal("zooMyProject.lib", premake.gettarget(cfg, "link", "windows").fullpath) + + function T.targets.StaticLib_Linux_Build_PS3() + cfg.kind = "StaticLib" + cfg.platform = "PS3" + result = premake.gettarget(cfg, "build", "linux", "macosx") + test.isequal([[../bin/libMyProject.a]], result.fullpath) end + + function T.targets.StaticLib_Linux_Link_Windows() + cfg.kind = "StaticLib" + result = premake.gettarget(cfg, "link", "linux", "windows") + test.isequal([[../bin/libMyProject.a]], result.fullpath) + end + + function T.targets.StaticLib_Linux_Link_Linux() + cfg.kind = "StaticLib" + result = premake.gettarget(cfg, "link", "linux", "linux") + test.isequal([[../bin/libMyProject.a]], result.fullpath) + end + + function T.targets.StaticLib_Linux_Link_MacOSX() + cfg.kind = "StaticLib" + result = premake.gettarget(cfg, "link", "linux", "macosx") + test.isequal([[../bin/libMyProject.a]], result.fullpath) + end + + function T.targets.StaticLib_Linux_Link_PS3() + cfg.kind = "StaticLib" + cfg.platform = "PS3" + result = premake.gettarget(cfg, "link", "linux", "macosx") + test.isequal([[../bin/libMyProject.a]], result.fullpath) + end + diff --git a/tests/test_vs2002_sln.lua b/tests/test_vs2002_sln.lua index 132fc075..623b7242 100644 --- a/tests/test_vs2002_sln.lua +++ b/tests/test_vs2002_sln.lua @@ -12,6 +12,8 @@ local sln function T.vs2002_sln.setup() + _ACTION = 'vs2002' + sln = solution "MySolution" configurations { "Debug", "Release" } platforms {} @@ -22,7 +24,6 @@ uuid "AE61726D-187C-E440-BD07-2556188A6565" premake.buildconfigs() - _ACTION = 'vs2002' end diff --git a/tests/test_vs2003_sln.lua b/tests/test_vs2003_sln.lua index 3350065f..42e0aee5 100644 --- a/tests/test_vs2003_sln.lua +++ b/tests/test_vs2003_sln.lua @@ -12,6 +12,8 @@ local sln function T.vs2003_sln.setup() + _ACTION = "vs2003" + sln = solution "MySolution" configurations { "Debug", "Release" } platforms {} @@ -22,7 +24,6 @@ uuid "AE61726D-187C-E440-BD07-2556188A6565" premake.buildconfigs() - _ACTION = 'vs2003' end diff --git a/tests/test_vs2008_sln.lua b/tests/test_vs2008_sln.lua index 54f611f7..8eec33e1 100644 --- a/tests/test_vs2008_sln.lua +++ b/tests/test_vs2008_sln.lua @@ -12,6 +12,8 @@ local sln function T.vs2008_sln.setup() + _ACTION = "vs2008" + sln = solution "MySolution" configurations { "Debug", "Release" } platforms {} @@ -22,7 +24,6 @@ uuid "AE61726D-187C-E440-BD07-2556188A6565" premake.buildconfigs() - _ACTION = 'vs2008' end diff --git a/tests/test_vs200x_vcproj.lua b/tests/test_vs200x_vcproj.lua index 342fd7ee..e543eb36 100644 --- a/tests/test_vs200x_vcproj.lua +++ b/tests/test_vs200x_vcproj.lua @@ -12,6 +12,8 @@ local sln, prj function T.vs200x_vcproj.setup() + _ACTION = "vs2005" + sln = solution "MySolution" configurations { "Debug", "Release" } platforms {} @@ -23,9 +25,7 @@ prj = project "MyProject" language "C++" kind "ConsoleApp" - uuid "AE61726D-187C-E440-BD07-2556188A6565" - - _ACTION = 'vs2005' + uuid "AE61726D-187C-E440-BD07-2556188A6565" end local function prepare() @@ -350,3 +350,17 @@ /> ]] end + +-- function T.vs200x_vcproj.LinkerBlock_OnPS3StaticLib() +-- platforms { "PS3" } +-- kind "StaticLib" +-- prepare() +-- premake.vs200x_vcproj_VCLinkerTool_GCC(premake.getconfig(prj, "Debug", "PS3")) +-- test.capture [[ +-- +-- ]] +-- end