Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/windirstat/premake-4.x-stable.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--samples/project/premake4.lua6
-rw-r--r--src/_premake_main.lua40
-rw-r--r--src/base/api.lua25
-rw-r--r--src/base/cmdline.lua19
-rw-r--r--src/base/globals.lua13
-rw-r--r--src/base/help.lua1
-rw-r--r--src/base/project.lua2
-rw-r--r--src/base/table.lua13
-rw-r--r--src/host/scripts.c14
-rw-r--r--tests/test_configs.lua55
10 files changed, 116 insertions, 72 deletions
diff --git a/samples/project/premake4.lua b/samples/project/premake4.lua
index b720f6f..382f191 100644
--- a/samples/project/premake4.lua
+++ b/samples/project/premake4.lua
@@ -1,7 +1,6 @@
solution "PremakeTestbox"
configurations { "Debug", "Release" }
- platforms { "native", "x32", "x64", "universal", "xbox360" }
-
+
objdir "obj"
-- solution level configuration
@@ -15,9 +14,6 @@ solution "PremakeTestbox"
targetdir "bin/release"
flags { "Optimize" }
defines { "NDEBUG" }
-
- configuration "x64"
- defines { "IS_64BIT" }
-- include all the projects
diff --git a/src/_premake_main.lua b/src/_premake_main.lua
index 97b76d4..d98e3cf 100644
--- a/src/_premake_main.lua
+++ b/src/_premake_main.lua
@@ -57,6 +57,39 @@
end
+--
+-- Inject a new target platform into each solution; called if the --platform
+-- argument was specified on the command line.
+--
+
+ local function injectplatform(platform)
+ if not platform then return true end
+ platform = premake.checkvalue(platform, premake.fields.platforms.allowed)
+
+ for _, sln in ipairs(_SOLUTIONS) do
+ local platforms = sln.platforms or { }
+
+ -- an empty table is equivalent to a native build
+ if #platforms == 0 then
+ table.insert(platforms, "Native")
+ end
+
+ -- the solution must provide a native build in order to support this feature
+ if not table.contains(platforms, "Native") then
+ return false, sln.name .. " does not target native platform\nNative platform settings are required for the --platform feature."
+ end
+
+ -- add it to the end of the list, if it isn't in there already
+ if not table.contains(platforms, platform) then
+ table.insert(platforms, platform)
+ end
+
+ sln.platforms = platforms
+ end
+
+ return true
+ end
+
--
-- Script-side program entry point.
@@ -129,6 +162,13 @@
ok, err = premake.checktools()
if (not ok) then error("Error: " .. err, 0) end
+
+ -- If a platform was specified on the command line, inject it now
+
+ ok, err = injectplatform(_OPTIONS["platform"])
+ if (not ok) then error("Error: " .. err, 0) end
+
+
-- work-in-progress: build the configurations
print("Building configurations...")
premake.buildconfigs()
diff --git a/src/base/api.lua b/src/base/api.lua
index 844066b..7fcfb96 100644
--- a/src/base/api.lua
+++ b/src/base/api.lua
@@ -198,24 +198,7 @@
{
kind = "list",
scope = "solution",
- allowed = {
- "Native",
- "x32",
- "x64",
- "Universal",
- "Universal32",
- "Universal64",
- "Xbox360"
- },
- shortnames = {
- Native = "",
- x32 = "32",
- x64 = "64",
- Universal = "univ",
- Universal32 = "univ32",
- Universal64 = "univ64",
- Xbox360 = "360",
- }
+ allowed = table.keys(premake.platforms),
},
postbuildcommands =
@@ -315,7 +298,7 @@
-- use case-sensitive comparisions.
--
- local function checkvalue(value, allowed)
+ function premake.checkvalue(value, allowed)
if (allowed) then
if (type(allowed) == "function") then
return allowed(value)
@@ -396,7 +379,7 @@
doinsert(v, depth + 1)
end
else
- value, err = checkvalue(value, allowed)
+ value, err = premake.checkvalue(value, allowed)
if (not value) then
error(err, depth)
end
@@ -464,7 +447,7 @@
-- if a value was provided, set it
if (value) then
- value, err = checkvalue(value, allowed)
+ value, err = premake.checkvalue(value, allowed)
if (not value) then
error(err, 4)
end
diff --git a/src/base/cmdline.lua b/src/base/cmdline.lua
index 2908a41..15deede 100644
--- a/src/base/cmdline.lua
+++ b/src/base/cmdline.lua
@@ -74,8 +74,8 @@
value = "compiler",
description = "Choose a C/C++ compiler set",
allowed = {
- { "gcc", "GNU GCC compiler (gcc/g++)" },
- { "ow", "OpenWatcom compiler" },
+ { "gcc", "GNU GCC (gcc/g++)" },
+ { "ow", "OpenWatcom" },
}
}
@@ -119,6 +119,21 @@
newoption
{
+ trigger = "platform",
+ value = "value",
+ description = "Add target architecture (if supported by action)",
+ allowed = {
+ { "x32", "32-bit" },
+ { "x64", "64-bit" },
+ { "universal", "Mac OS X Universal, 32- and 64-bit" },
+ { "universal32", "Mac OS X Universal, 32-bit only" },
+ { "universal64", "Mac OS X Universal, 64-bit only" },
+ { "xbox360", "Xbox 360" },
+ }
+ }
+
+ newoption
+ {
trigger = "scripts",
value = "path",
description = "Search for additional scripts on the given path"
diff --git a/src/base/globals.lua b/src/base/globals.lua
index 3359e70..e1f1f37 100644
--- a/src/base/globals.lua
+++ b/src/base/globals.lua
@@ -26,6 +26,19 @@
premake.options = { }
+-- The list of supported platforms; also update list in cmdline.lua
+
+ premake.platforms =
+ {
+ Native = { "" },
+ x32 = { "32" },
+ x64 = { "64" },
+ Universal = { "univ" },
+ Universal32 = { "univ32" },
+ Universal64 = { "univ64" },
+ Xbox360 = { "xbox360" },
+ }
+
--
-- A replacement for Lua's built-in dofile() function, this one sets the
diff --git a/src/base/help.lua b/src/base/help.lua
index ef13fc8..0385f03 100644
--- a/src/base/help.lua
+++ b/src/base/help.lua
@@ -39,7 +39,6 @@
printf(" --%-15s %s", trigger, description)
if (opt.allowed) then
- table.sort(opt.allowed, function(a,b) return a[1] < b[1] end)
for _, value in ipairs(opt.allowed) do
printf(" %-14s %s", value[1], value[2])
end
diff --git a/src/base/project.lua b/src/base/project.lua
index c209117..95baaf1 100644
--- a/src/base/project.lua
+++ b/src/base/project.lua
@@ -200,7 +200,7 @@
local name = cfgname
if platform and platform ~= "Native" then
if useshortname then
- name = name .. premake.fields.platforms.shortnames[platform]
+ name = name .. premake.platforms[platform][1]
else
name = name .. "|" .. platform
end
diff --git a/src/base/table.lua b/src/base/table.lua
index 4f739d9..6fc28fc 100644
--- a/src/base/table.lua
+++ b/src/base/table.lua
@@ -71,6 +71,19 @@
--
+-- Return a list of all keys used in a table.
+--
+
+ function table.keys(tbl)
+ local keys = {}
+ for k, _ in pairs(tbl) do
+ table.insert(keys, k)
+ end
+ return keys
+ end
+
+
+--
-- Translates the values contained in array, using the specified
-- translation table, and returns the results in a new array.
--
diff --git a/src/host/scripts.c b/src/host/scripts.c
index 96ce97e..90f71e2 100644
--- a/src/host/scripts.c
+++ b/src/host/scripts.c
@@ -5,18 +5,18 @@ const char* builtin_scripts[] = {
"--\n\n\n\nfunction os.findlib(libname)\nlocal path, formats\n\n-- assemble a search path, depending on the platform\nif os.is(\"windows\") then\nformats = { \"%s.dll\", \"%s\" }\npath = os.getenv(\"PATH\")\nelse\nif os.is(\"macosx\") then\nformats = { \"lib%s.dylib\", \"%s.dylib\" }\npath = os.getenv(\"DYLD_LIBRARY_PATH\")\nelse\nformats = { \"lib%s.so\", \"%s.so\" }\npath = os.getenv(\"LD_LIBRARY_PATH\") or \"\"\n\nlocal f = io.open(\"/etc/ld.so.conf\", \"r\")\nif f then\nfor line in f:lines() do\npath = path .. \":\" .. line\nend\nf:close()\nend\nend\n\ntable.insert(formats, \"%s\")\npath = (path or \"\") .. \":/lib:/usr/lib:/usr/local/lib\"\nend\n\nfor _, fmt in ipairs(formats) do\nlocal name = string.format(fmt, libname)\nlocal result = os.pathsearch(name, path)\nif result then return result end\nend\nend\n\n\n\n\nfunction os.get()\nreturn _OPTIONS.os or _OS\nend\n\n\n\n\nfunction os.is(id)\nreturn (os.get():lower() == id:lower())\nend\n\n\n\n\nlocal function domatch(result, mask, wantfiles)\nlocal basedir = path.getdirectory(mask)\nif (basedir == \".\") then basedir = \"\" end\n\nlocal m = os.matchstart(mask)\nwhile (os.matchnext(m)) do\nlocal fname = os.matchname(m)\nlocal isfile = os.matchisfile(m)\nif ((wantfiles and isfile) or (not wantfiles and not isfile)) then\ntable.insert(result, path.join(basedir, fname))\nend\nend\nos.matchdone(m)\n\n-- if the mask uses \"**\", recurse subdirectories\nif (mask:find(\"**\", nil, true)) then\nmask = path.getname(mask)\nm = os.matchstart(path.join(basedir, \"*\"))\nwhile (os.matchnext(m)) do\nlocal dirname = os.matchname(m)\nlocal submask = path.join(path.join(basedir, dirname), mask)\ndomatch(result, submask, wantfiles)\nend\nos.matchdone(m)\nend\nend\n\nfunction os.matchdirs(...)\nlocal result = { }\nfor _, mask in ipairs(arg) do\ndomatch(result, mask, false)\nend\nreturn result\nend\n\nfunction os.matchfiles(...)\nlocal result = { }\nfor _, mask in ipairs(arg) do\ndomatch(result, mask, true)\nend\nreturn result\nend\n\n\n\n\nlocal builtin_mkdir = os.mkdir\nfunction os.mkdir(p)\nlocal dir = iif(p:startswith(\"/\"), \"/\", \"\")\nfor part in p:gmatch(\"[^/]+\") do\ndir = dir .. part\n\nif (part ~= \"\" and not path.isabsolute(part) and not os.isdir(dir)) then\nlocal ok, err = builtin_mkdir(dir)\nif (not ok) then\nreturn nil, err\nend\nend\n\ndir = dir .. \"/\"\nend\n\nreturn true\nend\n\n\n\nlocal builtin_rmdir = os.rmdir\nfunction os.rmdir(p)\n-- recursively remove subdirectories\nlocal dirs = os.matchdirs(p .. \"/*\")\nfor _, dname in ipairs(dirs) do\nos.rmdir(dname)\nend\n\n-- remove any files\nlocal files = os.matchfiles(p .. \"/*\")\nfor _, fname in ipairs(files) do\nos.remove(fname)\nend\n\n-- remove this directory\nbuiltin_rmdir(p)\nend\n\n",
"--\n\n\n\nfunction path.getabsolute(p)\n-- normalize the target path\np = path.translate(p, \"/\")\nif (p == \"\") then p = \".\" end\n\n-- if the directory is already absolute I don't need to do anything\nlocal result = iif (path.isabsolute(p), nil, os.getcwd())\n\n-- split up the supplied relative path and tackle it bit by bit\nfor _,part in ipairs(p:explode(\"/\", true)) do\nif (part == \"\") then\nresult = \"/\"\nelseif (part == \"..\") then\nresult = path.getdirectory(result)\nelseif (part ~= \".\") then\nresult = path.join(result, part)\nend\nend\n\nreturn result\nend\n\n\n\nfunction path.getbasename(p)\nlocal name = path.getname(p)\nlocal i = name:findlast(\".\", true)\nif (i) then\nreturn name:sub(1, i - 1)\nelse\nreturn name\nend\nend\n\n\n\nfunction path.getdirectory(p)\nlocal i = p:findlast(\"/\", true)\nif (i) then\nif i > 1 then i = i - 1 end\nreturn p:sub(1, i)\nelse\nreturn \".\"\nend\nend\n\n\n\nfunction path.getdrive(p)\nlocal ch1 = p:sub(1,1)\nlocal ch2 = p:sub(2,2)\nif ch2 == \":\" then\nreturn ch1\nend\nend\n\n\n\n\nfunction path.getextension(p)\nlocal i = p:findlast(\".\", true)\nif (i) then\nreturn p:sub(i)\nelse\nreturn \"\"\nend\nend\n\n\n\n\nfunction path.getname(p)\nlocal i = p:findlast(\"[/\\\\]\")\nif (i) then\nreturn p:sub(i + 1)\nelse\nreturn p\nend\nend\n\n\n\nfunction path.getrelative(src, dst)\n-- normalize the two paths\nsrc = path.getabsolute(src)\ndst = path.getabsolute(dst)\n\n-- same directory?\nif (src == dst) then\nreturn \".\"\nend\n\n-- different drives? Must use absolute path\nif path.getdrive(src) ~= path.getdrive(dst) then\nreturn dst\nend\n\nsrc = src .. \"/\"\ndst = dst .. \"/\"\n\n-- trim off the common directories from the front \nlocal i = src:find(\"/\")\nwhile (i) do\nif (src:sub(1,i) == dst:sub(1,i)) then\nsrc = src:sub(i + 1)\ndst = dst:sub(i + 1)\nelse\nbreak\nend\ni = src:find(\"/\")\nend\n\n-- back up from dst to get to this common parent\nlocal result = \"\"\ni = src:find(\"/\")\nwhile (i) do\nresult = result .. \"../\"\ni = src:find(\"/\", i + 1)\nend\n\n-- tack on the path down to the dst from here\nresult = result .. dst\n\n-- remove the trailing slash\nreturn result:sub(1, -2)\nend\n\n\n\nfunction path.iscfile(fname)\nlocal extensions = { \".c\", \".s\" }\nlocal ext = path.getextension(fname):lower()\nreturn table.contains(extensions, ext)\nend\n\nfunction path.iscppfile(fname)\nlocal extensions = { \".cc\", \".cpp\", \".cxx\", \".c\", \".s\" }\nlocal ext = path.getextension(fname):lower()\nreturn table.contains(extensions, ext)\nend\n\n\n\nfunction path.isresourcefile(fname)\nlocal extensions = { \".rc\" }\nlocal ext = path.getextension(fname):lower()\nreturn table.contains(extensions, ext)\nend\n\n\n\n\nfunction path.join(leading, trailing)\nleading = leading or \"\"\n\nif (not trailing) then\nreturn leading\nend\n\nif (path.isabsolute(trailing)) then\nreturn trailing\nend\n\nif (leading == \".\") then\nleading = \"\"\nend\n\nif (leading:len() > 0 and not leading:endswith(\"/\")) then\nleading = leading .. \"/\"\nend\n\nreturn leading .. trailing\nend\n\n\n\nfunction path.rebase(p, oldbase, newbase)\np = path.getabsolute(path.join(oldbase, p))\np = path.getrelative(newbase, p)\nreturn p\nend\n\n\n\nfunction path.translate(p, sep)\nif (type(p) == \"table\") then\nlocal result = { }\nfor _, value in ipairs(p) do\ntable.insert(result, path.translate(value))\nend\nreturn result\nelse\nif (not sep) then\nif (os.is(\"windows\")) then\nsep = \"\\\\\"\nelse\nsep = \"/\"\nend\nend\nlocal result = p:gsub(\"[/\\\\]\", sep)\nreturn result\nend\nend\n",
"--\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.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 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\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('&', \"&amp;\")\nvalue = value:gsub('\"', \"&quot;\")\nvalue = value:gsub(\"'\", \"&apos;\")\nvalue = value:gsub('<', \"&lt;\")\nvalue = value:gsub('>', \"&gt;\")\nvalue = value:gsub('\\r', \"&#x0D;\")\nvalue = value:gsub('\\n', \"&#x0A;\")\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.fields.platforms.shortnames[platform]\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\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 = { \"\" },\nx32 = { \"32\" },\nx64 = { \"64\" },\nUniversal = { \"univ\" },\nUniversal32 = { \"univ32\" },\nUniversal64 = { \"univ64\" },\nXbox360 = { \"xbox360\" },\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('&', \"&amp;\")\nvalue = value:gsub('\"', \"&quot;\")\nvalue = value:gsub(\"'\", \"&apos;\")\nvalue = value:gsub('<', \"&lt;\")\nvalue = value:gsub('>', \"&gt;\")\nvalue = value:gsub('\\r', \"&#x0D;\")\nvalue = value:gsub('\\n', \"&#x0A;\")\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][1]\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-- 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\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 = {\n\"Native\",\n\"x32\",\n\"x64\",\n\"Universal\",\n\"Universal32\",\n\"Universal64\",\n\"Xbox360\"\n},\nshortnames = {\nNative = \"\",\nx32 = \"32\",\nx64 = \"64\",\nUniversal = \"univ\",\nUniversal32 = \"univ32\",\nUniversal64 = \"univ64\",\nXbox360 = \"360\",\n}\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\nlocal function 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 = 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 = 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 compiler (gcc/g++)\" },\n{ \"ow\", \"OpenWatcom compiler\" },\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 = \"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\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{ \"xbox360\", \"Xbox 360\" },\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\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},\n}\n\n\n\n\nfunction premake.gcc.getcppflags(cfg)\nreturn premake.gcc.platforms[cfg.platform].cppflags\nend\n\nfunction premake.gcc.getcflags(cfg)\nlocal result = table.translate(cfg.flags, cflags)\nif (cfg.kind == \"SharedLib\" and not os.is(\"windows\")) then\ntable.insert(result, \"-fPIC\")\nend\ntable.insert(result, premake.gcc.platforms[cfg.platform].flags)\nreturn result\nend\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\nif (cfg.kind == \"SharedLib\") then\nif os.is(\"macosx\") then\nresult = table.join(result, { \"-dynamiclib\", \"-flat_namespace\" })\nelse\ntable.insert(result, \"-shared\")\nend\n\n-- create import library for DLLs under Windows\nif (os.is(\"windows\") and not cfg.flags.NoImportLib) then\ntable.insert(result, '-Wl,--out-implib=\"'..premake.gettarget(cfg, \"link\", \"linux\").fullpath..'\"')\nend\nend\n\nif (os.is(\"windows\") and cfg.kind == \"WindowedApp\") then\ntable.insert(result, \"-mwindows\")\nend\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 (os.is(\"macosx\")) then\ntable.insert(result, \"-Wl,-x\")\nelse\ntable.insert(result, \"-s\")\nend\nend\n\ntable.insert(result, premake.gcc.platforms[cfg.platform].flags)\ntable.insert(result, premake.gcc.platforms[cfg.platform].ldflags)\n\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\npremake.ow = { }\npremake.ow.targetstyle = \"windows\"\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\ntable.sort(opt.allowed, function(a,b) return a[1] < b[1] end)\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",
+ "--\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",
"--\n\nfunction premake.codeblocks_workspace(sln)\n_p('<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>')\n_p('<CodeBlocks_workspace_file>')\n_p('\\t<Workspace title=\"%s\">', sln.name)\n\nfor prj in premake.eachproject(sln) do\nlocal fname = path.join(path.getrelative(sln.location, prj.location), prj.name)\nlocal active = iif(prj.project == sln.projects[1], ' active=\"1\"', '')\n\n_p('\\t\\t<Project filename=\"%s.cbp\"%s>', fname, active)\nfor _,dep in ipairs(premake.getdependencies(prj)) do\n_p('\\t\\t\\t<Depends filename=\"%s.cbp\" />', path.join(path.getrelative(sln.location, dep.location), dep.name))\nend\n\n_p('\\t\\t</Project>')\nend\n\n_p('\\t</Workspace>')\n_p('</CodeBlocks_workspace_file>')\nend\n\n",
"--\n\nfunction premake.codeblocks_cbp(prj)\n-- alias the C/C++ compiler interface\nlocal cc = premake[_OPTIONS.cc]\n\n_p('<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>')\n_p('<CodeBlocks_project_file>')\n_p('\\t<FileVersion major=\"1\" minor=\"6\" />')\n\n-- write project block header\n_p('\\t<Project>')\n_p('\\t\\t<Option title=\"%s\" />', premake.esc(prj.name))\n_p('\\t\\t<Option pch_mode=\"2\" />')\n_p('\\t\\t<Option compiler=\"%s\" />', _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\n-- write configuration blocks\n_p('\\t\\t<Build>')\nfor _, platform in ipairs(platforms) do\nfor cfg in premake.eachconfig(prj, platform) do\n_p('\\t\\t\\t<Target title=\"%s\">', premake.esc(cfg.longname))\n\n_p('\\t\\t\\t\\t<Option output=\"%s\" prefix_auto=\"0\" extension_auto=\"0\" />', premake.esc(cfg.buildtarget.fullpath))\n_p('\\t\\t\\t\\t<Option object_output=\"%s\" />', premake.esc(cfg.objectsdir))\n\n-- identify the type of binary\nlocal types = { WindowedApp = 0, ConsoleApp = 1, StaticLib = 2, SharedLib = 3 }\n_p('\\t\\t\\t\\t<Option type=\"%d\" />', types[cfg.kind])\n\n_p('\\t\\t\\t\\t<Option compiler=\"%s\" />', _OPTIONS.cc)\n\nif (cfg.kind == \"SharedLib\") then\n_p('\\t\\t\\t\\t<Option createDefFile=\"0\" />')\n_p('\\t\\t\\t\\t<Option createStaticLib=\"%s\" />', iif(cfg.flags.NoImportLib, 0, 1))\nend\n\n-- begin compiler block --\n_p('\\t\\t\\t\\t<Compiler>')\nfor _,flag in ipairs(table.join(cc.getcflags(cfg), cc.getcxxflags(cfg), cc.getdefines(cfg.defines), cfg.buildoptions)) do\n_p('\\t\\t\\t\\t\\t<Add option=\"%s\" />', premake.esc(flag))\nend\nif not cfg.flags.NoPCH and cfg.pchheader then\n_p('\\t\\t\\t\\t\\t<Add option=\"-Winvalid-pch\" />')\n_p('\\t\\t\\t\\t\\t<Add option=\"-include &quot;%s&quot;\" />', premake.esc(cfg.pchheader))\nend\nfor _,v in ipairs(cfg.includedirs) do\n_p('\\t\\t\\t\\t\\t<Add directory=\"%s\" />', premake.esc(v))\nend\n_p('\\t\\t\\t\\t</Compiler>')\n-- end compiler block --\n\n-- begin linker block --\n_p('\\t\\t\\t\\t<Linker>')\nfor _,flag in ipairs(table.join(cc.getldflags(cfg), cfg.linkoptions)) do\n_p('\\t\\t\\t\\t\\t<Add option=\"%s\" />', premake.esc(flag))\nend\nfor _,v in ipairs(premake.getlinks(cfg, \"all\", \"directory\")) do\n_p('\\t\\t\\t\\t\\t<Add directory=\"%s\" />', premake.esc(v))\nend\nfor _,v in ipairs(premake.getlinks(cfg, \"all\", \"basename\")) do\n_p('\\t\\t\\t\\t\\t<Add library=\"%s\" />', premake.esc(v))\nend\n_p('\\t\\t\\t\\t</Linker>')\n-- end linker block --\n\n-- begin resource compiler block --\nif premake.findfile(cfg, \".rc\") then\n_p('\\t\\t\\t\\t<ResourceCompiler>')\nfor _,v in ipairs(cfg.includedirs) do\n_p('\\t\\t\\t\\t\\t<Add directory=\"%s\" />', premake.esc(v))\nend\nfor _,v in ipairs(cfg.resincludedirs) do\n_p('\\t\\t\\t\\t\\t<Add directory=\"%s\" />', premake.esc(v))\nend\n_p('\\t\\t\\t\\t</ResourceCompiler>')\nend\n-- end resource compiler block --\n\n-- begin build steps --\nif #cfg.prebuildcommands > 0 or #cfg.postbuildcommands > 0 then\n_p('\\t\\t\\t\\t<ExtraCommands>')\nfor _,v in ipairs(cfg.prebuildcommands) do\n_p('\\t\\t\\t\\t\\t<Add before=\"%s\" />', premake.esc(v))\nend\nfor _,v in ipairs(cfg.postbuildcommands) do\n_p('\\t\\t\\t\\t\\t<Add after=\"%s\" />', premake.esc(v))\nend\n\n_p('\\t\\t\\t\\t</ExtraCommands>')\nend\n-- end build steps --\n\n_p('\\t\\t\\t</Target>')\nend\nend\n_p('\\t\\t</Build>')\n\n-- begin files block --\nfor _,fname in ipairs(prj.files) do\n_p('\\t\\t<Unit filename=\"%s\">', premake.esc(fname))\nif path.getextension(fname) == \".rc\" then\n_p('\\t\\t\\t<Option compilerVar=\"WINDRES\" />')\nelseif path.iscppfile(fname) then\n_p('\\t\\t\\t<Option compilerVar=\"%s\" />', iif(prj.language == \"C\", \"CC\", \"CPP\"))\nif (not prj.flags.NoPCH and fname == prj.pchheader) then\n_p('\\t\\t\\t<Option compile=\"1\" />')\n_p('\\t\\t\\t<Option weight=\"0\" />')\nend\nend\n_p('\\t\\t</Unit>')\nend\n-- end files block --\n\n_p('\\t\\t<Extensions />')\n_p('\\t</Project>')\n_p('</CodeBlocks_project_file>')\n_p('')\n\nend\n",
"--\n\nfunction premake.codelite_workspace(sln)\n_p('<?xml version=\"1.0\" encoding=\"utf-8\"?>')\n_p('<CodeLite_Workspace Name=\"%s\" Database=\"./%s.tags\">', premake.esc(sln.name), premake.esc(sln.name))\n\nfor i,prj in ipairs(sln.projects) do\nlocal name = premake.esc(prj.name)\nlocal fname = path.join(path.getrelative(sln.location, prj.location), prj.name)\nlocal active = iif(i==1, \"Yes\", \"No\")\n_p(' <Project Name=\"%s\" Path=\"%s.project\" Active=\"%s\" />', name, fname, active)\nend\n\n-- build a list of supported target platforms that also includes a generic build\nlocal platforms = premake.filterplatforms(sln, premake[_OPTIONS.cc].platforms, \"Native\")\n\n_p(' <BuildMatrix>')\nfor _, platform in ipairs(platforms) do\nfor _, cfgname in ipairs(sln.configurations) do\nlocal name = premake.getconfigname(cfgname, platform)\n_p(' <WorkspaceConfiguration Name=\"%s\" Selected=\"yes\">', name)\nfor _,prj in ipairs(sln.projects) do\n_p(' <Project Name=\"%s\" ConfigName=\"%s\"/>', prj.name, name)\nend\n_p(' </WorkspaceConfiguration>')\nend\nend\n_p(' </BuildMatrix>')\n_p('</CodeLite_Workspace>')\nend\n\n",
@@ -37,6 +37,6 @@ const char* builtin_scripts[] = {
"--\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\",\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 _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 premake.vstudio_filterplatforms(sln)\nlocal supported = iif(_ACTION < \"vs2005\", {}, premake.vstudio_platforms)\nreturn premake.filterplatforms(sln, supported, \"x32\")\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, \"<Filter\")\nattrib(indent, \"Name\", path.getname(fname))\nattrib(indent, \"Filter\", \"\")\noutput(indent, \"\\t>\")\n\nelseif (state == \"GroupEnd\") then\noutput(indent, \"</Filter>\")\n\nelse\noutput(indent, \"<File\")\nattrib(indent, \"RelativePath\", path.translate(fname, \"\\\\\"))\noutput(indent, \"\\t>\")\nif (not prj.flags.NoPCH and prj.pchsource == fname) then\nfor _, cfgname in ipairs(prj.configurations) do\noutput(indent, \"\\t<FileConfiguration\")\nattrib(indent, \"\\tName\", cfgname .. \"|Win32\")\noutput(indent, \"\\t\\t>\")\noutput(indent, \"\\t\\t<Tool\")\nattrib(indent, \"\\t\\tName\", \"VCCLCompilerTool\")\nattrib(indent, \"\\t\\tUsePrecompiledHeader\", \"1\")\noutput(indent, \"\\t\\t/>\")\noutput(indent, \"\\t</FileConfiguration>\")\nend\nend\noutput(indent, \"</File>\")\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\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\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-- 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",
+ "--\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/tests/test_configs.lua b/tests/test_configs.lua
index 6fcbe34..65617ab 100644
--- a/tests/test_configs.lua
+++ b/tests/test_configs.lua
@@ -28,6 +28,9 @@
configuration "Release"
defines "RELEASE"
+ configuration "native"
+ defines "NATIVE"
+
configuration "x32"
defines "X86_32"
@@ -50,12 +53,12 @@
function T.configs.ProjectWideSettings()
local cfg = premake.getconfig(prj)
- test.isequal("SOLUTION:PROJECT", table.concat(cfg.defines,":"))
+ test.isequal("SOLUTION:PROJECT:NATIVE", table.concat(cfg.defines,":"))
end
function T.configs.BuildCfgSettings()
local cfg = premake.getconfig(prj, "Debug")
- test.isequal("SOLUTION:SOLUTION_DEBUG:PROJECT:DEBUG", table.concat(cfg.defines,":"))
+ test.isequal("SOLUTION:SOLUTION_DEBUG:PROJECT:DEBUG:NATIVE", table.concat(cfg.defines,":"))
end
function T.configs.PlatformSettings()
@@ -73,50 +76,32 @@
test.isequal("x32", cfg.platform)
end
+ function T.configs.SetsPlatformNativeName()
+ local cfg = premake.getconfig(prj, "Debug")
+ test.isequal("Native", cfg.platform)
+ end
+
function T.configs.SetsShortName()
local cfg = premake.getconfig(prj, "Debug", "x32")
test.isequal("debug32", cfg.shortname)
end
+ function T.configs.SetsNativeShortName()
+ local cfg = premake.getconfig(prj, "Debug")
+ test.isequal("debug", cfg.shortname)
+ end
+
function T.configs.SetsLongName()
local cfg = premake.getconfig(prj, "Debug", "x32")
test.isequal("Debug|x32", cfg.longname)
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)
end
-
-
---[[
-
- function T.configs.PlatformValues()
- local r = premake.getconfig(prj, "Debug", "x32").defines
- test.isequal("GLOBAL:DEBUG:X86_32", table.concat(r,":"))
- end
-
-
- function T.configs.PlaformNotInSolution()
- local r = premake.getconfig(prj, "Debug", "Xbox360").defines
- test.isequal("GLOBAL:DEBUG", table.concat(r, ":"))
- end
-
-
- function T.configs.DefaultToNativePlatform()
- local r = premake.getconfig(prj, "Debug").platform
- test.isequal("Native", r)
- end
-
-
- function T.configs.BuildsShortName()
- local r = premake.getconfig(prj, "Debug", "x32").shortname
- test.isequal("debug32", r)
- end
-
- function T.configs.BuildsLongName()
- local r = premake.getconfig(prj, "Debug", "x32").longname
- test.isequal("Debug|x32", r)
- end
-
-]] \ No newline at end of file