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%DsD% 1) then result = result .. "/" .. part else result = path.join(result, part) end end end result = iif(result:endswith("/"), result:sub(1, -2), result) return result end function path.getbasename(p) local name = path.getname(p) local i = name:findlast(".", true) if (i) then return name:sub(1, i - 1) else return name end end function path.getdirectory(p) local i = p:findlast("/", true) if (i) then if i > 1 then i = i - 1 end return p:sub(1, i) else return "." end end function path.getdrive(p) local ch1 = p:sub(1,1) local ch2 = p:sub(2,2) if ch2 == ":" then return ch1 end end function path.getextension(p) local i = p:findlast(".", true) if (i) then return p:sub(i) else return "" end end function path.getname(p) local i = p:findlast("[/\\]") if (i) then return p:sub(i + 1) else return p end end function path.getrelative(src, dst) src = path.getabsolute(src) dst = path.getabsolute(dst) if (src == dst) then return "." end if dst:startswith("$") then return dst end src = src .. "/" dst = dst .. "/" local idx = 0 while (true) do local tst = src:find("/", idx + 1, true) if tst then if src:sub(1,tst) == dst:sub(1,tst) then idx = tst else break end else break end end local first = src:find("/", 0, true) if idx <= first then return dst:sub(1, -2) end src = src:sub(idx + 1) dst = dst:sub(idx + 1) local result = "" idx = src:find("/") while (idx) do result = result .. "../" idx = src:find("/", idx + 1) end result = result .. dst return result:sub(1, -2) end function path.iscfile(fname) local extensions = { ".c", ".s", ".m" } local ext = path.getextension(fname):lower() return table.contains(extensions, ext) end function path.iscppfile(fname) local extensions = { ".cc", ".cpp", ".cxx", ".c", ".s", ".m", ".mm" } local ext = path.getextension(fname):lower() return table.contains(extensions, ext) end function path.iscppheader(fname) local extensions = { ".h", ".hh", ".hpp", ".hxx" } local ext = path.getextension(fname):lower() return table.contains(extensions, ext) end function path.isresourcefile(fname) local extensions = { ".rc" } local ext = path.getextension(fname):lower() return table.contains(extensions, ext) end function path.join(leading, trailing) leading = leading or "" if (not trailing) then return leading end if (path.isabsolute(trailing)) then return trailing end if (leading == ".") then leading = "" end if (leading:len() > 0 and not leading:endswith("/")) then leading = leading .. "/" end return leading .. trailing end function path.rebase(p, oldbase, newbase) p = path.getabsolute(path.join(oldbase, p)) p = path.getrelative(newbase, p) return p end function path.translate(p, sep) if (type(p) == "table") then local result = { } for _, value in ipairs(p) do table.insert(result, path.translate(value)) end return result else if (not sep) then if (os.is("windows")) then sep = "\\" else sep = "/" end end local result = p:gsub("[/\\]", sep) return result end end function path.wildcards(pattern) pattern = pattern:gsub("([%+%.%-%^%$%(%)%%])", "%%%1") pattern = pattern:gsub("%*%*", "\001") pattern = pattern:gsub("%*", "\002") pattern = pattern:gsub("\001", ".*") pattern = pattern:gsub("\002", "[^/]*") return pattern end function string.explode(s, pattern, plain) if (pattern == '') then return false end local pos = 0 local arr = { } for st,sp in function() return s:find(pattern, pos, plain) end do table.insert(arr, s:sub(pos, st-1)) pos = sp + 1 end table.insert(arr, s:sub(pos)) return arr end function string.findlast(s, pattern, plain) local curr = 0 repeat local next = s:find(pattern, curr + 1, plain) if (next) then curr = next end until (not next) if (curr > 0) then return curr end end function string.startswith(haystack, needle) return (haystack:find(needle, 1, true) == 1) end function table.contains(t, value) for _,v in pairs(t) do if (v == value) then return true end end return false end function table.extract(arr, fname) local result = { } for _,v in ipairs(arr) do table.insert(result, v[fname]) end return result end function table.flatten(arr) local result = { } local function flatten(arr) for _, v in ipairs(arr) do if type(v) == "table" then flatten(v) else table.insert(result, v) end end end flatten(arr) return result end function table.implode(arr, before, after, between) local result = "" for _,v in ipairs(arr) do if (result ~= "" and between) then result = result .. between end result = result .. before .. v .. after end return result end function table.insertflat(tbl, values) if type(values) == "table" then for _, value in ipairs(values) do table.insertflat(tbl, value) end else table.insert(tbl, values) end end function table.isempty(t) return not next(t) end function table.join(...) local result = { } for _,t in ipairs(arg) do if type(t) == "table" then for _,v in ipairs(t) do table.insert(result, v) end else table.insert(result, t) end end return result end function table.keys(tbl) local keys = {} for k, _ in pairs(tbl) do table.insert(keys, k) end return keys end function table.merge(...) local result = { } for _,t in ipairs(arg) do if type(t) == "table" then for k,v in pairs(t) do result[k] = v end else error("invalid value") end end return result end function table.translate(arr, translation) local result = { } for _, value in ipairs(arr) do local tvalue if type(translation) == "function" then tvalue = translation(value) else tvalue = translation[value] end if (tvalue) then table.insert(result, tvalue) end end return result end function io.capture() io.captured = '' end function io.endcapture() local captured = io.captured io.captured = nil return captured end local builtin_open = io.open function io.open(fname, mode) if (mode) then if (mode:find("w")) then local dir = path.getdirectory(fname) ok, err = os.mkdir(dir) if (not ok) then error(err, 0) end end end return builtin_open(fname, mode) end function io.printf(msg, ...) if not io.eol then io.eol = "\n" end if not io.indent then io.indent = "\t" end if type(msg) == "number" then s = string.rep(io.indent, msg) .. string.format(unpack(arg)) else s = string.format(msg, unpack(arg)) end if io.captured then io.captured = io.captured .. s .. io.eol else io.write(s) io.write(io.eol) end end _p = io.printf premake = { } premake.platforms = { Native = { cfgsuffix = "", }, x32 = { cfgsuffix = "32", }, x64 = { cfgsuffix = "64", }, Universal = { cfgsuffix = "univ", }, Universal32 = { cfgsuffix = "univ32", }, Universal64 = { cfgsuffix = "univ64", }, PS3 = { cfgsuffix = "ps3", iscrosscompiler = true, nosharedlibs = true, namestyle = "PS3", }, Xbox360 = { cfgsuffix = "xbox360", iscrosscompiler = true, namestyle = "windows", }, } local builtin_dofile = dofile function dofile(fname) local oldcwd = os.getcwd() local oldfile = _SCRIPT if (not os.isfile(fname)) then local path = os.pathsearch(fname, _OPTIONS["scripts"], os.getenv("PREMAKE_PATH")) if (path) then fname = path.."/"..fname end end _SCRIPT = path.getabsolute(fname) local newcwd = path.getdirectory(_SCRIPT) os.chdir(newcwd) local a, b, c, d, e, f = builtin_dofile(_SCRIPT) _SCRIPT = oldfile os.chdir(oldcwd) return a, b, c, d, e, f end function iif(expr, trueval, falseval) if (expr) then return trueval else return falseval end end function include(fname) return dofile(fname .. "/premake4.lua") end function printf(msg, ...) print(string.format(msg, unpack(arg))) end local builtin_type = type function type(t) local mt = getmetatable(t) if (mt) then if (mt.__type) then return mt.__type end end return builtin_type(t) end premake.action = { } premake.action.list = { } function premake.action.add(a) local missing for _, field in ipairs({"description", "trigger"}) do if (not a[field]) then missing = field end end if (missing) then error("action needs a " .. missing, 3) end premake.action.list[a.trigger] = a end function premake.action.call(name) local a = premake.action.list[name] for sln in premake.solution.each() do if a.onsolution then a.onsolution(sln) end for prj in premake.solution.eachproject(sln) do if a.onproject then a.onproject(prj) end end end if a.execute then a.execute() end end function premake.action.current() return premake.action.get(_ACTION) end function premake.action.get(name) return premake.action.list[name] end function premake.action.each() local keys = { } for _, action in pairs(premake.action.list) do table.insert(keys, action.trigger) end table.sort(keys) local i = 0 return function() i = i + 1 return premake.action.list[keys[i]] end end function premake.action.set(name) _ACTION = name local action = premake.action.get(name) if action then _OS = action.os or _OS end end function premake.action.supports(action, feature) if not action then return false end if action.valid_languages then if table.contains(action.valid_languages, feature) then return true end end if action.valid_kinds then if table.contains(action.valid_kinds, feature) then return true end end return false end premake.option = { } premake.option.list = { } function premake.option.add(opt) local missing for _, field in ipairs({ "description", "trigger" }) do if (not opt[field]) then missing = field end end if (missing) then error("option needs a " .. missing, 3) end premake.option.list[opt.trigger] = opt end function premake.option.get(name) return premake.option.list[name] end function premake.option.each() local keys = { } for _, option in pairs(premake.option.list) do table.insert(keys, option.trigger) end table.sort(keys) local i = 0 return function() i = i + 1 return premake.option.list[keys[i]] end end function premake.option.validate(values) for key, value in pairs(values) do local opt = premake.option.get(key) if (not opt) then return false, "invalid option '" .. key .. "'" end if (opt.value and value == "") then return false, "no value specified for option '" .. key .. "'" end if (opt.allowed) then for _, match in ipairs(opt.allowed) do if (match[1] == value) then return true end end return false, "invalid value '" .. value .. "' for option '" .. key .. "'" end end return true end premake.tree = { } local tree = premake.tree function premake.tree.new(n) local t = { name = n, children = { } } return t end function premake.tree.add(tr, p, onaddfunc) if p == "." then return tr end local parentnode = tree.add(tr, path.getdirectory(p), onaddfunc) local childname = path.getname(p) if childname == ".." then return parentnode end local childnode = parentnode.children[childname] if not childnode or childnode.path ~= p then childnode = tree.insert(parentnode, tree.new(childname)) childnode.path = p if onaddfunc then onaddfunc(childnode) end end return childnode end function premake.tree.insert(parent, child) table.insert(parent.children, child) if child.name then parent.children[child.name] = child end child.parent = parent return child end function premake.tree.getlocalpath(node) if node.parent.path then return node.name else return node.path end end function premake.tree.remove(node) local children = node.parent.children for i = 1, #children do if children[i] == node then table.remove(children, i) end end node.children = {} end function premake.tree.sort(tr) tree.traverse(tr, { onnode = function(node) table.sort(node.children, function(a,b) return a.name < b.name end) end }, true) end function premake.tree.traverse(t, fn, includeroot, initialdepth) local donode, dochildren donode = function(node, fn, depth) if node.isremoved then return end if fn.onnode then fn.onnode(node, depth) end if #node.children > 0 then if fn.onbranchenter then fn.onbranchenter(node, depth) end if fn.onbranch then fn.onbranch(node, depth) end dochildren(node, fn, depth + 1) if fn.onbranchexit then fn.onbranchexit(node, depth) end else if fn.onleaf then fn.onleaf(node, depth) end end end dochildren = function(parent, fn, depth) local i = 1 while i <= #parent.children do local node = parent.children[i] donode(node, fn, depth) if node == parent.children[i] then i = i + 1 end end end if not initialdepth then initialdepth = 0 end if includeroot then donode(t, fn, initialdepth) else dochildren(t, fn, initialdepth) end end premake.solution = { } premake.solution.list = { } function premake.solution.new(name) local sln = { } table.insert(premake.solution.list, sln) premake.solution.list[name] = sln setmetatable(sln, { __type="solution" }) sln.name = name sln.basedir = os.getcwd() sln.projects = { } sln.blocks = { } sln.configurations = { } return sln end function premake.solution.each() local i = 0 return function () i = i + 1 if i <= #premake.solution.list then return premake.solution.list[i] end end end function premake.solution.eachproject(sln) local i = 0 return function () i = i + 1 if (i <= #sln.projects) then return premake.solution.getproject(sln, i) end end end function premake.solution.get(key) return premake.solution.list[key] end function premake.solution.getproject(sln, idx) local prj = sln.projects[idx] local cfg = premake.getconfig(prj) cfg.name = prj.name return cfg end premake.project = { } function premake.project.buildsourcetree(prj) local tr = premake.tree.new(prj.name) tr.project = prj local isvpath local function onadd(node) node.isvpath = isvpath end for fcfg in premake.project.eachfile(prj) do isvpath = (fcfg.name ~= fcfg.vpath) local node = premake.tree.add(tr, fcfg.vpath, onadd) node.cfg = fcfg end premake.tree.sort(tr) return tr end function premake.eachconfig(prj, platform) if prj.project then prj = prj.project end local cfgs = prj.solution.configurations local i = 0 return function () i = i + 1 if i <= #cfgs then return premake.getconfig(prj, cfgs[i], platform) end end end function premake.project.eachfile(prj) if not prj.project then prj = premake.getconfig(prj) end local i = 0 local t = prj.files return function () i = i + 1 if (i <= #t) then local fcfg = prj.__fileconfigs[t[i]] fcfg.vpath = premake.project.getvpath(prj, fcfg.name) return fcfg end end end function premake.esc(value) if (type(value) == "table") then local result = { } for _,v in ipairs(value) do table.insert(result, premake.esc(v)) end return result else value = value:gsub('&', "&") value = value:gsub('"', """) value = value:gsub("'", "'") value = value:gsub('<', "<") value = value:gsub('>', ">") value = value:gsub('\r', " ") value = value:gsub('\n', " ") return value end end function premake.filterplatforms(sln, map, default) local result = { } local keys = { } if sln.platforms then for _, p in ipairs(sln.platforms) do if map[p] and not table.contains(keys, map[p]) then table.insert(result, p) table.insert(keys, map[p]) end end end if #result == 0 and default then table.insert(result, default) end return result end function premake.findproject(name) for sln in premake.solution.each() do for prj in premake.solution.eachproject(sln) do if (prj.name == name) then return prj end end end end function premake.findfile(prj, extension) for _, fname in ipairs(prj.files) do if fname:endswith(extension) then return fname end end end function premake.getconfig(prj, cfgname, pltname) prj = prj.project or prj if pltname == "Native" or not table.contains(prj.solution.platforms or {}, pltname) then pltname = nil end local key = (cfgname or "") if pltname then key = key .. pltname end return prj.__configs[key] end function premake.getconfigname(cfgname, platform, useshortname) if cfgname then local name = cfgname if platform and platform ~= "Native" then if useshortname then name = name .. premake.platforms[platform].cfgsuffix else name = name .. "|" .. platform end end return iif(useshortname, name:lower(), name) end end function premake.getdependencies(prj) prj = prj.project or prj local results = { } for _, cfg in pairs(prj.__configs) do for _, link in ipairs(cfg.links) do local dep = premake.findproject(link) if dep and not table.contains(results, dep) then table.insert(results, dep) end end end return results end function premake.project.getfilename(prj, pattern) local fname = pattern:gsub("%%%%", prj.name) fname = path.join(prj.location, fname) return path.getrelative(os.getcwd(), fname) end function premake.getlinks(cfg, kind, part) local result = iif (part == "directory" and kind == "all", cfg.libdirs, {}) local cfgname = iif(cfg.name == cfg.project.name, "", cfg.name) local pathstyle = premake.getpathstyle(cfg) local namestyle = premake.getnamestyle(cfg) local function canlink(source, target) if (target.kind ~= "SharedLib" and target.kind ~= "StaticLib") then return false end if premake.iscppproject(source) then return premake.iscppproject(target) elseif premake.isdotnetproject(source) then return premake.isdotnetproject(target) end end for _, link in ipairs(cfg.links) do local item local prj = premake.findproject(link) if prj and kind ~= "system" then local prjcfg = premake.getconfig(prj, cfgname, cfg.platform) if kind == "dependencies" or canlink(cfg, prjcfg) then if (part == "directory") then item = path.rebase(prjcfg.linktarget.directory, prjcfg.location, cfg.location) elseif (part == "basename") then item = prjcfg.linktarget.basename elseif (part == "fullpath") then item = path.rebase(prjcfg.linktarget.fullpath, prjcfg.location, cfg.location) elseif (part == "object") then item = prjcfg end end elseif not prj and (kind == "system" or kind == "all") then if (part == "directory") then local dir = path.getdirectory(link) if (dir ~= ".") then item = dir end elseif (part == "fullpath") then item = link if namestyle == "windows" then if premake.iscppproject(cfg) then item = item .. ".lib" elseif premake.isdotnetproject(cfg) then item = item .. ".dll" end end if item:find("/", nil, true) then item = path.getrelative(cfg.basedir, item) end else item = link end end if item then if pathstyle == "windows" and part ~= "object" then item = path.translate(item, "\\") end if not table.contains(result, item) then table.insert(result, item) end end end return result end function premake.getnamestyle(cfg) return premake.platforms[cfg.platform].namestyle or premake.gettool(cfg).namestyle or "posix" end function premake.getpathstyle(cfg) if premake.action.current().os == "windows" then return "windows" else return "posix" end end function premake.gettarget(cfg, direction, pathstyle, namestyle, system) if system == "bsd" or system == "solaris" then system = "linux" end local kind = cfg.kind if premake.iscppproject(cfg) then if (namestyle == "windows" or system == "windows") and kind == "SharedLib" and direction == "link" then kind = "StaticLib" end if namestyle == "posix" and system == "windows" and kind ~= "StaticLib" then namestyle = "windows" end end local field = iif(direction == "build", "target", "implib") local name = cfg[field.."name"] or cfg.targetname or cfg.project.name local dir = cfg[field.."dir"] or cfg.targetdir or path.getrelative(cfg.location, cfg.basedir) local prefix = "" local suffix = "" local ext = "" local bundlepath, bundlename if namestyle == "windows" then if kind == "ConsoleApp" or kind == "WindowedApp" then ext = ".exe" elseif kind == "SharedLib" then ext = ".dll" elseif kind == "StaticLib" then ext = ".lib" end elseif namestyle == "posix" then if kind == "WindowedApp" and system == "macosx" then bundlename = name .. ".app" bundlepath = path.join(dir, bundlename) dir = path.join(bundlepath, "Contents/MacOS") elseif kind == "SharedLib" then prefix = "lib" ext = iif(system == "macosx", ".dylib", ".so") elseif kind == "StaticLib" then prefix = "lib" ext = ".a" end elseif namestyle == "PS3" then if kind == "ConsoleApp" or kind == "WindowedApp" then ext = ".elf" elseif kind == "StaticLib" then prefix = "lib" ext = ".a" end end prefix = cfg[field.."prefix"] or cfg.targetprefix or prefix suffix = cfg[field.."suffix"] or cfg.targetsuffix or suffix ext = cfg[field.."extension"] or cfg.targetextension or ext local result = { } result.basename = name .. suffix result.name = prefix .. name .. suffix .. ext result.directory = dir result.prefix = prefix result.suffix = suffix result.fullpath = path.join(result.directory, result.name) result.bundlepath = bundlepath or result.fullpath if pathstyle == "windows" then result.directory = path.translate(result.directory, "\\") result.fullpath = path.translate(result.fullpath, "\\") end return result end function premake.gettool(cfg) if premake.iscppproject(cfg) then if _OPTIONS.cc then return premake[_OPTIONS.cc] end local action = premake.action.current() if action.valid_tools then return premake[action.valid_tools.cc[1]] end return premake.gcc else return premake.dotnet end end function premake.project.getvpath(prj, filename) local vpath = filename for replacement,patterns in pairs(prj.vpaths) do for _,pattern in ipairs(patterns) do local i = vpath:find(path.wildcards(pattern)) if i == 1 then i = pattern:find("*", 1, true) or (pattern:len() + 1) local leaf = vpath:sub(i) if leaf:startswith("/") then leaf = leaf:sub(2) end local stem = "" if replacement:len() > 0 then stem, stars = replacement:gsub("%*", "") if stars == 0 then leaf = path.getname(leaf) end end vpath = path.join(stem, leaf) end end end local changed repeat changed = true if vpath:startswith("./") then vpath = vpath:sub(3) elseif vpath:startswith("../") then vpath = vpath:sub(4) else changed = false end until not changed return vpath end function premake.hascppproject(sln) for prj in premake.solution.eachproject(sln) do if premake.iscppproject(prj) then return true end end end function premake.hasdotnetproject(sln) for prj in premake.solution.eachproject(sln) do if premake.isdotnetproject(prj) then return true end end end function premake.iscppproject(prj) return (prj.language == "C" or prj.language == "C++") end function premake.isdotnetproject(prj) return (prj.language == "C#") end premake.config = { } local config = premake.config function premake.config.isdebugbuild(cfg) if cfg.flags.Optimize or cfg.flags.OptimizeSize or cfg.flags.OptimizeSpeed then return false end if not cfg.flags.Symbols then return false end return true end function premake.config.isincrementallink(cfg) if cfg.kind == "StaticLib" or config.isoptimizedbuild(cfg.flags) or cfg.flags.NoIncrementalLink then return false end return true end function premake.config.isoptimizedbuild(flags) return flags.Optimize or flags.OptimizeSize or flags.OptimizeSpeed end premake.bake = { } local bake = premake.bake local nocopy = { blocks = true, keywords = true, projects = true, __configs = true, } local keeprelative = { basedir = true, location = true, } function premake.getactiveterms() local terms = { _action = _ACTION:lower(), os = os.get() } for key, value in pairs(_OPTIONS) do if value ~= "" then table.insert(terms, value:lower()) else table.insert(terms, key:lower()) end end return terms end function premake.iskeywordmatch(keyword, terms) if keyword:startswith("not ") then return not premake.iskeywordmatch(keyword:sub(5), terms) end for _, pattern in ipairs(keyword:explode(" or ")) do for termkey, term in pairs(terms) do if term:match(pattern) == term then return termkey end end end end function premake.iskeywordsmatch(keywords, terms) local hasrequired = false for _, keyword in ipairs(keywords) do local matched = premake.iskeywordmatch(keyword, terms) if not matched then return false end if matched == "required" then hasrequired = true end end if terms.required and not hasrequired then return false else return true end end local function adjustpaths(location, obj) for name, value in pairs(obj) do local field = premake.fields[name] if field and value and not keeprelative[name] then if field.kind == "path" then obj[name] = path.getrelative(location, value) elseif field.kind == "dirlist" or field.kind == "filelist" then for i, p in ipairs(value) do value[i] = path.getrelative(location, p) end end end end end local function mergefield(kind, dest, src) local tbl = dest or { } if kind == "keyvalue" then for key, value in pairs(src) do tbl[key] = mergefield("list", tbl[key], value) end else for _, item in ipairs(src) do if not tbl[item] then table.insert(tbl, item) tbl[item] = item end end end return tbl end local function mergeobject(dest, src) if not src then return end for fieldname, value in pairs(src) do if not nocopy[fieldname] then local field = premake.fields[fieldname] if field then if type(value) == "table" then dest[fieldname] = mergefield(field.kind, dest[fieldname], value) else dest[fieldname] = value end else dest[fieldname] = value end end end end local function merge(dest, obj, basis, terms, cfgname, pltname) local key = cfgname or "" pltname = pltname or "Native" if pltname ~= "Native" then key = key .. pltname end terms.config = (cfgname or ""):lower() terms.platform = pltname:lower() local cfg = {} mergeobject(cfg, basis[key]) adjustpaths(obj.location, cfg) mergeobject(cfg, obj) if (cfg.kind) then terms['kind']=cfg.kind:lower() end for _, blk in ipairs(obj.blocks) do if (premake.iskeywordsmatch(blk.keywords, terms))then mergeobject(cfg, blk) if (cfg.kind and not cfg.terms.kind) then cfg.terms['kind'] = cfg.kind:lower() terms['kind'] = cfg.kind:lower() end end end cfg.name = cfgname cfg.platform = pltname for k,v in pairs(terms) do cfg.terms[k] =v end dest[key] = cfg end local function collapse(obj, basis) local result = {} basis = basis or {} local sln = obj.solution or obj local terms = premake.getactiveterms() merge(result, obj, basis, terms)--this adjusts terms for _, cfgname in ipairs(sln.configurations) do local terms_local = {} for k,v in pairs(terms)do terms_local[k]=v end merge(result, obj, basis, terms_local, cfgname, "Native")--terms cam also be adjusted here for _, pltname in ipairs(sln.platforms or {}) do if pltname ~= "Native" then merge(result, obj, basis,terms_local, cfgname, pltname)--terms also here end end end return result end local function builduniquedirs() local num_variations = 4 local cfg_dirs = {} local hit_counts = {} for sln in premake.solution.each() do for _, prj in ipairs(sln.projects) do for _, cfg in pairs(prj.__configs) do local dirs = { } dirs[1] = path.getabsolute(path.join(cfg.location, cfg.objdir or cfg.project.objdir or "obj")) dirs[2] = path.join(dirs[1], iif(cfg.platform == "Native", "", cfg.platform)) dirs[3] = path.join(dirs[2], cfg.name) dirs[4] = path.join(dirs[3], cfg.project.name) cfg_dirs[cfg] = dirs local start = iif(cfg.name, 2, 1) for v = start, num_variations do local d = dirs[v] hit_counts[d] = (hit_counts[d] or 0) + 1 end end end end for sln in premake.solution.each() do for _, prj in ipairs(sln.projects) do for _, cfg in pairs(prj.__configs) do local dir local start = iif(cfg.name, 2, 1) for v = start, num_variations do dir = cfg_dirs[cfg][v] if hit_counts[dir] == 1 then break end end cfg.objectsdir = path.getrelative(cfg.location, dir) end end end end local function buildtargets() for sln in premake.solution.each() do for _, prj in ipairs(sln.projects) do for _, cfg in pairs(prj.__configs) do local pathstyle = premake.getpathstyle(cfg) local namestyle = premake.getnamestyle(cfg) cfg.buildtarget = premake.gettarget(cfg, "build", pathstyle, namestyle, cfg.system) cfg.linktarget = premake.gettarget(cfg, "link", pathstyle, namestyle, cfg.system) if pathstyle == "windows" then cfg.objectsdir = path.translate(cfg.objectsdir, "\\") end end end end end local function getCfgKind(cfg) if(cfg.kind) then return cfg.kind; end if(cfg.project.__configs[""] and cfg.project.__configs[""].kind) then return cfg.project.__configs[""].kind; end return nil end local function getprojrec(dstArray, foundList, cfg, cfgname, searchField, bLinkage) if(not cfg) then return end local foundUsePrjs = {}; for _, useName in ipairs(cfg[searchField]) do local testName = useName:lower(); if((not foundList[testName])) then local theProj = nil; local theUseProj = nil; for _, prj in ipairs(cfg.project.solution.projects) do if (prj.name:lower() == testName) then if(prj.usage) then theUseProj = prj; else theProj = prj; end end end --Must connect to a usage project. if(theUseProj) then foundList[testName] = true; local prjEntry = { name = testName, proj = theProj, usageProj = theUseProj, bLinkageOnly = bLinkage, }; dstArray[testName] = prjEntry; table.insert(foundUsePrjs, theUseProj); end end end for _, usePrj in ipairs(foundUsePrjs) do --Links can only recurse through static libraries. if((searchField ~= "links") or (getCfgKind(usePrj.__configs[cfgname]) == "StaticLib")) then getprojrec(dstArray, foundList, usePrj.__configs[cfgname], cfgname, searchField, bLinkage); end end end -- -- This function will recursively get all projects that the given configuration has in its "uses" -- field. The return values are a list of tables. Each table in that list contains the following: --name = The lowercase name of the project. --proj = The project. Can be nil if it is usage-only. --usageProj = The usage project. Can't be nil, as using a project that has no -- usage project is not put into the list. --bLinkageOnly = If this is true, then only the linkage information should be copied. -- The recursion will only look at the "uses" field on *usage* projects. -- This function will also add projects to the list that are mentioned in the "links" -- field of usage projects. These will only copy linker information, but they will recurse. -- through other "links" fields. -- local function getprojectsconnections(cfg, cfgname) local dstArray = {}; local foundList = {}; foundList[cfg.project.name:lower()] = true; --First, follow the uses recursively. getprojrec(dstArray, foundList, cfg, cfgname, "uses", false); --Next, go through all of the usage projects and recursively get their links. --But only if they're not already there. Get the links as linkage-only. local linkArray = {}; for prjName, prjEntry in pairs(dstArray) do getprojrec(linkArray, foundList, prjEntry.usageProj.__configs[cfgname], cfgname, "links", true); end --Copy from linkArray into dstArray. for prjName, prjEntry in pairs(linkArray) do dstArray[prjName] = prjEntry; end return dstArray; end local function isnameofproj(cfg, strName) local sln = cfg.project.solution; local strTest = strName:lower(); for prjIx, prj in ipairs(sln.projects) do if (prj.name:lower() == strTest) then return true; end end return false; end -- -- Copies the field from dstCfg to srcCfg. -- local function copydependentfield(srcCfg, dstCfg, strSrcField) local srcField = premake.fields[strSrcField]; local strDstField = strSrcField; if type(srcCfg[strSrcField]) == "table" then --handle paths. if (srcField.kind == "dirlist" or srcField.kind == "filelist") and (not keeprelative[strSrcField]) then for i,p in ipairs(srcCfg[strSrcField]) do table.insert(dstCfg[strDstField], path.rebase(p, srcCfg.project.location, dstCfg.project.location)) end else if(strSrcField == "links") then for i,p in ipairs(srcCfg[strSrcField]) do if(not isnameofproj(dstCfg, p)) then table.insert(dstCfg[strDstField], p) else printf("Failed to copy '%s' from proj '%s'.", p, srcCfg.project.name); end end else for i,p in ipairs(srcCfg[strSrcField]) do table.insert(dstCfg[strDstField], p) end end end else if(srcField.kind == "path" and (not keeprelative[strSrcField])) then dstCfg[strDstField] = path.rebase(srcCfg[strSrcField], prj.location, dstCfg.project.location); else dstCfg[strDstField] = srcCfg[strSrcField]; end end end -- -- This function will take the list of project entries and apply their usage project data -- to the given configuration. It will copy compiling information for the projects that are -- not listed as linkage-only. It will copy the linking information for projects only if -- the source project is not a static library. It won't copy linking information -- if the project is in this solution; instead it will add that project to the configuration's -- links field, expecting that Premake will handle the rest. -- local function copyusagedata(cfg, cfgname, linkToProjs) local myPrj = cfg.project; local bIsStaticLib = (getCfgKind(cfg) == "StaticLib"); for prjName, prjEntry in pairs(linkToProjs) do local srcPrj = prjEntry.usageProj; local srcCfg = srcPrj.__configs[cfgname]; for name, field in pairs(premake.fields) do if(srcCfg[name]) then if(field.usagecopy) then if(not prjEntry.bLinkageOnly) then copydependentfield(srcCfg, cfg, name) end elseif(field.linkagecopy) then --Copy the linkage data if we're building a non-static thing --and this is a pure usage project. If it's not pure-usage, then --we will simply put the project's name in the links field later. if((not bIsStaticLib) and (not prjEntry.proj)) then copydependentfield(srcCfg, cfg, name) end end end end if((not bIsStaticLib) and prjEntry.proj) then table.insert(cfg.links, prjEntry.proj.name); end end end function premake.bake.buildconfigs() for sln in premake.solution.each() do for _, prj in ipairs(sln.projects) do prj.location = prj.location or sln.location or prj.basedir adjustpaths(prj.location, prj) for _, blk in ipairs(prj.blocks) do adjustpaths(prj.location, blk) end end sln.location = sln.location or sln.basedir end for sln in premake.solution.each() do local basis = collapse(sln) for _, prj in ipairs(sln.projects) do prj.__configs = collapse(prj, basis) for _, cfg in pairs(prj.__configs) do bake.postprocess(prj, cfg) end end end for sln in premake.solution.each() do for prjIx, prj in ipairs(sln.projects) do if(not prj.usage) then for cfgname, cfg in pairs(prj.__configs) do local usesPrjs = getprojectsconnections(cfg, cfgname); copyusagedata(cfg, cfgname, usesPrjs) end end end end for sln in premake.solution.each() do local removeList = {}; for index, prj in ipairs(sln.projects) do if(prj.usage) then table.insert(removeList, 1, index); --Add in reverse order. end end for _, index in ipairs(removeList) do table.remove(sln.projects, index); end end builduniquedirs() buildtargets(cfg) end function premake.bake.postprocess(prj, cfg) cfg.project = prj cfg.shortname = premake.getconfigname(cfg.name, cfg.platform, true) cfg.longname = premake.getconfigname(cfg.name, cfg.platform) cfg.location = cfg.location or cfg.basedir local platform = premake.platforms[cfg.platform] if platform.iscrosscompiler then cfg.system = cfg.platform else cfg.system = os.get() end if cfg.kind == "SharedLib" and platform.nosharedlibs then cfg.kind = "StaticLib" end local files = { } for _, fname in ipairs(cfg.files) do local excluded = false for _, exclude in ipairs(cfg.excludes) do excluded = (fname == exclude) if (excluded) then break end end if (not excluded) then table.insert(files, fname) end end cfg.files = files for name, field in pairs(premake.fields) do if field.isflags then local values = cfg[name] for _, flag in ipairs(values) do values[flag] = true end end end cfg.__fileconfigs = { } for _, fname in ipairs(cfg.files) do cfg.terms.required = fname:lower() local fcfg = {} for _, blk in ipairs(cfg.project.blocks) do if (premake.iskeywordsmatch(blk.keywords, cfg.terms)) then mergeobject(fcfg, blk) end end fcfg.name = fname cfg.__fileconfigs[fname] = fcfg table.insert(cfg.__fileconfigs, fcfg) end end premake.fields = { basedir = { kind = "path", scope = "container", }, buildaction = { kind = "string", scope = "config", allowed = { "Compile", "Copy", "Embed", "None" } }, buildoptions = { kind = "list", scope = "config", }, configurations = { kind = "list", scope = "solution", }, debugargs = { kind = "list", scope = "config", }, debugdir = { kind = "path", scope = "config", }, defines = { kind = "list", scope = "config", }, deploymentoptions = { kind = "list", scope = "config", usagecopy = true, }, excludes = { kind = "filelist", scope = "config", }, files = { kind = "filelist", scope = "config", }, flags = { kind = "list", scope = "config", isflags = true, usagecopy = true, allowed = function(value) local allowed_flags = { EnableSSE = 1, EnableSSE2 = 1, ExtraWarnings = 1, FatalWarnings = 1, FloatFast = 1, FloatStrict = 1, Managed = 1, MFC = 1, NativeWChar = 1, No64BitChecks = 1, NoEditAndContinue = 1, NoExceptions = 1, NoFramePointer = 1, NoImportLib = 1, NoIncrementalLink = 1, NoManifest = 1, NoMinimalRebuild = 1, NoNativeWChar = 1, NoPCH = 1, NoRTTI = 1, Optimize = 1, OptimizeSize = 1, OptimizeSpeed = 1, SEH = 1, StaticRuntime = 1, Symbols = 1, Unicode = 1, Unsafe = 1, WinMain = 1 } local englishToAmericanSpelling = { Optimise = 'Optimize', OptimiseSize = 'OptimizeSize', OptimiseSpeed = 'OptimizeSpeed' } if englishToAmericanSpelling[value] then value = englishToAmericanSpelling[value] end if allowed_flags[value] then return value else return nil, "invalid flag" end end, }, framework = { kind = "string", scope = "container", allowed = { "1.0", "1.1", "2.0", "3.0", "3.5", "4.0" } }, imagepath = { kind = "path", scope = "config", }, imageoptions = { kind = "list", scope = "config", }, implibdir = { kind = "path", scope = "config", }, implibextension = { kind = "string", scope = "config", }, implibname = { kind = "string", scope = "config", }, implibprefix = { kind = "string", scope = "config", }, implibsuffix = { kind = "string", scope = "config", }, includedirs = { kind = "dirlist", scope = "config", usagecopy = true, }, kind = { kind = "string", scope = "config", allowed = { "ConsoleApp", "WindowedApp", "StaticLib", "SharedLib" } }, language = { kind = "string", scope = "container", allowed = { "C", "C++", "C#" } }, libdirs = { kind = "dirlist", scope = "config", linkagecopy = true, }, linkoptions = { kind = "list", scope = "config", }, links = { kind = "list", scope = "config", allowed = function(value) if value:find('/', nil, true) then value = path.getabsolute(value) end return value end, linkagecopy = true, }, location = { kind = "path", scope = "container", }, objdir = { kind = "path", scope = "config", }, pchheader = { kind = "string", scope = "config", }, pchsource = { kind = "path", scope = "config", }, platforms = { kind = "list", scope = "solution", allowed = table.keys(premake.platforms), }, postbuildcommands = { kind = "list", scope = "config", }, prebuildcommands = { kind = "list", scope = "config", }, prelinkcommands = { kind = "list", scope = "config", }, resdefines = { kind = "list", scope = "config", }, resincludedirs = { kind = "dirlist", scope = "config", }, resoptions = { kind = "list", scope = "config", }, targetdir = { kind = "path", scope = "config", }, targetextension = { kind = "string", scope = "config", }, targetname = { kind = "string", scope = "config", }, targetprefix = { kind = "string", scope = "config", }, targetsuffix = { kind = "string", scope = "config", }, trimpaths = { kind = "dirlist", scope = "config", }, uuid = { kind = "string", scope = "container", allowed = function(value) local ok = true if (#value ~= 36) then ok = false end for i=1,36 do local ch = value:sub(i,i) if (not ch:find("[ABCDEFabcdef0123456789-]")) then ok = false end end if (value:sub(9,9) ~= "-") then ok = false end if (value:sub(14,14) ~= "-") then ok = false end if (value:sub(19,19) ~= "-") then ok = false end if (value:sub(24,24) ~= "-") then ok = false end if (not ok) then return nil, "invalid UUID" end return value:upper() end }, uses = { kind = "list", scope = "config", }, vpaths = { kind = "keyvalue", scope = "container", }, } function premake.checkvalue(value, allowed) if (allowed) then if (type(allowed) == "function") then return allowed(value) else for _,v in ipairs(allowed) do if (value:lower() == v:lower()) then return v end end return nil, "invalid value '" .. value .. "'" end else return value end end function premake.getobject(t) local container if (t == "container" or t == "solution") then container = premake.CurrentContainer else container = premake.CurrentConfiguration end if t == "solution" then if type(container) == "project" then container = container.solution end if type(container) ~= "solution" then container = nil end end local msg if (not container) then if (t == "container") then msg = "no active solution or project" elseif (t == "solution") then msg = "no active solution" else msg = "no active solution, project, or configuration" end end return container, msg end function premake.setarray(ctype, fieldname, value, allowed) local container, err = premake.getobject(ctype) if (not container) then error(err, 4) end if (not container[fieldname]) then container[fieldname] = { } end local function doinsert(value, depth) if (type(value) == "table") then for _,v in ipairs(value) do doinsert(v, depth + 1) end else value, err = premake.checkvalue(value, allowed) if (not value) then error(err, depth) end table.insert(container[fieldname], value) end end if (value) then doinsert(value, 5) end return container[fieldname] end local function domatchedarray(ctype, fieldname, value, matchfunc) local result = { } function makeabsolute(value, depth) if (type(value) == "table") then for _, item in ipairs(value) do makeabsolute(item, depth + 1) end elseif type(value) == "string" then if value:find("*") then makeabsolute(matchfunc(value), depth + 1) else table.insert(result, path.getabsolute(value)) end else error("Invalid value in list: expected string, got " .. type(value), depth) end end makeabsolute(value, 3) return premake.setarray(ctype, fieldname, result) end function premake.setdirarray(ctype, fieldname, value) return domatchedarray(ctype, fieldname, value, os.matchdirs) end function premake.setfilearray(ctype, fieldname, value) return domatchedarray(ctype, fieldname, value, os.matchfiles) end function premake.setkeyvalue(ctype, fieldname, values) local container, err = premake.getobject(ctype) if not container then error(err, 4) end if not container[fieldname] then container[fieldname] = {} end if type(values) ~= "table" then error("invalid value; table expected", 4) end local field = container[fieldname] for key,value in pairs(values) do if not field[key] then field[key] = {} end table.insertflat(field[key], value) end return field end function premake.setstring(ctype, fieldname, value, allowed) local container, err = premake.getobject(ctype) if (not container) then error(err, 4) end if (value) then value, err = premake.checkvalue(value, allowed) if (not value) then error(err, 4) end container[fieldname] = value end return container[fieldname] end local function accessor(name, value) local kind = premake.fields[name].kind local scope = premake.fields[name].scope local allowed = premake.fields[name].allowed if (kind == "string" or kind == "path") and value then if type(value) ~= "string" then error("string value expected", 3) end end if kind == "string" then return premake.setstring(scope, name, value, allowed) elseif kind == "path" then if value then value = path.getabsolute(value) end return premake.setstring(scope, name, value) elseif kind == "list" then return premake.setarray(scope, name, value, allowed) elseif kind == "dirlist" then return premake.setdirarray(scope, name, value) elseif kind == "filelist" then return premake.setfilearray(scope, name, value) elseif kind == "keyvalue" then return premake.setkeyvalue(scope, name, value) end end for name,_ in pairs(premake.fields) do _G[name] = function(value) return accessor(name, value) end end function configuration(terms) if not terms then return premake.CurrentConfiguration end local container, err = premake.getobject("container") if (not container) then error(err, 2) end local cfg = { } cfg.terms = table.flatten({terms}) table.insert(container.blocks, cfg) premake.CurrentConfiguration = cfg cfg.keywords = { } for _, word in ipairs(cfg.terms) do table.insert(cfg.keywords, path.wildcards(word):lower()) end for name, field in pairs(premake.fields) do if (field.kind ~= "string" and field.kind ~= "path") then cfg[name] = { } end end return cfg end local function createproject(name, sln, isUsage) local prj = {} setmetatable(prj, { __type = "project", }) table.insert(sln.projects, prj) if(isUsage) then if(sln.projects[name]) then sln.projects[name].usageProj = prj; else sln.projects[name] = prj end else if(sln.projects[name]) then prj.usageProj = sln.projects[name]; end sln.projects[name] = prj end prj.solution = sln prj.name = name prj.basedir = os.getcwd() prj.uuid = os.uuid() prj.blocks = { } prj.usage = isUsage; return prj; end function usage(name) if (not name) then if(type(premake.CurrentContainer) ~= "project") then return nil end if(not premake.CurrentContainer.usage) then return nil end return premake.CurrentContainer end local sln if (type(premake.CurrentContainer) == "project") then sln = premake.CurrentContainer.solution else sln = premake.CurrentContainer end if (type(sln) ~= "solution") then error("no active solution", 2) end -- if this is a new project, or the project in that slot doesn't have a usage, create it if((not sln.projects[name]) or ((not sln.projects[name].usage) and (not sln.projects[name].usageProj))) then premake.CurrentContainer = createproject(name, sln, true) else premake.CurrentContainer = iff(sln.projects[name].usage, sln.projects[name], sln.projects[name].usageProj) end -- add an empty, global configuration to the project configuration { } return premake.CurrentContainer end function project(name) if (not name) then --Only return non-usage projects if(type(premake.CurrentContainer) ~= "project") then return nil end if(premake.CurrentContainer.usage) then return nil end return premake.CurrentContainer end -- identify the parent solution local sln if (type(premake.CurrentContainer) == "project") then sln = premake.CurrentContainer.solution else sln = premake.CurrentContainer end if (type(sln) ~= "solution") then error("no active solution", 2) end -- if this is a new project, or the old project is a usage project, create it if((not sln.projects[name]) or sln.projects[name].usage) then premake.CurrentContainer = createproject(name, sln) else premake.CurrentContainer = sln.projects[name]; end configuration { } return premake.CurrentContainer end function solution(name) if not name then if type(premake.CurrentContainer) == "project" then return premake.CurrentContainer.solution else return premake.CurrentContainer end end premake.CurrentContainer = premake.solution.get(name) if (not premake.CurrentContainer) then premake.CurrentContainer = premake.solution.new(name) end configuration { } return premake.CurrentContainer end function newaction(a) premake.action.add(a) end function newoption(opt) premake.option.add(opt) end newoption { trigger = "cc", value = "VALUE", description = "Choose a C/C++ compiler set", allowed = { { "gcc", "GNU GCC (gcc/g++)" }, { "ow", "OpenWatcom" }, } } newoption { trigger = "dotnet", value = "VALUE", description = "Choose a .NET compiler set", allowed = { { "msnet", "Microsoft .NET (csc)" }, { "mono", "Novell Mono (mcs)" }, { "pnet", "Portable.NET (cscc)" }, } } newoption { trigger = "file", value = "FILE", description = "Read FILE as a Premake script; default is 'premake4.lua'" } newoption { trigger = "help", description = "Display this information" } newoption { trigger = "os", value = "VALUE", description = "Generate files for a different operating system", allowed = { { "bsd", "OpenBSD, NetBSD, or FreeBSD" }, { "haiku", "Haiku" }, { "linux", "Linux" }, { "macosx", "Apple Mac OS X" }, { "solaris", "Solaris" }, { "windows", "Microsoft Windows" }, } } 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" }, { "ps3", "Playstation 3 (experimental)" }, { "xbox360", "Xbox 360 (experimental)" }, } } newoption { trigger = "scripts", value = "path", description = "Search for additional scripts on the given path" } newoption { trigger = "version", description = "Display version information" } premake.dotnet = { } premake.dotnet.namestyle = "windows" local flags = { FatalWarning = "/warnaserror", Optimize = "/optimize", OptimizeSize = "/optimize", OptimizeSpeed = "/optimize", Symbols = "/debug", Unsafe = "/unsafe" } function premake.dotnet.getbuildaction(fcfg) local ext = path.getextension(fcfg.name):lower() if fcfg.buildaction == "Compile" or ext == ".cs" then return "Compile" elseif fcfg.buildaction == "Embed" or ext == ".resx" then return "EmbeddedResource" elseif fcfg.buildaction == "Copy" or ext == ".asax" or ext == ".aspx" then return "Content" else return "None" end end function premake.dotnet.getcompilervar(cfg) if (_OPTIONS.dotnet == "msnet") then return "csc" elseif (_OPTIONS.dotnet == "mono") then if (cfg.framework <= "1.1") then return "mcs" elseif (cfg.framework >= "4.0") then return "dmcs" else return "gmcs" end else return "cscc" end end function premake.dotnet.getflags(cfg) local result = table.translate(cfg.flags, flags) return result end function premake.dotnet.getkind(cfg) if (cfg.kind == "ConsoleApp") then return "Exe" elseif (cfg.kind == "WindowedApp") then return "WinExe" elseif (cfg.kind == "SharedLib") then return "Library" end endpremake.gcc = { } premake.gcc.cc = "gcc" premake.gcc.cxx = "g++" premake.gcc.ar = "ar" local cflags = { EnableSSE = "-msse", EnableSSE2 = "-msse2", ExtraWarnings = "-Wall", FatalWarnings = "-Werror", FloatFast = "-ffast-math", FloatStrict = "-ffloat-store", NoFramePointer = "-fomit-frame-pointer", Optimize = "-O2", OptimizeSize = "-Os", OptimizeSpeed = "-O3", Symbols = "-g", } local cxxflags = { NoExceptions = "-fno-exceptions", NoRTTI = "-fno-rtti", } premake.gcc.platforms = { Native = { cppflags = "-MMD", }, x32 = { cppflags = "-MMD", flags = "-m32", ldflags = "-L/usr/lib32", }, x64 = { cppflags = "-MMD", flags = "-m64", ldflags = "-L/usr/lib64", }, Universal = { cppflags = "", flags = "-arch i386 -arch x86_64 -arch ppc -arch ppc64", }, Universal32 = { cppflags = "", flags = "-arch i386 -arch ppc", }, Universal64 = { cppflags = "", flags = "-arch x86_64 -arch ppc64", }, PS3 = { cc = "ppu-lv2-g++", cxx = "ppu-lv2-g++", ar = "ppu-lv2-ar", cppflags = "-MMD", } } local platforms = premake.gcc.platforms function premake.gcc.getcppflags(cfg) local flags = { } table.insert(flags, platforms[cfg.platform].cppflags) if flags[1]:startswith("-MMD") and cfg.system ~= "haiku" then table.insert(flags, "-MP") end return flags end function premake.gcc.getcflags(cfg) local result = table.translate(cfg.flags, cflags) table.insert(result, platforms[cfg.platform].flags) if cfg.system ~= "windows" and cfg.kind == "SharedLib" then table.insert(result, "-fPIC") end return result end function premake.gcc.getcxxflags(cfg) local result = table.translate(cfg.flags, cxxflags) return result end function premake.gcc.getldflags(cfg) local result = { } if not cfg.flags.Symbols then if cfg.system == "macosx" then table.insert(result, "-Wl,-x") else table.insert(result, "-s") end end if cfg.kind == "SharedLib" then if cfg.system == "macosx" then result = table.join(result, { "-dynamiclib", "-flat_namespace" }) else table.insert(result, "-shared") end if cfg.system == "windows" and not cfg.flags.NoImportLib then table.insert(result, '-Wl,--out-implib="' .. cfg.linktarget.fullpath .. '"') end end if cfg.kind == "WindowedApp" and cfg.system == "windows" then table.insert(result, "-mwindows") end local platform = platforms[cfg.platform] table.insert(result, platform.flags) table.insert(result, platform.ldflags) return result end function premake.gcc.getlibdirflags(cfg) local result = { } for _, value in ipairs(premake.getlinks(cfg, "all", "directory")) do table.insert(result, '-L' .. _MAKE.esc(value)) end return result end function premake.gcc.getlinkflags(cfg) local result = { } for _, value in ipairs(premake.getlinks(cfg, "siblings", "object")) do if (value.kind == "StaticLib") then local pathstyle = premake.getpathstyle(value) local namestyle = premake.getnamestyle(value) local linktarget = premake.gettarget(value, "link", pathstyle, namestyle, cfg.system) local rebasedpath = path.rebase(linktarget.fullpath, value.location, cfg.location) table.insert(result, rebasedpath) else table.insert(result, '-l' .. _MAKE.esc(value.linktarget.basename)) end end for _, value in ipairs(premake.getlinks(cfg, "system", "basename")) do if path.getextension(value) == ".framework" then table.insert(result, '-framework ' .. _MAKE.esc(path.getbasename(value))) else table.insert(result, '-l' .. _MAKE.esc(value)) end end return result end function premake.gcc.getdefines(defines) local result = { } for _,def in ipairs(defines) do table.insert(result, '-D' .. def) end return result end function premake.gcc.getincludedirs(includedirs) local result = { } for _,dir in ipairs(includedirs) do table.insert(result, "-I" .. _MAKE.esc(dir)) end return result end premake.msc = { } premake.msc.namestyle = "windows" premake.ow = { } premake.ow.namestyle = "windows" premake.ow.cc = "WCL386" premake.ow.cxx = "WCL386" premake.ow.ar = "ar" local cflags = { ExtraWarnings = "-wx", FatalWarning = "-we", FloatFast = "-omn", FloatStrict = "-op", Optimize = "-ox", OptimizeSize = "-os", OptimizeSpeed = "-ot", Symbols = "-d2", } local cxxflags = { NoExceptions = "-xd", NoRTTI = "-xr", } premake.ow.platforms = { Native = { flags = "" }, } function premake.ow.getcppflags(cfg) return {} end function premake.ow.getcflags(cfg) local result = table.translate(cfg.flags, cflags) if (cfg.flags.Symbols) then table.insert(result, "-hw") -- Watcom debug format for Watcom debugger end return result end function premake.ow.getcxxflags(cfg) local result = table.translate(cfg.flags, cxxflags) return result end function premake.ow.getldflags(cfg) local result = { } if (cfg.flags.Symbols) then table.insert(result, "op symf") end return result end function premake.ow.getlinkflags(cfg) local result = { } return result end function premake.ow.getdefines(defines) local result = { } for _,def in ipairs(defines) do table.insert(result, '-D' .. def) end return result end function premake.ow.getincludedirs(includedirs) local result = { } for _,dir in ipairs(includedirs) do table.insert(result, '-I "' .. dir .. '"') end return result end premake.snc = { } premake.snc.cc = "snc" premake.snc.cxx = "g++" premake.snc.ar = "ar" local cflags = { ExtraWarnings = "-Xdiag=2", FatalWarnings = "-Xquit=2", } local cxxflags = { NoExceptions = "", -- No exceptions is the default in the SNC compiler. NoRTTI = "-Xc-=rtti", } premake.snc.platforms = { PS3 = { cc = "ppu-lv2-g++", cxx = "ppu-lv2-g++", ar = "ppu-lv2-ar", cppflags = "-MMD -MP", } } local platforms = premake.snc.platforms function premake.snc.getcppflags(cfg) local result = { } table.insert(result, platforms[cfg.platform].cppflags) return result end function premake.snc.getcflags(cfg) local result = table.translate(cfg.flags, cflags) table.insert(result, platforms[cfg.platform].flags) if cfg.kind == "SharedLib" then table.insert(result, "-fPIC") end return result end function premake.snc.getcxxflags(cfg) local result = table.translate(cfg.flags, cxxflags) return result end function premake.snc.getldflags(cfg) local result = { } if not cfg.flags.Symbols then table.insert(result, "-s") end if cfg.kind == "SharedLib" then table.insert(result, "-shared") if not cfg.flags.NoImportLib then table.insert(result, '-Wl,--out-implib="' .. cfg.linktarget.fullpath .. '"') end end local platform = platforms[cfg.platform] table.insert(result, platform.flags) table.insert(result, platform.ldflags) return result end function premake.snc.getlibdirflags(cfg) local result = { } for _, value in ipairs(premake.getlinks(cfg, "all", "directory")) do table.insert(result, '-L' .. _MAKE.esc(value)) end return result end function premake.snc.getlinkflags(cfg) local result = { } for _, value in ipairs(premake.getlinks(cfg, "all", "basename")) do table.insert(result, '-l' .. _MAKE.esc(value)) end return result end function premake.snc.getdefines(defines) local result = { } for _,def in ipairs(defines) do table.insert(result, '-D' .. def) end return result end function premake.snc.getincludedirs(includedirs) local result = { } for _,dir in ipairs(includedirs) do table.insert(result, "-I" .. _MAKE.esc(dir)) end return result end function premake.checkprojects() local action = premake.action.current() for sln in premake.solution.each() do if (#sln.projects == 0) then return nil, "solution '" .. sln.name .. "' needs at least one project" end if (#sln.configurations == 0) then return nil, "solution '" .. sln.name .. "' needs configurations" end for prj in premake.solution.eachproject(sln) do if (not prj.language) then return nil, "project '" ..prj.name .. "' needs a language" end if (action.valid_languages) then if (not table.contains(action.valid_languages, prj.language)) then return nil, "the " .. action.shortname .. " action does not support " .. prj.language .. " projects" end end for cfg in premake.eachconfig(prj) do if (not cfg.kind) then return nil, "project '" ..prj.name .. "' needs a kind in configuration '" .. cfg.name .. "'" end if (action.valid_kinds) then if (not table.contains(action.valid_kinds, cfg.kind)) then return nil, "the " .. action.shortname .. " action does not support " .. cfg.kind .. " projects" end end end if action.oncheckproject then action.oncheckproject(prj) end end end return true end function premake.checktools() local action = premake.action.current() if (not action.valid_tools) then return true end for tool, values in pairs(action.valid_tools) do if (_OPTIONS[tool]) then if (not table.contains(values, _OPTIONS[tool])) then return nil, "the " .. action.shortname .. " action does not support /" .. tool .. "=" .. _OPTIONS[tool] .. " (yet)" end else _OPTIONS[tool] = values[1] end end return true end function premake.showhelp() printf("Premake %s, a build script generator", _PREMAKE_VERSION) printf(_PREMAKE_COPYRIGHT) printf("%s %s", _VERSION, _COPYRIGHT) printf("") printf("Usage: premake4 [options] action [arguments]") printf("") printf("OPTIONS") printf("") for option in premake.option.each() do local trigger = option.trigger local description = option.description if (option.value) then trigger = trigger .. "=" .. option.value end if (option.allowed) then description = description .. "; one of:" end printf(" --%-15s %s", trigger, description) if (option.allowed) then for _, value in ipairs(option.allowed) do printf(" %-14s %s", value[1], value[2]) end end printf("") end printf("ACTIONS") printf("") for action in premake.action.each() do printf(" %-17s %s", action.trigger, action.description) end printf("") printf("For additional information, see http://industriousone.com/premake") end function premake.generate(obj, filename, callback) filename = premake.project.getfilename(obj, filename) printf("Generating %s...", filename) local f, err = io.open(filename, "wb") if (not f) then error(err, 0) end io.output(f) callback(obj) f:close() end premake.codeblocks = { } newaction { trigger = "codeblocks", shortname = "Code::Blocks", description = "Generate Code::Blocks project files", valid_kinds = { "ConsoleApp", "WindowedApp", "StaticLib", "SharedLib" }, valid_languages = { "C", "C++" }, valid_tools = { cc = { "gcc", "ow" }, }, onsolution = function(sln) premake.generate(sln, "%%.workspace", premake.codeblocks.workspace) end, onproject = function(prj) premake.generate(prj, "%%.cbp", premake.codeblocks.cbp) end, oncleansolution = function(sln) premake.clean.file(sln, "%%.workspace") end, oncleanproject = function(prj) premake.clean.file(prj, "%%.cbp") premake.clean.file(prj, "%%.depend") premake.clean.file(prj, "%%.layout") end } function premake.codeblocks.workspace(sln) _p('') _p('') _p(1,'', sln.name) for prj in premake.solution.eachproject(sln) do local fname = path.join(path.getrelative(sln.location, prj.location), prj.name) local active = iif(prj.project == sln.projects[1], ' active="1"', '') _p(2,'', fname, active) for _,dep in ipairs(premake.getdependencies(prj)) do _p(3,'', path.join(path.getrelative(sln.location, dep.location), dep.name)) end _p(2,'') end _p(1,'') _p('') end local codeblocks = premake.codeblocks function codeblocks.files(prj) local pchheader if (prj.pchheader) then pchheader = path.getrelative(prj.location, prj.pchheader) end for _,fname in ipairs(prj.files) do _p(2,'', premake.esc(fname)) if path.isresourcefile(fname) then _p(3,'') end end function premake.codeblocks.cbp(prj) local cc = premake.gettool(prj) _p('') _p('') _p(1,'') _p(1,'') _p(2,'') _p('') _p('') end premake.codelite = { } newaction { trigger = "codelite", shortname = "CodeLite", description = "Generate CodeLite project files", valid_kinds = { "ConsoleApp", "WindowedApp", "StaticLib", "SharedLib" }, valid_languages = { "C", "C++" }, valid_tools = { cc = { "gcc" }, }, onsolution = function(sln) premake.generate(sln, "%%.workspace", premake.codelite.workspace) end, onproject = function(prj) premake.generate(prj, "%%.project", premake.codelite.project) end, oncleansolution = function(sln) premake.clean.file(sln, "%%.workspace") premake.clean.file(sln, "%%_wsp.mk") premake.clean.file(sln, "%%.tags") end, oncleanproject = function(prj) premake.clean.file(prj, "%%.project") premake.clean.file(prj, "%%.mk") premake.clean.file(prj, "%%.list") premake.clean.file(prj, "%%.out") end } function premake.codelite.workspace(sln) _p('') _p('', premake.esc(sln.name), premake.esc(sln.name)) for i,prj in ipairs(sln.projects) do local name = premake.esc(prj.name) local fname = path.join(path.getrelative(sln.location, prj.location), prj.name) local active = iif(i==1, "Yes", "No") _p(' ', name, fname, active) end local platforms = premake.filterplatforms(sln, premake[_OPTIONS.cc].platforms, "Native") for i = #platforms, 1, -1 do if premake.platforms[platforms[i]].iscrosscompiler then table.remove(platforms, i) end end _p(' ') for _, platform in ipairs(platforms) do for _, cfgname in ipairs(sln.configurations) do local name = premake.getconfigname(cfgname, platform) _p(' ', name) for _,prj in ipairs(sln.projects) do _p(' ', prj.name, name) end _p(' ') end end _p(' ') _p('') end local codelite = premake.codelite local tree = premake.tree function codelite.files(prj) local tr = premake.project.buildsourcetree(prj) tree.traverse(tr, { onbranchenter = function(node, depth) _p(depth, '', node.name) end, onbranchexit = function(node, depth) _p(depth, '') end, onleaf = function(node, depth) _p(depth, '', node.cfg.name) end, }, false, 1) end function premake.codelite.project(prj) io.indent = " " _p('') _p('', premake.esc(prj.name)) codelite.files(prj) local types = { ConsoleApp = "Executable", WindowedApp = "Executable", StaticLib = "Static Library", SharedLib = "Dynamic Library", } _p(' ', types[prj.kind]) local platforms = premake.filterplatforms(prj.solution, premake[_OPTIONS.cc].platforms, "Native") for i = #platforms, 1, -1 do if premake.platforms[platforms[i]].iscrosscompiler then table.remove(platforms, i) end end for _, platform in ipairs(platforms) do for cfg in premake.eachconfig(prj, platform) do local name = premake.esc(cfg.longname) local compiler = iif(cfg.language == "C", "gcc", "g++") _p(' ', name, compiler, types[cfg.kind]) local fname = premake.esc(cfg.buildtarget.fullpath) local objdir = premake.esc(cfg.objectsdir) local runcmd = cfg.buildtarget.name local rundir = cfg.debugdir or cfg.buildtarget.directory local runargs = table.concat(cfg.debugargs, " ") local pause = iif(cfg.kind == "WindowedApp", "no", "yes") _p(' ', fname, objdir, runcmd, runargs, rundir, pause) local flags = premake.esc(table.join(premake.gcc.getcflags(cfg), premake.gcc.getcxxflags(cfg), cfg.buildoptions)) _p(' ', table.concat(flags, ";")) for _,v in ipairs(cfg.includedirs) do _p(' ', premake.esc(v)) end for _,v in ipairs(cfg.defines) do _p(' ', premake.esc(v)) end _p(' ') flags = premake.esc(table.join(premake.gcc.getldflags(cfg), cfg.linkoptions)) _p(' ', table.concat(flags, ";")) for _,v in ipairs(premake.getlinks(cfg, "all", "directory")) do _p(' ', premake.esc(v)) end for _,v in ipairs(premake.getlinks(cfg, "all", "basename")) do _p(' ', premake.esc(v)) end _p(' ') if premake.findfile(cfg, ".rc") then local defines = table.implode(table.join(cfg.defines, cfg.resdefines), "-D", ";", "") local options = table.concat(cfg.resoptions, ";") _p(' ', defines, options) for _,v in ipairs(table.join(cfg.includedirs, cfg.resincludedirs)) do _p(' ', premake.esc(v)) end _p(' ') else _p(' ') end if #cfg.prebuildcommands > 0 then _p(' ') for _,v in ipairs(cfg.prebuildcommands) do _p(' %s', premake.esc(v)) end _p(' ') end if #cfg.postbuildcommands > 0 then _p(' ') for _,v in ipairs(cfg.postbuildcommands) do _p(' %s', premake.esc(v)) end _p(' ') end _p(' ') _p(' ') _p(' ') _p(' ') _p(' ') _p(' None') _p(' ') _p(' ') _p(' ') _p(' ') _p(' ') _p(' ') _p(' ') end end _p(' ') for _, platform in ipairs(platforms) do for cfg in premake.eachconfig(prj, platform) do _p(' ', cfg.longname) for _,dep in ipairs(premake.getdependencies(prj)) do _p(' ', dep.name) end _p(' ') end end _p('') end _MAKE = { } premake.make = { } function _MAKE.esc(value) local result if (type(value) == "table") then result = { } for _,v in ipairs(value) do table.insert(result, _MAKE.esc(v)) end return result else result = value:gsub("\\", "\\\\") result = result:gsub(" ", "\\ ") result = result:gsub("%(", "\\%(") result = result:gsub("%)", "\\%)") result = result:gsub("$\\%((.-)\\%)", "$%(%1%)") return result end end function premake.make_copyrule(source, target) _p('%s: %s', target, source) _p('\t@echo Copying $(notdir %s)', target) _p('ifeq (posix,$(SHELLTYPE))') _p('\t$(SILENT) cp -fR %s %s', source, target) _p('else') _p('\t$(SILENT) copy /Y $(subst /,\\\\,%s) $(subst /,\\\\,%s)', source, target) _p('endif') end function premake.make_mkdirrule(var) _p('\t@echo Creating %s', var) _p('ifeq (posix,$(SHELLTYPE))') _p('\t$(SILENT) mkdir -p %s', var) _p('else') _p('\t$(SILENT) mkdir $(subst /,\\\\,%s)', var) _p('endif') _p('') end function _MAKE.getmakefilename(this, searchprjs) local count = 0 for sln in premake.solution.each() do if (sln.location == this.location) then count = count + 1 end if (searchprjs) then for _,prj in ipairs(sln.projects) do if (prj.location == this.location) then count = count + 1 end end end end if (count == 1) then return "Makefile" else return this.name .. ".make" end end function _MAKE.getnames(tbl) local result = table.extract(tbl, "name") for k,v in pairs(result) do result[k] = _MAKE.esc(v) end return result end newaction { trigger = "gmake", shortname = "GNU Make", description = "Generate GNU makefiles for POSIX, MinGW, and Cygwin", valid_kinds = { "ConsoleApp", "WindowedApp", "StaticLib", "SharedLib" }, valid_languages = { "C", "C++", "C#" }, valid_tools = { cc = { "gcc" }, dotnet = { "mono", "msnet", "pnet" }, }, onsolution = function(sln) premake.generate(sln, _MAKE.getmakefilename(sln, false), premake.make_solution) end, onproject = function(prj) local makefile = _MAKE.getmakefilename(prj, true) if premake.isdotnetproject(prj) then premake.generate(prj, makefile, premake.make_csharp) else premake.generate(prj, makefile, premake.make_cpp) end end, oncleansolution = function(sln) premake.clean.file(sln, _MAKE.getmakefilename(sln, false)) end, oncleanproject = function(prj) premake.clean.file(prj, _MAKE.getmakefilename(prj, true)) end } function premake.make_solution(sln) local cc = premake[_OPTIONS.cc] local platforms = premake.filterplatforms(sln, cc.platforms, "Native") _p('# %s solution makefile autogenerated by Premake', premake.action.current().shortname) _p('# Type "make help" for usage help') _p('') _p('ifndef config') _p(' config=%s', _MAKE.esc(premake.getconfigname(sln.configurations[1], platforms[1], true))) _p('endif') _p('export config') _p('') _p('PROJECTS := %s', table.concat(_MAKE.esc(table.extract(sln.projects, "name")), " ")) _p('') _p('.PHONY: all clean help $(PROJECTS)') _p('') _p('all: $(PROJECTS)') _p('') for _, prj in ipairs(sln.projects) do _p('%s: %s', _MAKE.esc(prj.name), table.concat(_MAKE.esc(table.extract(premake.getdependencies(prj), "name")), " ")) _p('\t@echo "==== Building %s ($(config)) ===="', prj.name) _p('\t@${MAKE} --no-print-directory -C %s -f %s', _MAKE.esc(path.getrelative(sln.location, prj.location)), _MAKE.esc(_MAKE.getmakefilename(prj, true))) _p('') end _p('clean:') for _ ,prj in ipairs(sln.projects) do _p('\t@${MAKE} --no-print-directory -C %s -f %s clean', _MAKE.esc(path.getrelative(sln.location, prj.location)), _MAKE.esc(_MAKE.getmakefilename(prj, true))) end _p('') _p('help:') _p(1,'@echo "Usage: make [config=name] [target]"') _p(1,'@echo ""') _p(1,'@echo "CONFIGURATIONS:"') local cfgpairs = { } for _, platform in ipairs(platforms) do for _, cfgname in ipairs(sln.configurations) do _p(1,'@echo " %s"', premake.getconfigname(cfgname, platform, true)) end end _p(1,'@echo ""') _p(1,'@echo "TARGETS:"') _p(1,'@echo " all (default)"') _p(1,'@echo " clean"') for _, prj in ipairs(sln.projects) do _p(1,'@echo " %s"', prj.name) end _p(1,'@echo ""') _p(1,'@echo "For more information, see http://industriousone.com/premake/quick-start"') end premake.make.cpp = { } local _ = premake.make.cpp function premake.make_cpp(prj) local cc = premake.gettool(prj) local platforms = premake.filterplatforms(prj.solution, cc.platforms, "Native") premake.gmake_cpp_header(prj, cc, platforms) for _, platform in ipairs(platforms) do for cfg in premake.eachconfig(prj, platform) do premake.gmake_cpp_config(cfg, cc) end end _p('OBJECTS := \\') for _, file in ipairs(prj.files) do if path.iscppfile(file) then _p('\t$(OBJDIR)/%s.o \\', _MAKE.esc(path.getbasename(file))) end end _p('') _p('RESOURCES := \\') for _, file in ipairs(prj.files) do if path.isresourcefile(file) then _p('\t$(OBJDIR)/%s.res \\', _MAKE.esc(path.getbasename(file))) end end _p('') _p('SHELLTYPE := msdos') _p('ifeq (,$(ComSpec)$(COMSPEC))') _p(' SHELLTYPE := posix') _p('endif') _p('ifeq (/bin,$(findstring /bin,$(SHELL)))') _p(' SHELLTYPE := posix') _p('endif') _p('') _p('.PHONY: clean prebuild prelink') _p('') if os.is("MacOSX") and prj.kind == "WindowedApp" then _p('all: $(TARGETDIR) $(OBJDIR) prebuild prelink $(TARGET) $(dir $(TARGETDIR))PkgInfo $(dir $(TARGETDIR))Info.plist') else _p('all: $(TARGETDIR) $(OBJDIR) prebuild prelink $(TARGET)') end _p('\t@:') _p('') _p('$(TARGET): $(GCH) $(OBJECTS) $(LDDEPS) $(RESOURCES)') _p('\t@echo Linking %s', prj.name) _p('\t$(SILENT) $(LINKCMD)') _p('\t$(POSTBUILDCMDS)') _p('') _p('$(TARGETDIR):') premake.make_mkdirrule("$(TARGETDIR)") _p('$(OBJDIR):') premake.make_mkdirrule("$(OBJDIR)") if os.is("MacOSX") and prj.kind == "WindowedApp" then _p('$(dir $(TARGETDIR))PkgInfo:') _p('$(dir $(TARGETDIR))Info.plist:') _p('') end _p('clean:') _p('\t@echo Cleaning %s', prj.name) _p('ifeq (posix,$(SHELLTYPE))') _p('\t$(SILENT) rm -f $(TARGET)') _p('\t$(SILENT) rm -rf $(OBJDIR)') _p('else') _p('\t$(SILENT) if exist $(subst /,\\\\,$(TARGET)) del $(subst /,\\\\,$(TARGET))') _p('\t$(SILENT) if exist $(subst /,\\\\,$(OBJDIR)) rmdir /s /q $(subst /,\\\\,$(OBJDIR))') _p('endif') _p('') _p('prebuild:') _p('\t$(PREBUILDCMDS)') _p('') _p('prelink:') _p('\t$(PRELINKCMDS)') _p('') _.pchrules(prj) for _, file in ipairs(prj.files) do if path.iscppfile(file) then _p('$(OBJDIR)/%s.o: %s', _MAKE.esc(path.getbasename(file)), _MAKE.esc(file)) _p('\t@echo $(notdir $<)') if (path.iscfile(file)) then _p('\t$(SILENT) $(CC) $(CFLAGS) -o "$@" -c "$<"') else _p('\t$(SILENT) $(CXX) $(CXXFLAGS) -o "$@" -c "$<"') end elseif (path.getextension(file) == ".rc") then _p('$(OBJDIR)/%s.res: %s', _MAKE.esc(path.getbasename(file)), _MAKE.esc(file)) _p('\t@echo $(notdir $<)') _p('\t$(SILENT) windres $< -O coff -o "$@" $(RESFLAGS)') end end _p('') _p('-include $(OBJECTS:%%.o=%%.d)') end function premake.gmake_cpp_header(prj, cc, platforms) _p('# %s project makefile autogenerated by Premake', premake.action.current().shortname) _p('ifndef config') _p(' config=%s', _MAKE.esc(premake.getconfigname(prj.solution.configurations[1], platforms[1], true))) _p('endif') _p('') _p('ifndef verbose') _p(' SILENT = @') _p('endif') _p('') _p('ifndef CC') _p(' CC = %s', cc.cc) _p('endif') _p('') _p('ifndef CXX') _p(' CXX = %s', cc.cxx) _p('endif') _p('') _p('ifndef AR') _p(' AR = %s', cc.ar) _p('endif') _p('') end function premake.gmake_cpp_config(cfg, cc) _p('ifeq ($(config),%s)', _MAKE.esc(cfg.shortname)) local platform = cc.platforms[cfg.platform] if platform.cc then _p(' CC = %s', platform.cc) end if platform.cxx then _p(' CXX = %s', platform.cxx) end if platform.ar then _p(' AR = %s', platform.ar) end _p(' OBJDIR = %s', _MAKE.esc(cfg.objectsdir)) _p(' TARGETDIR = %s', _MAKE.esc(cfg.buildtarget.directory)) _p(' TARGET = $(TARGETDIR)/%s', _MAKE.esc(cfg.buildtarget.name)) _p(' DEFINES += %s', table.concat(cc.getdefines(cfg.defines), " ")) _p(' INCLUDES += %s', table.concat(cc.getincludedirs(cfg.includedirs), " ")) _p(' CPPFLAGS += %s $(DEFINES) $(INCLUDES)', table.concat(cc.getcppflags(cfg), " ")) _.pchconfig(cfg) _p(' CFLAGS += $(CPPFLAGS) $(ARCH) %s', table.concat(table.join(cc.getcflags(cfg), cfg.buildoptions), " ")) _p(' CXXFLAGS += $(CFLAGS) %s', table.concat(cc.getcxxflags(cfg), " ")) _p(' LDFLAGS += %s', table.concat(table.join(cc.getldflags(cfg), cfg.linkoptions, cc.getlibdirflags(cfg)), " ")) _p(' LIBS += %s', table.concat(cc.getlinkflags(cfg), " ")) _p(' RESFLAGS += $(DEFINES) $(INCLUDES) %s', table.concat(table.join(cc.getdefines(cfg.resdefines), cc.getincludedirs(cfg.resincludedirs), cfg.resoptions), " ")) _p(' LDDEPS += %s', table.concat(_MAKE.esc(premake.getlinks(cfg, "siblings", "fullpath")), " ")) if cfg.kind == "StaticLib" then if cfg.platform:startswith("Universal") then _p(' LINKCMD = libtool -o $(TARGET) $(OBJECTS)') else _p(' LINKCMD = $(AR) -rcs $(TARGET) $(OBJECTS)') end else _p(' LINKCMD = $(%s) -o $(TARGET) $(OBJECTS) $(LDFLAGS) $(RESOURCES) $(ARCH) $(LIBS)', iif(cfg.language == "C", "CC", "CXX")) end _p(' define PREBUILDCMDS') if #cfg.prebuildcommands > 0 then _p('\t@echo Running pre-build commands') _p('\t%s', table.implode(cfg.prebuildcommands, "", "", "\n\t")) end _p(' endef') _p(' define PRELINKCMDS') if #cfg.prelinkcommands > 0 then _p('\t@echo Running pre-link commands') _p('\t%s', table.implode(cfg.prelinkcommands, "", "", "\n\t")) end _p(' endef') _p(' define POSTBUILDCMDS') if #cfg.postbuildcommands > 0 then _p('\t@echo Running post-build commands') _p('\t%s', table.implode(cfg.postbuildcommands, "", "", "\n\t")) end _p(' endef') _p('endif') _p('') end function _.pchconfig(cfg) if not cfg.flags.NoPCH and cfg.pchheader then _p(' PCH = %s', _MAKE.esc(path.getrelative(cfg.location, cfg.pchheader))) _p(' GCH = $(OBJDIR)/%s.gch', _MAKE.esc(path.getname(cfg.pchheader))) _p(' CPPFLAGS += -I$(OBJDIR) -include $(OBJDIR)/%s', _MAKE.esc(path.getname(cfg.pchheader))) end end function _.pchrules(prj) _p('ifneq (,$(PCH))') _p('$(GCH): $(PCH)') _p('\t@echo $(notdir $<)') _p('\t-$(SILENT) cp $< $(OBJDIR)') if prj.language == "C" then _p('\t$(SILENT) $(CC) $(CFLAGS) -o "$@" -c "$<"') else _p('\t$(SILENT) $(CXX) $(CXXFLAGS) -o "$@" -c "$<"') end _p('endif') _p('') end local function getresourcefilename(cfg, fname) if path.getextension(fname) == ".resx" then local name = cfg.buildtarget.basename .. "." local dir = path.getdirectory(fname) if dir ~= "." then name = name .. path.translate(dir, ".") .. "." end return "$(OBJDIR)/" .. _MAKE.esc(name .. path.getbasename(fname)) .. ".resources" else return fname end end function premake.make_csharp(prj) local csc = premake.dotnet local cfglibs = { } local cfgpairs = { } local anycfg for cfg in premake.eachconfig(prj) do anycfg = cfg cfglibs[cfg] = premake.getlinks(cfg, "siblings", "fullpath") cfgpairs[cfg] = { } for _, fname in ipairs(cfglibs[cfg]) do if path.getdirectory(fname) ~= cfg.buildtarget.directory then cfgpairs[cfg]["$(TARGETDIR)/" .. _MAKE.esc(path.getname(fname))] = _MAKE.esc(fname) end end end local sources = {} local embedded = { } local copypairs = { } for fcfg in premake.project.eachfile(prj) do local action = csc.getbuildaction(fcfg) if action == "Compile" then table.insert(sources, fcfg.name) elseif action == "EmbeddedResource" then table.insert(embedded, fcfg.name) elseif action == "Content" then copypairs["$(TARGETDIR)/" .. _MAKE.esc(path.getname(fcfg.name))] = _MAKE.esc(fcfg.name) elseif path.getname(fcfg.name):lower() == "app.config" then copypairs["$(TARGET).config"] = _MAKE.esc(fcfg.name) end end local paths = table.translate(prj.libdirs, function(v) return path.join(prj.basedir, v) end) paths = table.join({prj.basedir}, paths) for _, libname in ipairs(premake.getlinks(prj, "system", "fullpath")) do local libdir = os.pathsearch(libname..".dll", unpack(paths)) if (libdir) then local target = "$(TARGETDIR)/" .. _MAKE.esc(path.getname(libname)) local source = path.getrelative(prj.basedir, path.join(libdir, libname))..".dll" copypairs[target] = _MAKE.esc(source) end end _p('# %s project makefile autogenerated by Premake', premake.action.current().shortname) _p('') _p('ifndef config') _p(' config=%s', _MAKE.esc(prj.configurations[1]:lower())) _p('endif') _p('') _p('ifndef verbose') _p(' SILENT = @') _p('endif') _p('') _p('ifndef CSC') _p(' CSC=%s', csc.getcompilervar(prj)) _p('endif') _p('') _p('ifndef RESGEN') _p(' RESGEN=resgen') _p('endif') _p('') local platforms = premake.filterplatforms(prj.solution, premake[_OPTIONS.cc].platforms) table.insert(platforms, 1, "") for cfg in premake.eachconfig(prj) do premake.gmake_cs_config(cfg, csc, cfglibs) end _p('# To maintain compatibility with VS.NET, these values must be set at the project level') _p('TARGET := $(TARGETDIR)/%s', _MAKE.esc(prj.buildtarget.name)) _p('FLAGS += /t:%s %s', csc.getkind(prj):lower(), table.implode(_MAKE.esc(prj.libdirs), "/lib:", "", " ")) _p('REFERENCES += %s', table.implode(_MAKE.esc(premake.getlinks(prj, "system", "basename")), "/r:", ".dll", " ")) _p('') _p('SOURCES := \\') for _, fname in ipairs(sources) do _p('\t%s \\', _MAKE.esc(path.translate(fname))) end _p('') _p('EMBEDFILES := \\') for _, fname in ipairs(embedded) do _p('\t%s \\', getresourcefilename(prj, fname)) end _p('') _p('COPYFILES += \\') for target, source in pairs(cfgpairs[anycfg]) do _p('\t%s \\', target) end for target, source in pairs(copypairs) do _p('\t%s \\', target) end _p('') _p('SHELLTYPE := msdos') _p('ifeq (,$(ComSpec)$(COMSPEC))') _p(' SHELLTYPE := posix') _p('endif') _p('ifeq (/bin,$(findstring /bin,$(SHELL)))') _p(' SHELLTYPE := posix') _p('endif') _p('') _p('.PHONY: clean prebuild prelink') _p('') _p('all: $(TARGETDIR) $(OBJDIR) prebuild $(EMBEDFILES) $(COPYFILES) prelink $(TARGET)') _p('') _p('$(TARGET): $(SOURCES) $(EMBEDFILES) $(DEPENDS)') _p('\t$(SILENT) $(CSC) /nologo /out:$@ $(FLAGS) $(REFERENCES) $(SOURCES) $(patsubst %%,/resource:%%,$(EMBEDFILES))') _p('\t$(POSTBUILDCMDS)') _p('') _p('$(TARGETDIR):') premake.make_mkdirrule("$(TARGETDIR)") _p('$(OBJDIR):') premake.make_mkdirrule("$(OBJDIR)") _p('clean:') _p('\t@echo Cleaning %s', prj.name) _p('ifeq (posix,$(SHELLTYPE))') _p('\t$(SILENT) rm -f $(TARGETDIR)/%s.* $(COPYFILES)', prj.buildtarget.basename) _p('\t$(SILENT) rm -rf $(OBJDIR)') _p('else') _p('\t$(SILENT) if exist $(subst /,\\\\,$(TARGETDIR)/%s.*) del $(subst /,\\\\,$(TARGETDIR)/%s.*)', prj.buildtarget.basename, prj.buildtarget.basename) for target, source in pairs(cfgpairs[anycfg]) do _p('\t$(SILENT) if exist $(subst /,\\\\,%s) del $(subst /,\\\\,%s)', target, target) end for target, source in pairs(copypairs) do _p('\t$(SILENT) if exist $(subst /,\\\\,%s) del $(subst /,\\\\,%s)', target, target) end _p('\t$(SILENT) if exist $(subst /,\\\\,$(OBJDIR)) rmdir /s /q $(subst /,\\\\,$(OBJDIR))') _p('endif') _p('') _p('prebuild:') _p('\t$(PREBUILDCMDS)') _p('') _p('prelink:') _p('\t$(PRELINKCMDS)') _p('') _p('# Per-configuration copied file rules') for cfg in premake.eachconfig(prj) do _p('ifneq (,$(findstring %s,$(config)))', _MAKE.esc(cfg.name:lower())) for target, source in pairs(cfgpairs[cfg]) do premake.make_copyrule(source, target) end _p('endif') _p('') end _p('# Copied file rules') for target, source in pairs(copypairs) do premake.make_copyrule(source, target) end _p('# Embedded file rules') for _, fname in ipairs(embedded) do if path.getextension(fname) == ".resx" then _p('%s: %s', getresourcefilename(prj, fname), _MAKE.esc(fname)) _p('\t$(SILENT) $(RESGEN) $^ $@') end _p('') end end function premake.gmake_cs_config(cfg, csc, cfglibs) _p('ifneq (,$(findstring %s,$(config)))', _MAKE.esc(cfg.name:lower())) _p(' TARGETDIR := %s', _MAKE.esc(cfg.buildtarget.directory)) _p(' OBJDIR := %s', _MAKE.esc(cfg.objectsdir)) _p(' DEPENDS := %s', table.concat(_MAKE.esc(premake.getlinks(cfg, "dependencies", "fullpath")), " ")) _p(' REFERENCES := %s', table.implode(_MAKE.esc(cfglibs[cfg]), "/r:", "", " ")) _p(' FLAGS += %s %s', table.implode(cfg.defines, "/d:", "", " "), table.concat(table.join(csc.getflags(cfg), cfg.buildoptions), " ")) _p(' define PREBUILDCMDS') if #cfg.prebuildcommands > 0 then _p('\t@echo Running pre-build commands') _p('\t%s', table.implode(cfg.prebuildcommands, "", "", "\n\t")) end _p(' endef') _p(' define PRELINKCMDS') if #cfg.prelinkcommands > 0 then _p('\t@echo Running pre-link commands') _p('\t%s', table.implode(cfg.prelinkcommands, "", "", "\n\t")) end _p(' endef') _p(' define POSTBUILDCMDS') if #cfg.postbuildcommands > 0 then _p('\t@echo Running post-build commands') _p('\t%s', table.implode(cfg.postbuildcommands, "", "", "\n\t")) end _p(' endef') _p('endif') _p('') end premake.vstudio = { } local vstudio = premake.vstudio vstudio.platforms = { any = "Any CPU", mixed = "Mixed Platforms", Native = "Win32", x86 = "x86", x32 = "Win32", x64 = "x64", PS3 = "PS3", Xbox360 = "Xbox 360", } function vstudio.arch(prj) if (prj.language == "C#") then if (_ACTION < "vs2005") then return ".NET" else return "Any CPU" end else return "Win32" end end function vstudio.buildconfigs(sln) local cfgs = { } local platforms = premake.filterplatforms(sln, vstudio.platforms, "Native") local hascpp = premake.hascppproject(sln) local hasdotnet = premake.hasdotnetproject(sln) if hasdotnet and (_ACTION > "vs2008" or hascpp) then table.insert(platforms, 1, "mixed") end if hasdotnet and (_ACTION < "vs2010" or not hascpp) then table.insert(platforms, 1, "any") end if _ACTION > "vs2008" then local platforms2010 = { } for _, platform in ipairs(platforms) do if vstudio.platforms[platform] == "Win32" then if hascpp then table.insert(platforms2010, platform) end if hasdotnet then table.insert(platforms2010, "x86") end else table.insert(platforms2010, platform) end end platforms = platforms2010 end for _, buildcfg in ipairs(sln.configurations) do for _, platform in ipairs(platforms) do local entry = { } entry.src_buildcfg = buildcfg entry.src_platform = platform if platform ~= "PS3" then entry.buildcfg = buildcfg entry.platform = vstudio.platforms[platform] else entry.buildcfg = platform .. " " .. buildcfg entry.platform = "Win32" end entry.name = entry.buildcfg .. "|" .. entry.platform entry.isreal = (platform ~= "any" and platform ~= "mixed") table.insert(cfgs, entry) end end return cfgs end function vstudio.cleansolution(sln) premake.clean.file(sln, "%%.sln") premake.clean.file(sln, "%%.suo") premake.clean.file(sln, "%%.ncb") premake.clean.file(sln, "%%.userprefs") premake.clean.file(sln, "%%.usertasks") end function vstudio.cleanproject(prj) local fname = premake.project.getfilename(prj, "%%") os.remove(fname .. ".vcproj") os.remove(fname .. ".vcproj.user") os.remove(fname .. ".vcxproj") os.remove(fname .. ".vcxproj.user") os.remove(fname .. ".vcxproj.filters") os.remove(fname .. ".csproj") os.remove(fname .. ".csproj.user") os.remove(fname .. ".pidb") os.remove(fname .. ".sdf") end function vstudio.cleantarget(name) os.remove(name .. ".pdb") os.remove(name .. ".idb") os.remove(name .. ".ilk") os.remove(name .. ".vshost.exe") os.remove(name .. ".exe.manifest") end function vstudio.projectfile(prj) local extension if prj.language == "C#" then extension = ".csproj" else extension = iif(_ACTION > "vs2008", ".vcxproj", ".vcproj") end local fname = path.join(prj.location, prj.name) return fname..extension end function vstudio.tool(prj) if (prj.language == "C#") then return "FAE04EC0-301F-11D3-BF4B-00C04F79EFBC" else return "8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942" end end newaction { trigger = "vs2002", shortname = "Visual Studio 2002", description = "Generate Microsoft Visual Studio 2002 project files", os = "windows", valid_kinds = { "ConsoleApp", "WindowedApp", "StaticLib", "SharedLib" }, valid_languages = { "C", "C++", "C#" }, valid_tools = { cc = { "msc" }, dotnet = { "msnet" }, }, onsolution = function(sln) premake.generate(sln, "%%.sln", vstudio.sln2002.generate) end, onproject = function(prj) if premake.isdotnetproject(prj) then premake.generate(prj, "%%.csproj", vstudio.cs2002.generate) premake.generate(prj, "%%.csproj.user", vstudio.cs2002.generate_user) else premake.generate(prj, "%%.vcproj", vstudio.vc200x.generate) premake.generate(prj, "%%.vcproj.user", vstudio.vc200x.generate_user) end end, oncleansolution = premake.vstudio.cleansolution, oncleanproject = premake.vstudio.cleanproject, oncleantarget = premake.vstudio.cleantarget } newaction { trigger = "vs2003", shortname = "Visual Studio 2003", description = "Generate Microsoft Visual Studio 2003 project files", os = "windows", valid_kinds = { "ConsoleApp", "WindowedApp", "StaticLib", "SharedLib" }, valid_languages = { "C", "C++", "C#" }, valid_tools = { cc = { "msc" }, dotnet = { "msnet" }, }, onsolution = function(sln) premake.generate(sln, "%%.sln", vstudio.sln2003.generate) end, onproject = function(prj) if premake.isdotnetproject(prj) then premake.generate(prj, "%%.csproj", vstudio.cs2002.generate) premake.generate(prj, "%%.csproj.user", vstudio.cs2002.generate_user) else premake.generate(prj, "%%.vcproj", vstudio.vc200x.generate) premake.generate(prj, "%%.vcproj.user", vstudio.vc200x.generate_user) end end, oncleansolution = premake.vstudio.cleansolution, oncleanproject = premake.vstudio.cleanproject, oncleantarget = premake.vstudio.cleantarget } newaction { trigger = "vs2005", shortname = "Visual Studio 2005", description = "Generate Microsoft Visual Studio 2005 project files", os = "windows", valid_kinds = { "ConsoleApp", "WindowedApp", "StaticLib", "SharedLib" }, valid_languages = { "C", "C++", "C#" }, valid_tools = { cc = { "msc" }, dotnet = { "msnet" }, }, onsolution = function(sln) premake.generate(sln, "%%.sln", vstudio.sln2005.generate) end, onproject = function(prj) if premake.isdotnetproject(prj) then premake.generate(prj, "%%.csproj", vstudio.cs2005.generate) premake.generate(prj, "%%.csproj.user", vstudio.cs2005.generate_user) else premake.generate(prj, "%%.vcproj", vstudio.vc200x.generate) premake.generate(prj, "%%.vcproj.user", vstudio.vc200x.generate_user) end end, oncleansolution = vstudio.cleansolution, oncleanproject = vstudio.cleanproject, oncleantarget = vstudio.cleantarget } newaction { trigger = "vs2008", shortname = "Visual Studio 2008", description = "Generate Microsoft Visual Studio 2008 project files", os = "windows", valid_kinds = { "ConsoleApp", "WindowedApp", "StaticLib", "SharedLib" }, valid_languages = { "C", "C++", "C#" }, valid_tools = { cc = { "msc" }, dotnet = { "msnet" }, }, onsolution = function(sln) premake.generate(sln, "%%.sln", vstudio.sln2005.generate) end, onproject = function(prj) if premake.isdotnetproject(prj) then premake.generate(prj, "%%.csproj", vstudio.cs2005.generate) premake.generate(prj, "%%.csproj.user", vstudio.cs2005.generate_user) else premake.generate(prj, "%%.vcproj", vstudio.vc200x.generate) premake.generate(prj, "%%.vcproj.user", vstudio.vc200x.generate_user) end end, oncleansolution = vstudio.cleansolution, oncleanproject = vstudio.cleanproject, oncleantarget = vstudio.cleantarget } newaction { trigger = "vs2010", shortname = "Visual Studio 2010", description = "Generate Visual Studio 2010 project files", os = "windows", valid_kinds = { "ConsoleApp", "WindowedApp", "StaticLib", "SharedLib" }, valid_languages = { "C", "C++", "C#"}, valid_tools = { cc = { "msc" }, dotnet = { "msnet" }, }, onsolution = function(sln) premake.generate(sln, "%%.sln", vstudio.sln2005.generate) end, onproject = function(prj) if premake.isdotnetproject(prj) then premake.generate(prj, "%%.csproj", vstudio.cs2005.generate) premake.generate(prj, "%%.csproj.user", vstudio.cs2005.generate_user) else premake.generate(prj, "%%.vcxproj", premake.vs2010_vcxproj) premake.generate(prj, "%%.vcxproj.user", premake.vs2010_vcxproj_user) premake.generate(prj, "%%.vcxproj.filters", vstudio.vc2010.generate_filters) end end, oncleansolution = premake.vstudio.cleansolution, oncleanproject = premake.vstudio.cleanproject, oncleantarget = premake.vstudio.cleantarget }premake.vstudio.sln2002 = { } local vstudio = premake.vstudio local sln2002 = premake.vstudio.sln2002 function sln2002.generate(sln) io.eol = '\r\n' sln.vstudio_configs = premake.vstudio.buildconfigs(sln) _p('Microsoft Visual Studio Solution File, Format Version 7.00') for prj in premake.solution.eachproject(sln) do local projpath = path.translate(path.getrelative(sln.location, vstudio.projectfile(prj))) _p('Project("{%s}") = "%s", "%s", "{%s}"', vstudio.tool(prj), prj.name, projpath, prj.uuid) _p('EndProject') end _p('Global') _p(1,'GlobalSection(SolutionConfiguration) = preSolution') for i, cfgname in ipairs(sln.configurations) do _p(2,'ConfigName.%d = %s', i - 1, cfgname) end _p(1,'EndGlobalSection') _p(1,'GlobalSection(ProjectDependencies) = postSolution') _p(1,'EndGlobalSection') _p(1,'GlobalSection(ProjectConfiguration) = postSolution') for prj in premake.solution.eachproject(sln) do for _, cfgname in ipairs(sln.configurations) do _p(2,'{%s}.%s.ActiveCfg = %s|%s', prj.uuid, cfgname, cfgname, vstudio.arch(prj)) _p(2,'{%s}.%s.Build.0 = %s|%s', prj.uuid, cfgname, cfgname, vstudio.arch(prj)) end end _p(1,'EndGlobalSection') _p(1,'GlobalSection(ExtensibilityGlobals) = postSolution') _p(1,'EndGlobalSection') _p(1,'GlobalSection(ExtensibilityAddIns) = postSolution') _p(1,'EndGlobalSection') _p('EndGlobal') end premake.vstudio.cs2002 = { } local vstudio = premake.vstudio local cs2002 = premake.vstudio.cs2002 local function getelements(prj, action, fname) if action == "Compile" and fname:endswith(".cs") then return "SubTypeCode" end if action == "EmbeddedResource" and fname:endswith(".resx") then local basename = fname:sub(1, -6) local testname = path.getname(basename .. ".cs") if premake.findfile(prj, testname) then return "Dependency", testname end end return "None" end function cs2002.Files(prj) local tr = premake.project.buildsourcetree(prj) premake.tree.traverse(tr, { onleaf = function(node) local action = premake.dotnet.getbuildaction(node.cfg) local fname = path.translate(premake.esc(node.path), "\\") local elements, dependency = getelements(prj, action, node.path) _p(4,'') end }, false) end function cs2002.generate(prj) io.eol = "\r\n" _p('') _p(1,'') _p(2,'') _p(3,'') for cfg in premake.eachconfig(prj) do _p(4,'') end _p(3,'') _p(3,'') for _, ref in ipairs(premake.getlinks(prj, "siblings", "object")) do _p(4,'') end for _, linkname in ipairs(premake.getlinks(prj, "system", "fullpath")) do _p(4,'') end _p(3,'') _p(2,'') _p(2,'') _p(3,'') cs2002.Files(prj) _p(3,'') _p(2,'') _p(1,'') _p('') end local cs2002 = premake.vstudio.cs2002 function cs2002.generate_user(prj) io.eol = "\r\n" _p('') _p(1,'') _p(2,'') local refpaths = table.translate(prj.libdirs, function(v) return path.getabsolute(prj.location .. "/" .. v) end) _p(3,'', path.translate(table.concat(refpaths, ";"), "\\")) for cfg in premake.eachconfig(prj) do _p(4,'') end _p(3,'') _p(2,'') _p(2,'') _p(1,'') _p('') end premake.vstudio.vc200x = { } local vc200x = premake.vstudio.vc200x local tree = premake.tree local function bool(value) if (_ACTION < "vs2005") then return iif(value, "TRUE", "FALSE") else return iif(value, "true", "false") end end function vc200x.optimization(cfg) local result = 0 for _, value in ipairs(cfg.flags) do if (value == "Optimize") then result = 3 elseif (value == "OptimizeSize") then result = 1 elseif (value == "OptimizeSpeed") then result = 2 end end return result end function vc200x.header(element) io.eol = "\r\n" _p('') _p('<%s', element) _p(1,'ProjectType="Visual C++"') if _ACTION == "vs2002" then _p(1,'Version="7.00"') elseif _ACTION == "vs2003" then _p(1,'Version="7.10"') elseif _ACTION == "vs2005" then _p(1,'Version="8.00"') elseif _ACTION == "vs2008" then _p(1,'Version="9.00"') end end function vc200x.Configuration(name, cfg) _p(2,'') end function vc200x.Files(prj) local tr = premake.project.buildsourcetree(prj) tree.traverse(tr, { onbranchenter = function(node, depth) _p(depth, '') end, onbranchexit = function(node, depth) _p(depth, '') end, onleaf = function(node, depth) _p(depth, '') depth = depth + 1 for _, cfginfo in ipairs(prj.solution.vstudio_configs) do if cfginfo.isreal then local cfg = premake.getconfig(prj, cfginfo.src_buildcfg, cfginfo.src_platform) local usePCH = (not prj.flags.NoPCH and prj.pchsource == node.cfg.name) if (usePCH) then _p(depth, '') _p(depth, '\t') _p(depth, '') end end end depth = depth - 1 _p(depth, '') end, }, false, 2) end function vc200x.Platforms(prj) local used = { } _p(1,'') for _, cfg in ipairs(prj.solution.vstudio_configs) do if cfg.isreal and not table.contains(used, cfg.platform) then table.insert(used, cfg.platform) _p(2,'') end end _p(1,'') end function vc200x.Symbols(cfg) if (not cfg.flags.Symbols) then return 0 else if cfg.flags.NoEditAndContinue or vc200x.optimization(cfg) ~= 0 or cfg.flags.Managed or cfg.platform == "x64" then return 3 else return 4 end end end function vc200x.VCCLCompilerTool(cfg) _p(3,' 0 then _p(4,'AdditionalOptions="%s"', table.concat(premake.esc(cfg.buildoptions), " ")) end _p(4,'Optimization="%s"', vc200x.optimization(cfg)) if cfg.flags.NoFramePointer then _p(4,'OmitFramePointers="%s"', bool(true)) end if #cfg.includedirs > 0 then _p(4,'AdditionalIncludeDirectories="%s"', premake.esc(path.translate(table.concat(cfg.includedirs, ";"), '\\'))) end if #cfg.defines > 0 then _p(4,'PreprocessorDefinitions="%s"', premake.esc(table.concat(cfg.defines, ";"))) end if premake.config.isdebugbuild(cfg) and not cfg.flags.NoMinimalRebuild and not cfg.flags.Managed then _p(4,'MinimalRebuild="%s"', bool(true)) end if cfg.flags.NoExceptions then _p(4,'ExceptionHandling="%s"', iif(_ACTION < "vs2005", "FALSE", 0)) elseif cfg.flags.SEH and _ACTION > "vs2003" then _p(4,'ExceptionHandling="2"') end if vc200x.optimization(cfg) == 0 and not cfg.flags.Managed then _p(4,'BasicRuntimeChecks="3"') end if vc200x.optimization(cfg) ~= 0 then _p(4,'StringPooling="%s"', bool(true)) end local runtime if premake.config.isdebugbuild(cfg) then runtime = iif(cfg.flags.StaticRuntime, 1, 3) else runtime = iif(cfg.flags.StaticRuntime, 0, 2) end _p(4,'RuntimeLibrary="%s"', runtime) _p(4,'EnableFunctionLevelLinking="%s"', bool(true)) if _ACTION > "vs2003" and cfg.platform ~= "Xbox360" and cfg.platform ~= "x64" then if cfg.flags.EnableSSE then _p(4,'EnableEnhancedInstructionSet="1"') elseif cfg.flags.EnableSSE2 then _p(4,'EnableEnhancedInstructionSet="2"') end end if _ACTION < "vs2005" then if cfg.flags.FloatFast then _p(4,'ImproveFloatingPointConsistency="%s"', bool(false)) elseif cfg.flags.FloatStrict then _p(4,'ImproveFloatingPointConsistency="%s"', bool(true)) end else if cfg.flags.FloatFast then _p(4,'FloatingPointModel="2"') elseif cfg.flags.FloatStrict then _p(4,'FloatingPointModel="1"') end end if _ACTION < "vs2005" and not cfg.flags.NoRTTI then _p(4,'RuntimeTypeInfo="%s"', bool(true)) elseif _ACTION > "vs2003" and cfg.flags.NoRTTI and not cfg.flags.Managed then _p(4,'RuntimeTypeInfo="%s"', bool(false)) end if cfg.flags.NativeWChar then _p(4,'TreatWChar_tAsBuiltInType="%s"', bool(true)) elseif cfg.flags.NoNativeWChar then _p(4,'TreatWChar_tAsBuiltInType="%s"', bool(false)) end if not cfg.flags.NoPCH and cfg.pchheader then _p(4,'UsePrecompiledHeader="%s"', iif(_ACTION < "vs2005", 3, 2)) _p(4,'PrecompiledHeaderThrough="%s"', path.getname(cfg.pchheader)) else _p(4,'UsePrecompiledHeader="%s"', iif(_ACTION > "vs2003" or cfg.flags.NoPCH, 0, 2)) end _p(4,'WarningLevel="%s"', iif(cfg.flags.ExtraWarnings, 4, 3)) if cfg.flags.FatalWarnings then _p(4,'WarnAsError="%s"', bool(true)) end if _ACTION < "vs2008" and not cfg.flags.Managed then _p(4,'Detect64BitPortabilityProblems="%s"', bool(not cfg.flags.No64BitChecks)) end _p(4,'ProgramDataBaseFileName="$(OutDir)\\%s.pdb"', path.getbasename(cfg.buildtarget.name)) _p(4,'DebugInformationFormat="%s"', vc200x.Symbols(cfg)) if cfg.language == "C" then _p(4, 'CompileAs="1"') end _p(3,'/>') end function vc200x.VCLinkerTool(cfg) _p(3,' 0 then _p(4,'AdditionalOptions="%s"', table.concat(premake.esc(cfg.linkoptions), " ")) end if #cfg.links > 0 then _p(4,'AdditionalDependencies="%s"', table.concat(premake.getlinks(cfg, "all", "fullpath"), " ")) end _p(4,'OutputFile="$(OutDir)\\%s"', cfg.buildtarget.name) _p(4,'LinkIncremental="%s"', iif(premake.config.isincrementallink(cfg) , 2, 1)) _p(4,'AdditionalLibraryDirectories="%s"', table.concat(premake.esc(path.translate(cfg.libdirs, '\\')) , ";")) local deffile = premake.findfile(cfg, ".def") if deffile then _p(4,'ModuleDefinitionFile="%s"', deffile) end if cfg.flags.NoManifest then _p(4,'GenerateManifest="%s"', bool(false)) end _p(4,'GenerateDebugInformation="%s"', bool(vc200x.Symbols(cfg) ~= 0)) if vc200x.Symbols(cfg) ~= 0 then _p(4,'ProgramDataBaseFileName="$(OutDir)\\%s.pdb"', path.getbasename(cfg.buildtarget.name)) end _p(4,'SubSystem="%s"', iif(cfg.kind == "ConsoleApp", 1, 2)) if vc200x.optimization(cfg) ~= 0 then _p(4,'OptimizeReferences="2"') _p(4,'EnableCOMDATFolding="2"') end if (cfg.kind == "ConsoleApp" or cfg.kind == "WindowedApp") and not cfg.flags.WinMain then _p(4,'EntryPointSymbol="mainCRTStartup"') end if cfg.kind == "SharedLib" then local implibname = cfg.linktarget.fullpath _p(4,'ImportLibrary="%s"', iif(cfg.flags.NoImportLib, cfg.objectsdir .. "\\" .. path.getname(implibname), implibname)) end _p(4,'TargetMachine="%d"', iif(cfg.platform == "x64", 17, 1)) else _p(4,'Name="VCLibrarianTool"') if #cfg.links > 0 then _p(4,'AdditionalDependencies="%s"', table.concat(premake.getlinks(cfg, "all", "fullpath"), " ")) end _p(4,'OutputFile="$(OutDir)\\%s"', cfg.buildtarget.name) if #cfg.libdirs > 0 then _p(4,'AdditionalLibraryDirectories="%s"', premake.esc(path.translate(table.concat(cfg.libdirs , ";")))) end local addlOptions = {} if cfg.platform == "x32" then table.insert(addlOptions, "/MACHINE:X86") elseif cfg.platform == "x64" then table.insert(addlOptions, "/MACHINE:X64") end addlOptions = table.join(addlOptions, cfg.linkoptions) if #addlOptions > 0 then _p(4,'AdditionalOptions="%s"', table.concat(premake.esc(addlOptions), " ")) end end _p(3,'/>') end function vc200x.VCCLCompilerTool_PS3(cfg) _p(3,' "vs2003" or cfg.flags.NoPCH, 0, 2)) end _p(4,'AdditionalOptions="%s"', premake.esc(table.concat(buildoptions, " "))) if #cfg.includedirs > 0 then _p(4,'AdditionalIncludeDirectories="%s"', premake.esc(path.translate(table.concat(cfg.includedirs, ";"), '\\'))) end if #cfg.defines > 0 then _p(4,'PreprocessorDefinitions="%s"', table.concat(premake.esc(cfg.defines), ";")) end _p(4,'ProgramDataBaseFileName="$(OutDir)\\%s.pdb"', path.getbasename(cfg.buildtarget.name)) _p(4,'DebugInformationFormat="0"') _p(4,'CompileAs="0"') _p(3,'/>') end function vc200x.VCLinkerTool_PS3(cfg) _p(3,' 0 then _p(4,'AdditionalOptions="%s"', premake.esc(table.concat(buildoptions, " "))) end if #cfg.links > 0 then _p(4,'AdditionalDependencies="%s"', table.concat(premake.getlinks(cfg, "all", "fullpath"), " ")) end _p(4,'OutputFile="$(OutDir)\\%s"', cfg.buildtarget.name) _p(4,'LinkIncremental="0"') _p(4,'AdditionalLibraryDirectories="%s"', table.concat(premake.esc(path.translate(cfg.libdirs, '\\')) , ";")) _p(4,'GenerateManifest="%s"', bool(false)) _p(4,'ProgramDatabaseFile=""') _p(4,'RandomizedBaseAddress="1"') _p(4,'DataExecutionPrevention="0"') else _p(4,'Name="VCLibrarianTool"') local buildoptions = table.join(premake.snc.getldflags(cfg), cfg.linkoptions) if #buildoptions > 0 then _p(4,'AdditionalOptions="%s"', premake.esc(table.concat(buildoptions, " "))) end if #cfg.links > 0 then _p(4,'AdditionalDependencies="%s"', table.concat(premake.getlinks(cfg, "all", "fullpath"), " ")) end _p(4,'OutputFile="$(OutDir)\\%s"', cfg.buildtarget.name) if #cfg.libdirs > 0 then _p(4,'AdditionalLibraryDirectories="%s"', premake.esc(path.translate(table.concat(cfg.libdirs , ";")))) end end _p(3,'/>') end function vc200x.VCResourceCompilerTool(cfg) _p(3,' 0 then _p(4,'AdditionalOptions="%s"', table.concat(premake.esc(cfg.resoptions), " ")) end if #cfg.defines > 0 or #cfg.resdefines > 0 then _p(4,'PreprocessorDefinitions="%s"', table.concat(premake.esc(table.join(cfg.defines, cfg.resdefines)), ";")) end if #cfg.includedirs > 0 or #cfg.resincludedirs > 0 then local dirs = table.join(cfg.includedirs, cfg.resincludedirs) _p(4,'AdditionalIncludeDirectories="%s"', premake.esc(path.translate(table.concat(dirs, ";"), '\\'))) end _p(3,'/>') end function vc200x.VCManifestTool(cfg) local manifests = { } for _, fname in ipairs(cfg.files) do if path.getextension(fname) == ".manifest" then table.insert(manifests, fname) end end _p(3,' 0 then _p(4,'AdditionalManifestFiles="%s"', premake.esc(table.concat(manifests, ";"))) end _p(3,'/>') end function vc200x.VCMIDLTool(cfg) _p(3,'') end function vc200x.buildstepsblock(name, steps) _p(3,' 0 then _p(4,'CommandLine="%s"', premake.esc(table.implode(steps, "", "", "\r\n"))) end _p(3,'/>') end local blockmap = { VCCLCompilerTool = vc200x.VCCLCompilerTool, VCCLCompilerTool_PS3 = vc200x.VCCLCompilerTool_PS3, VCLinkerTool = vc200x.VCLinkerTool, VCLinkerTool_PS3 = vc200x.VCLinkerTool_PS3, VCManifestTool = vc200x.VCManifestTool, VCMIDLTool = vc200x.VCMIDLTool, VCResourceCompilerTool = vc200x.VCResourceCompilerTool, } local function getsections(version, platform) if version == "vs2002" then return { "VCCLCompilerTool", "VCCustomBuildTool", "VCLinkerTool", "VCMIDLTool", "VCPostBuildEventTool", "VCPreBuildEventTool", "VCPreLinkEventTool", "VCResourceCompilerTool", "VCWebServiceProxyGeneratorTool", "VCWebDeploymentTool" } end if version == "vs2003" then return { "VCCLCompilerTool", "VCCustomBuildTool", "VCLinkerTool", "VCMIDLTool", "VCPostBuildEventTool", "VCPreBuildEventTool", "VCPreLinkEventTool", "VCResourceCompilerTool", "VCWebServiceProxyGeneratorTool", "VCXMLDataGeneratorTool", "VCWebDeploymentTool", "VCManagedWrapperGeneratorTool", "VCAuxiliaryManagedWrapperGeneratorTool" } end if platform == "Xbox360" then return { "VCPreBuildEventTool", "VCCustomBuildTool", "VCXMLDataGeneratorTool", "VCWebServiceProxyGeneratorTool", "VCMIDLTool", "VCCLCompilerTool", "VCManagedResourceCompilerTool", "VCResourceCompilerTool", "VCPreLinkEventTool", "VCLinkerTool", "VCALinkTool", "VCX360ImageTool", "VCBscMakeTool", "VCX360DeploymentTool", "VCPostBuildEventTool", "DebuggerTool", } end if platform == "PS3" then return { "VCPreBuildEventTool", "VCCustomBuildTool", "VCXMLDataGeneratorTool", "VCWebServiceProxyGeneratorTool", "VCMIDLTool", "VCCLCompilerTool_PS3", "VCManagedResourceCompilerTool", "VCResourceCompilerTool", "VCPreLinkEventTool", "VCLinkerTool_PS3", "VCALinkTool", "VCManifestTool", "VCXDCMakeTool", "VCBscMakeTool", "VCFxCopTool", "VCAppVerifierTool", "VCWebDeploymentTool", "VCPostBuildEventTool" } else return { "VCPreBuildEventTool", "VCCustomBuildTool", "VCXMLDataGeneratorTool", "VCWebServiceProxyGeneratorTool", "VCMIDLTool", "VCCLCompilerTool", "VCManagedResourceCompilerTool", "VCResourceCompilerTool", "VCPreLinkEventTool", "VCLinkerTool", "VCALinkTool", "VCManifestTool", "VCXDCMakeTool", "VCBscMakeTool", "VCFxCopTool", "VCAppVerifierTool", "VCWebDeploymentTool", "VCPostBuildEventTool" } end end function vc200x.generate(prj) vc200x.header('VisualStudioProject') _p(1,'Name="%s"', premake.esc(prj.name)) _p(1,'ProjectGUID="{%s}"', prj.uuid) if _ACTION > "vs2003" then _p(1,'RootNamespace="%s"', prj.name) end _p(1,'Keyword="%s"', iif(prj.flags.Managed, "ManagedCProj", "Win32Proj")) _p(1,'>') vc200x.Platforms(prj) if _ACTION > "vs2003" then _p(1,'') _p(1,'') end _p(1,'') for _, cfginfo in ipairs(prj.solution.vstudio_configs) do if cfginfo.isreal then local cfg = premake.getconfig(prj, cfginfo.src_buildcfg, cfginfo.src_platform) vc200x.Configuration(cfginfo.name, cfg) for _, block in ipairs(getsections(_ACTION, cfginfo.src_platform)) do if blockmap[block] then blockmap[block](cfg) elseif block == "VCPreBuildEventTool" then vc200x.buildstepsblock("VCPreBuildEventTool", cfg.prebuildcommands) elseif block == "VCPreLinkEventTool" then vc200x.buildstepsblock("VCPreLinkEventTool", cfg.prelinkcommands) elseif block == "VCPostBuildEventTool" then vc200x.buildstepsblock("VCPostBuildEventTool", cfg.postbuildcommands) elseif block == "VCX360DeploymentTool" then _p(3,' 0 then _p(4,'AdditionalOptions="%s"', table.concat(premake.esc(cfg.deploymentoptions), " ")) end _p(3,'/>') elseif block == "VCX360ImageTool" then _p(3,' 0 then _p(4,'AdditionalOptions="%s"', table.concat(premake.esc(cfg.imageoptions), " ")) end if cfg.imagepath ~= nil then _p(4,'OutputFileName="%s"', premake.esc(path.translate(cfg.imagepath))) end _p(3,'/>') elseif block == "DebuggerTool" then _p(3,'') else _p(3,'') end end _p(2,'') end end _p(1,'') _p(1,'') _p(1,'') _p(1,'') vc200x.Files(prj) _p(1,'') _p(1,'') _p(1,'') _p('') end local vc200x = premake.vstudio.vc200x function vc200x.generate_user(prj) vc200x.header('VisualStudioUserFile') _p(1,'ShowAllFiles="false"') _p(1,'>') _p(1,'') for _, cfginfo in ipairs(prj.solution.vstudio_configs) do if cfginfo.isreal then local cfg = premake.getconfig(prj, cfginfo.src_buildcfg, cfginfo.src_platform) _p(2,'') vc200x.debugdir(cfg) _p(2,'') end end _p(1,'') _p('') end function vc200x.debugdir(cfg) _p(3,' 0 then _p(4,'CommandArguments="%s"', table.concat(cfg.debugargs, " ")) end _p(3,'/>') end premake.vstudio.sln2003 = { } local vstudio = premake.vstudio local sln2003 = premake.vstudio.sln2003 function sln2003.generate(sln) io.eol = '\r\n' sln.vstudio_configs = premake.vstudio.buildconfigs(sln) _p('Microsoft Visual Studio Solution File, Format Version 8.00') for prj in premake.solution.eachproject(sln) do local projpath = path.translate(path.getrelative(sln.location, vstudio.projectfile(prj))) _p('Project("{%s}") = "%s", "%s", "{%s}"', vstudio.tool(prj), prj.name, projpath, prj.uuid) local deps = premake.getdependencies(prj) if #deps > 0 then _p('\tProjectSection(ProjectDependencies) = postProject') for _, dep in ipairs(deps) do _p('\t\t{%s} = {%s}', dep.uuid, dep.uuid) end _p('\tEndProjectSection') end _p('EndProject') end _p('Global') _p('\tGlobalSection(SolutionConfiguration) = preSolution') for _, cfgname in ipairs(sln.configurations) do _p('\t\t%s = %s', cfgname, cfgname) end _p('\tEndGlobalSection') _p('\tGlobalSection(ProjectDependencies) = postSolution') _p('\tEndGlobalSection') _p('\tGlobalSection(ProjectConfiguration) = postSolution') for prj in premake.solution.eachproject(sln) do for _, cfgname in ipairs(sln.configurations) do _p('\t\t{%s}.%s.ActiveCfg = %s|%s', prj.uuid, cfgname, cfgname, vstudio.arch(prj)) _p('\t\t{%s}.%s.Build.0 = %s|%s', prj.uuid, cfgname, cfgname, vstudio.arch(prj)) end end _p('\tEndGlobalSection') _p('\tGlobalSection(ExtensibilityGlobals) = postSolution') _p('\tEndGlobalSection') _p('\tGlobalSection(ExtensibilityAddIns) = postSolution') _p('\tEndGlobalSection') _p('EndGlobal') end premake.vstudio.sln2005 = { } local vstudio = premake.vstudio local sln2005 = premake.vstudio.sln2005 function sln2005.generate(sln) io.eol = '\r\n' sln.vstudio_configs = premake.vstudio.buildconfigs(sln) _p('\239\187\191') sln2005.header(sln) for prj in premake.solution.eachproject(sln) do sln2005.project(prj) end _p('Global') sln2005.platforms(sln) sln2005.project_platforms(sln) sln2005.properties(sln) _p('EndGlobal') end function sln2005.header(sln) local version = { vs2005 = 9, vs2008 = 10, vs2010 = 11 } _p('Microsoft Visual Studio Solution File, Format Version %d.00', version[_ACTION]) _p('# Visual Studio %s', _ACTION:sub(3)) end function sln2005.project(prj) local projpath = path.translate(path.getrelative(prj.solution.location, vstudio.projectfile(prj)), "\\") _p('Project("{%s}") = "%s", "%s", "{%s}"', vstudio.tool(prj), prj.name, projpath, prj.uuid) sln2005.projectdependencies(prj) _p('EndProject') end function sln2005.projectdependencies(prj) if _ACTION > "vs2008" and prj.language == "C#" then return end local deps = premake.getdependencies(prj) if #deps > 0 then _p('\tProjectSection(ProjectDependencies) = postProject') for _, dep in ipairs(deps) do _p('\t\t{%s} = {%s}', dep.uuid, dep.uuid) end _p('\tEndProjectSection') end end function sln2005.platforms(sln) _p('\tGlobalSection(SolutionConfigurationPlatforms) = preSolution') for _, cfg in ipairs(sln.vstudio_configs) do _p('\t\t%s = %s', cfg.name, cfg.name) end _p('\tEndGlobalSection') end function sln2005.project_platforms(sln) _p('\tGlobalSection(ProjectConfigurationPlatforms) = postSolution') for prj in premake.solution.eachproject(sln) do for _, cfg in ipairs(sln.vstudio_configs) do local mapped if premake.isdotnetproject(prj) then mapped = "Any CPU" else if cfg.platform == "Any CPU" or cfg.platform == "Mixed Platforms" then mapped = sln.vstudio_configs[3].platform else mapped = cfg.platform end end _p('\t\t{%s}.%s.ActiveCfg = %s|%s', prj.uuid, cfg.name, cfg.buildcfg, mapped) if mapped == cfg.platform or cfg.platform == "Mixed Platforms" then _p('\t\t{%s}.%s.Build.0 = %s|%s', prj.uuid, cfg.name, cfg.buildcfg, mapped) end end end _p('\tEndGlobalSection') end function sln2005.properties(sln) _p('\tGlobalSection(SolutionProperties) = preSolution') _p('\t\tHideSolutionNode = FALSE') _p('\tEndGlobalSection') end premake.vstudio.cs2005 = { } local vstudio = premake.vstudio local cs2005 = premake.vstudio.cs2005 local function getelements(prj, action, fname) if action == "Compile" and fname:endswith(".cs") then if fname:endswith(".Designer.cs") then local basename = fname:sub(1, -13) local testname = basename .. ".cs" if premake.findfile(prj, testname) then return "Dependency", testname end testname = basename .. ".resx" if premake.findfile(prj, testname) then return "AutoGen", testname end else local basename = fname:sub(1, -4) local testname = basename .. ".Designer.cs" if premake.findfile(prj, testname) then return "SubTypeForm" end end end if action == "EmbeddedResource" and fname:endswith(".resx") then local basename = fname:sub(1, -6) local testname = path.getname(basename .. ".cs") if premake.findfile(prj, testname) then if premake.findfile(prj, basename .. ".Designer.cs") then return "DesignerType", testname else return "Dependency", testname end else testname = path.getname(basename .. ".Designer.cs") if premake.findfile(prj, testname) then return "AutoGenerated" end end end if action == "Content" then return "CopyNewest" end return "None" end function cs2005.arch(prj) return "AnyCPU" end function cs2005.files(prj) local tr = premake.project.buildsourcetree(prj) premake.tree.traverse(tr, { onleaf = function(node) local action = premake.dotnet.getbuildaction(node.cfg) local fname = path.translate(premake.esc(node.path), "\\") local elements, dependency = getelements(prj, action, node.path) if elements == "None" then _p(' <%s Include="%s" />', action, fname) else _p(' <%s Include="%s">', action, fname) if elements == "AutoGen" then _p(' True') elseif elements == "AutoGenerated" then _p(' Designer') _p(' ResXFileCodeGenerator') _p(' %s.Designer.cs', premake.esc(path.getbasename(node.name))) elseif elements == "SubTypeDesigner" then _p(' Designer') elseif elements == "SubTypeForm" then _p(' Form') elseif elements == "PreserveNewest" then _p(' PreserveNewest') end if dependency then _p(' %s', path.translate(premake.esc(dependency), "\\")) end _p(' ', action) end end }, false) end function cs2005.projectelement(prj) local toolversion = { vs2005 = '', vs2008 = ' ToolsVersion="3.5"', vs2010 = ' ToolsVersion="4.0"', } if _ACTION > "vs2008" then _p('') end _p('', toolversion[_ACTION]) end function cs2005.projectsettings(prj) local version = { vs2005 = '8.0.50727', vs2008 = '9.0.21022', vs2010 = '8.0.30703', } _p(' ') _p(' %s', premake.esc(prj.solution.configurations[1])) _p(' %s', cs2005.arch(prj)) _p(' %s', version[_ACTION]) _p(' 2.0') _p(' {%s}', prj.uuid) _p(' %s', premake.dotnet.getkind(prj)) _p(' Properties') _p(' %s', prj.buildtarget.basename) _p(' %s', prj.buildtarget.basename) local framework = prj.framework or iif(_ACTION == "vs2010", "4.0", nil) if framework then _p(' v%s', framework) end if _ACTION == "vs2010" then _p(' Client') _p(' 512') end _p(' ') end function cs2005.propertygroup(cfg) _p(' ', premake.esc(cfg.name), cs2005.arch(cfg)) if _ACTION > "vs2008" then _p(' %s', cs2005.arch(cfg)) end end function cs2005.generate(prj) io.eol = "\r\n" cs2005.projectelement(prj) cs2005.projectsettings(prj) for cfg in premake.eachconfig(prj) do cs2005.propertygroup(cfg) if cfg.flags.Symbols then _p(' true') _p(' full') else _p(' pdbonly') end _p(' %s', iif(cfg.flags.Optimize or cfg.flags.OptimizeSize or cfg.flags.OptimizeSpeed, "true", "false")) _p(' %s', cfg.buildtarget.directory) _p(' %s', table.concat(premake.esc(cfg.defines), ";")) _p(' prompt') _p(' 4') if cfg.flags.Unsafe then _p(' true') end if cfg.flags.FatalWarnings then _p(' true') end _p(' ') end _p(' ') for _, ref in ipairs(premake.getlinks(prj, "siblings", "object")) do _p(' ', path.translate(path.getrelative(prj.location, vstudio.projectfile(ref)), "\\")) _p(' {%s}', ref.uuid) _p(' %s', premake.esc(ref.name)) _p(' ') end for _, linkname in ipairs(premake.getlinks(prj, "system", "basename")) do _p(' ', premake.esc(linkname)) end _p(' ') _p(' ') cs2005.files(prj) _p(' ') _p(' ') _p(' ') _p('') end local cs2005 = premake.vstudio.cs2005 function cs2005.generate_user(prj) io.eol = "\r\n" _p('') _p(' ') local refpaths = table.translate(prj.libdirs, function(v) return path.getabsolute(prj.location .. "/" .. v) end) _p(' %s', path.translate(table.concat(refpaths, ";"), "\\")) _p(' ') _p('') end premake.vstudio.vc2010 = { } local vc2010 = premake.vstudio.vc2010 local function vs2010_config(prj) _p(1,'') for _, cfginfo in ipairs(prj.solution.vstudio_configs) do _p(2,'', premake.esc(cfginfo.name)) _p(3,'%s',cfginfo.buildcfg) _p(3,'%s',cfginfo.platform) _p(2,'') end _p(1,'') end local function vs2010_globals(prj) _p(1,'') _p(2,'{%s}',prj.uuid) _p(2,'%s',prj.name) if prj.flags and prj.flags.Managed then _p(2,'v4.0') _p(2,'ManagedCProj') else _p(2,'Win32Proj') end _p(1,'') end function vc2010.config_type(config) local t = { SharedLib = "DynamicLibrary", StaticLib = "StaticLibrary", ConsoleApp = "Application", WindowedApp = "Application" } return t[config.kind] end local function if_config_and_platform() return 'Condition="\'$(Configuration)|$(Platform)\'==\'%s\'"' end local function optimisation(cfg) local result = "Disabled" for _, value in ipairs(cfg.flags) do if (value == "Optimize") then result = "Full" elseif (value == "OptimizeSize") then result = "MinSpace" elseif (value == "OptimizeSpeed") then result = "MaxSpeed" end end return result end local function config_type_block(prj) for _, cfginfo in ipairs(prj.solution.vstudio_configs) do local cfg = premake.getconfig(prj, cfginfo.src_buildcfg, cfginfo.src_platform) _p(1,'' , premake.esc(cfginfo.name)) _p(2,'%s',vc2010.config_type(cfg)) _p(2,'%s',iif(cfg.flags.Unicode,"Unicode","MultiByte")) if cfg.flags.MFC then _p(2,'Dynamic') end _p(2,'%s' ,iif(optimisation(cfg) == "Disabled","true","false")) if cfg.flags.Managed then _p(2,'true') end _p(1,'') end end local function import_props(prj) for _, cfginfo in ipairs(prj.solution.vstudio_configs) do local cfg = premake.getconfig(prj, cfginfo.src_buildcfg, cfginfo.src_platform) _p(1,'' ,premake.esc(cfginfo.name)) _p(2,'') _p(1,'') end end local function incremental_link(cfg,cfginfo) if cfg.kind ~= "StaticLib" then _p(2,'%s' ,premake.esc(cfginfo.name) ,tostring(premake.config.isincrementallink(cfg))) end end local function ignore_import_lib(cfg,cfginfo) if cfg.kind == "SharedLib" then local shouldIgnore = "false" if cfg.flags.NoImportLib then shouldIgnore = "true" end _p(2,'%s' ,premake.esc(cfginfo.name),shouldIgnore) end end local function intermediate_and_out_dirs(prj) _p(1,'') _p(2,'<_ProjectFileVersion>10.0.30319.1') for _, cfginfo in ipairs(prj.solution.vstudio_configs) do local cfg = premake.getconfig(prj, cfginfo.src_buildcfg, cfginfo.src_platform) _p(2,'%s\\' , premake.esc(cfginfo.name),premake.esc(cfg.buildtarget.directory) ) _p(2,'%s\\' , premake.esc(cfginfo.name), premake.esc(cfg.objectsdir)) _p(2,'%s' ,premake.esc(cfginfo.name),path.getbasename(cfg.buildtarget.name)) ignore_import_lib(cfg,cfginfo) incremental_link(cfg,cfginfo) if cfg.flags.NoManifest then _p(2,'false' ,premake.esc(cfginfo.name)) end end _p(1,'') end local function runtime(cfg) local runtime local flags = cfg.flags if premake.config.isdebugbuild(cfg) then runtime = iif(flags.StaticRuntime and not flags.Managed, "MultiThreadedDebug", "MultiThreadedDebugDLL") else runtime = iif(flags.StaticRuntime and not flags.Managed, "MultiThreaded", "MultiThreadedDLL") end return runtime end local function precompiled_header(cfg) if not cfg.flags.NoPCH and cfg.pchheader then _p(3,'Use') _p(3,'%s', path.getname(cfg.pchheader)) else _p(3,'') end end local function preprocessor(indent,cfg) if #cfg.defines > 0 then _p(indent,'%s;%%(PreprocessorDefinitions)' ,premake.esc(table.concat(cfg.defines, ";"))) else _p(indent,'') end end local function include_dirs(indent,cfg) if #cfg.includedirs > 0 then _p(indent,'%s;%%(AdditionalIncludeDirectories)' ,premake.esc(path.translate(table.concat(cfg.includedirs, ";"), '\\'))) end end local function resource_compile(cfg) _p(2,'') preprocessor(3,cfg) include_dirs(3,cfg) _p(2,'') end local function exceptions(cfg) if cfg.flags.NoExceptions then _p(2,'false') elseif cfg.flags.SEH then _p(2,'Async') end end local function rtti(cfg) if cfg.flags.NoRTTI and not cfg.flags.Managed then _p(3,'false') end end local function wchar_t_buildin(cfg) if cfg.flags.NativeWChar then _p(3,'true') elseif cfg.flags.NoNativeWChar then _p(3,'false') end end local function sse(cfg) if cfg.flags.EnableSSE then _p(3,'StreamingSIMDExtensions') elseif cfg.flags.EnableSSE2 then _p(3,'StreamingSIMDExtensions2') end end local function floating_point(cfg) if cfg.flags.FloatFast then _p(3,'Fast') elseif cfg.flags.FloatStrict and not cfg.flags.Managed then _p(3,'Strict') end end local function debug_info(cfg) local debug_info = '' if cfg.flags.Symbols then if cfg.platform == "x64" or cfg.flags.Managed or premake.config.isoptimizedbuild(cfg.flags) or cfg.flags.NoEditAndContinue then debug_info = "ProgramDatabase" else debug_info = "EditAndContinue" end end _p(3,'%s',debug_info) end local function minimal_build(cfg) if premake.config.isdebugbuild(cfg) and not cfg.flags.NoMinimalRebuild then _p(3,'true') else _p(3,'false') end end local function compile_language(cfg) if cfg.language == "C" then _p(3,'CompileAsC') end end local function vs10_clcompile(cfg) _p(2,'') if #cfg.buildoptions > 0 then _p(3,'%s %%(AdditionalOptions)', table.concat(premake.esc(cfg.buildoptions), " ")) end _p(3,'%s',optimisation(cfg)) include_dirs(3,cfg) preprocessor(3,cfg) minimal_build(cfg) if not premake.config.isoptimizedbuild(cfg.flags) then if not cfg.flags.Managed then _p(3,'EnableFastChecks') end if cfg.flags.ExtraWarnings then _p(3,'true') end else _p(3,'true') end _p(3,'%s', runtime(cfg)) _p(3,'true') precompiled_header(cfg) if cfg.flags.ExtraWarnings then _p(3,'Level4') else _p(3,'Level3') end if cfg.flags.FatalWarnings then _p(3,'true') end exceptions(cfg) rtti(cfg) wchar_t_buildin(cfg) sse(cfg) floating_point(cfg) debug_info(cfg) if cfg.flags.Symbols then _p(3,'$(OutDir)%s.pdb' , path.getbasename(cfg.buildtarget.name)) end if cfg.flags.NoFramePointer then _p(3,'true') end compile_language(cfg) _p(2,'') end local function event_hooks(cfg) if #cfg.postbuildcommands> 0 then _p(2,'') _p(3,'%s',premake.esc(table.implode(cfg.postbuildcommands, "", "", "\r\n"))) _p(2,'') end if #cfg.prebuildcommands> 0 then _p(2,'') _p(3,'%s',premake.esc(table.implode(cfg.prebuildcommands, "", "", "\r\n"))) _p(2,'') end if #cfg.prelinkcommands> 0 then _p(2,'') _p(3,'%s',premake.esc(table.implode(cfg.prelinkcommands, "", "", "\r\n"))) _p(2,'') end end local function additional_options(indent,cfg) if #cfg.linkoptions > 0 then _p(indent,'%s %%(AdditionalOptions)', table.concat(premake.esc(cfg.linkoptions), " ")) end end local function link_target_machine(index,cfg) local platforms = {x32 = 'MachineX86',Native = 'MachineX86', x64 = 'MachineX64'} if platforms[cfg.platform] then _p(index,'%s', platforms[cfg.platform]) end end local function item_def_lib(cfg) if cfg.kind == 'StaticLib' then _p(1,'') _p(2,'$(OutDir)%s',cfg.buildtarget.name) additional_options(2,cfg) link_target_machine(2,cfg) _p(1,'') end end local function import_lib(cfg) if cfg.kind == "SharedLib" then local implibname = cfg.linktarget.fullpath _p(3,'%s',iif(cfg.flags.NoImportLib, cfg.objectsdir .. "\\" .. path.getname(implibname), implibname)) end end local function common_link_section(cfg) _p(3,'%s',iif(cfg.kind == "ConsoleApp","Console", "Windows")) if cfg.flags.Symbols then _p(3,'true') else _p(3,'false') end if premake.config.isoptimizedbuild(cfg.flags) then _p(3,'true') _p(3,'true') end end local function item_link(cfg) _p(2,'') if cfg.kind ~= 'StaticLib' then if #cfg.links > 0 then _p(3,'%s;%%(AdditionalDependencies)', table.concat(premake.getlinks(cfg, "all", "fullpath"), ";")) end _p(3,'$(OutDir)%s', cfg.buildtarget.name) _p(3,'%s%s%%(AdditionalLibraryDirectories)', table.concat(premake.esc(path.translate(cfg.libdirs, '\\')) , ";"), iif(cfg.libdirs and #cfg.libdirs >0,';','')) common_link_section(cfg) if vc2010.config_type(cfg) == 'Application' and not cfg.flags.WinMain and not cfg.flags.Managed then _p(3,'mainCRTStartup') end import_lib(cfg) link_target_machine(3,cfg) additional_options(3,cfg) else common_link_section(cfg) end _p(2,'') end local function item_definitions(prj) for _, cfginfo in ipairs(prj.solution.vstudio_configs) do local cfg = premake.getconfig(prj, cfginfo.src_buildcfg, cfginfo.src_platform) _p(1,'' ,premake.esc(cfginfo.name)) vs10_clcompile(cfg) resource_compile(cfg) item_def_lib(cfg) item_link(cfg) event_hooks(cfg) _p(1,'') end end function vc2010.getfilegroup(prj, group) local sortedfiles = prj.vc2010sortedfiles if not sortedfiles then sortedfiles = { ClCompile = {}, ClInclude = {}, None = {}, ResourceCompile = {}, } for file in premake.project.eachfile(prj) do if path.iscppfile(file.name) then table.insert(sortedfiles.ClCompile, file) elseif path.iscppheader(file.name) then table.insert(sortedfiles.ClInclude, file) elseif path.isresourcefile(file.name) then table.insert(sortedfiles.ResourceCompile, file) else table.insert(sortedfiles.None, file) end end prj.vc2010sortedfiles = sortedfiles end return sortedfiles[group] end function vc2010.files(prj) vc2010.simplefilesgroup(prj, "ClInclude") vc2010.compilerfilesgroup(prj) vc2010.simplefilesgroup(prj, "None") vc2010.simplefilesgroup(prj, "ResourceCompile") end function vc2010.simplefilesgroup(prj, section) local files = vc2010.getfilegroup(prj, section) if #files > 0 then _p(1,'') for _, file in ipairs(files) do _p(2,'<%s Include=\"%s\" />', section, path.translate(file.name, "\\")) end _p(1,'') end end function vc2010.compilerfilesgroup(prj) local configs = prj.solution.vstudio_configs local files = vc2010.getfilegroup(prj, "ClCompile") if #files > 0 then local config_mappings = {} for _, cfginfo in ipairs(configs) do local cfg = premake.getconfig(prj, cfginfo.src_buildcfg, cfginfo.src_platform) if cfg.pchheader and cfg.pchsource and not cfg.flags.NoPCH then config_mappings[cfginfo] = path.translate(cfg.pchsource, "\\") end end _p(1,'') for _, file in ipairs(files) do _p(2,'', path.translate(file.name, "\\")) for _, cfginfo in ipairs(configs) do if config_mappings[cfginfo] and file.name == config_mappings[cfginfo] then _p(3,'Create', premake.esc(cfginfo.name)) config_mappings[cfginfo] = nil --only one source file per pch end end _p(2,'') end _p(1,'') end end function vc2010.header(targets) io.eol = "\r\n" _p('') local t = "" if targets then t = ' DefaultTargets="' .. targets .. '"' end _p('', t) end function premake.vs2010_vcxproj(prj) io.indent = " " vc2010.header("Build") vs2010_config(prj) vs2010_globals(prj) _p(1,'') config_type_block(prj) _p(1,'') _p(1,'') _p(1,'') import_props(prj) _p(1,'') intermediate_and_out_dirs(prj) item_definitions(prj) vc2010.files(prj) _p(1,'') _p(1,'') _p(1,'') _p('') end function vc2010.debugdir(cfg) if cfg.debugdir then _p(' %s', path.translate(cfg.debugdir, '\\')) _p(' WindowsLocalDebugger') end if cfg.debugargs then _p(' %s', table.concat(cfg.debugargs, " ")) end end function premake.vs2010_vcxproj_user(prj) io.indent = " " vc2010.header() for _, cfginfo in ipairs(prj.solution.vstudio_configs) do local cfg = premake.getconfig(prj, cfginfo.src_buildcfg, cfginfo.src_platform) _p(' ', premake.esc(cfginfo.name)) vc2010.debugdir(cfg) _p(' ') end _p('') end local vc2010 = premake.vstudio.vc2010 local project = premake.project function vc2010.filteridgroup(prj) local filters = { } local filterfound = false for file in project.eachfile(prj) do local folders = string.explode(file.vpath, "/", true) local path = "" for i = 1, #folders - 1 do if not filterfound then filterfound = true _p(1,'') end path = path .. folders[i] if not filters[path] then filters[path] = true _p(2, '', path) _p(3, '{%s}', os.uuid()) _p(2, '') end path = path .. "\\" end end if filterfound then _p(1,'') end end function vc2010.filefiltergroup(prj, section) local files = vc2010.getfilegroup(prj, section) if #files > 0 then _p(1,'') for _, file in ipairs(files) do local filter if file.name ~= file.vpath then filter = path.getdirectory(file.vpath) else filter = path.getdirectory(file.name) end if filter ~= "." then _p(2,'<%s Include=\"%s\">', section, path.translate(file.name, "\\")) _p(3,'%s', path.translate(filter, "\\")) _p(2,'', section) else _p(2,'<%s Include=\"%s\" />', section, path.translate(file.name, "\\")) end end _p(1,'') end end function vc2010.generate_filters(prj) io.indent = " " vc2010.header() vc2010.filteridgroup(prj) vc2010.filefiltergroup(prj, "None") vc2010.filefiltergroup(prj, "ClInclude") vc2010.filefiltergroup(prj, "ClCompile") vc2010.filefiltergroup(prj, "ResourceCompile") _p('') end premake.xcode = { } newaction { trigger = "xcode3", shortname = "Xcode 3", description = "Generate Apple Xcode 3 project files (experimental)", os = "macosx", valid_kinds = { "ConsoleApp", "WindowedApp", "SharedLib", "StaticLib" }, valid_languages = { "C", "C++" }, valid_tools = { cc = { "gcc" }, }, valid_platforms = { Native = "Native", x32 = "Native 32-bit", x64 = "Native 64-bit", Universal32 = "32-bit Universal", Universal64 = "64-bit Universal", Universal = "Universal", }, default_platform = "Universal", onsolution = function(sln) premake.xcode.preparesolution(sln) end, onproject = function(prj) premake.generate(prj, "%%.xcodeproj/project.pbxproj", premake.xcode.project) end, oncleanproject = function(prj) premake.clean.directory(prj, "%%.xcodeproj") end, oncheckproject = function(prj) local last for cfg in premake.eachconfig(prj) do if last and last ~= cfg.kind then error("Project '" .. prj.name .. "' uses more than one target kind; not supported by Xcode", 0) end last = cfg.kind end end, } newaction { trigger = "xcode4", shortname = "Xcode 4", description = "Generate Apple Xcode 4 project files (experimental)", os = "macosx", valid_kinds = { "ConsoleApp", "WindowedApp", "SharedLib", "StaticLib" }, valid_languages = { "C", "C++" }, valid_tools = { cc = { "gcc" }, }, valid_platforms = { Native = "Native", x32 = "Native 32-bit", x64 = "Native 64-bit", Universal32 = "32-bit Universal", Universal64 = "64-bit Universal", Universal = "Universal", }, default_platform = "Universal", onsolution = function(sln) premake.generate(sln, "%%.xcworkspace/contents.xcworkspacedata", premake.xcode4.workspace_generate) end, onproject = function(prj) premake.generate(prj, "%%.xcodeproj/project.pbxproj", premake.xcode.project) end, oncleanproject = function(prj) premake.clean.directory(prj, "%%.xcodeproj") premake.clean.directory(prj, "%%.xcworkspace") end, oncheckproject = function(prj) local last for cfg in premake.eachconfig(prj) do if last and last ~= cfg.kind then error("Project '" .. prj.name .. "' uses more than one target kind; not supported by Xcode", 0) end last = cfg.kind end end, } local xcode = premake.xcode local tree = premake.tree function xcode.getbuildcategory(node) local categories = { [".a"] = "Frameworks", [".c"] = "Sources", [".cc"] = "Sources", [".cpp"] = "Sources", [".cxx"] = "Sources", [".dylib"] = "Frameworks", [".framework"] = "Frameworks", [".m"] = "Sources", [".mm"] = "Sources", [".strings"] = "Resources", [".nib"] = "Resources", [".xib"] = "Resources", [".icns"] = "Resources", } return categories[path.getextension(node.name)] end function xcode.getconfigname(cfg) local name = cfg.name if #cfg.project.solution.xcode.platforms > 1 then name = name .. " " .. premake.action.current().valid_platforms[cfg.platform] end return name end function xcode.getfiletype(node) local types = { [".c"] = "sourcecode.c.c", [".cc"] = "sourcecode.cpp.cpp", [".cpp"] = "sourcecode.cpp.cpp", [".css"] = "text.css", [".cxx"] = "sourcecode.cpp.cpp", [".framework"] = "wrapper.framework", [".gif"] = "image.gif", [".h"] = "sourcecode.c.h", [".html"] = "text.html", [".lua"] = "sourcecode.lua", [".m"] = "sourcecode.c.objc", [".mm"] = "sourcecode.cpp.objc", [".nib"] = "wrapper.nib", [".pch"] = "sourcecode.c.h", [".plist"] = "text.plist.xml", [".strings"] = "text.plist.strings", [".xib"] = "file.xib", [".icns"] = "image.icns", } return types[path.getextension(node.path)] or "text" end function xcode.getproducttype(node) local types = { ConsoleApp = "com.apple.product-type.tool", WindowedApp = "com.apple.product-type.application", StaticLib = "com.apple.product-type.library.static", SharedLib = "com.apple.product-type.library.dynamic", } return types[node.cfg.kind] end function xcode.gettargettype(node) local types = { ConsoleApp = "\"compiled.mach-o.executable\"", WindowedApp = "wrapper.application", StaticLib = "archive.ar", SharedLib = "\"compiled.mach-o.dylib\"", } return types[node.cfg.kind] end function xcode.getxcodeprojname(prj) local fname = premake.project.getfilename(prj, "%%.xcodeproj") return fname end function xcode.isframework(fname) return (path.getextension(fname) == ".framework") end function xcode.newid() return string.format("%04X%04X%04X%04X%04X%04X", math.random(0, 32767), math.random(0, 32767), math.random(0, 32767), math.random(0, 32767), math.random(0, 32767), math.random(0, 32767)) end function xcode.preparesolution(sln) sln.xcode = { } sln.xcode.platforms = premake.filterplatforms(sln, premake.action.current().valid_platforms, "Universal") for prj in premake.solution.eachproject(sln) do local cfg = premake.getconfig(prj, prj.configurations[1], sln.xcode.platforms[1]) local node = premake.tree.new(path.getname(cfg.buildtarget.bundlepath)) node.cfg = cfg node.id = premake.xcode.newid(node, "product") node.targetid = premake.xcode.newid(node, "target") prj.xcode = {} prj.xcode.projectnode = node end end function xcode.printlist(list, tag) if #list > 0 then _p(4,'%s = (', tag) for _, item in ipairs(list) do _p(5, '"%s",', item) end _p(4,');') end end function xcode.Header() _p('// !$*UTF8*$!') _p('{') _p(1,'archiveVersion = 1;') _p(1,'classes = {') _p(1,'};') _p(1,'objectVersion = 45;') _p(1,'objects = {') _p('') end function xcode.PBXBuildFile(tr) _p('/* Begin PBXBuildFile section */') tree.traverse(tr, { onnode = function(node) if node.buildid then _p(2,'%s /* %s in %s */ = {isa = PBXBuildFile; fileRef = %s /* %s */; };', node.buildid, node.name, xcode.getbuildcategory(node), node.id, node.name) end end }) _p('/* End PBXBuildFile section */') _p('') end function xcode.PBXContainerItemProxy(tr) if #tr.projects.children > 0 then _p('/* Begin PBXContainerItemProxy section */') for _, node in ipairs(tr.projects.children) do _p(2,'%s /* PBXContainerItemProxy */ = {', node.productproxyid) _p(3,'isa = PBXContainerItemProxy;') _p(3,'containerPortal = %s /* %s */;', node.id, path.getname(node.path)) _p(3,'proxyType = 2;') _p(3,'remoteGlobalIDString = %s;', node.project.xcode.projectnode.id) _p(3,'remoteInfo = "%s";', node.project.xcode.projectnode.name) _p(2,'};') _p(2,'%s /* PBXContainerItemProxy */ = {', node.targetproxyid) _p(3,'isa = PBXContainerItemProxy;') _p(3,'containerPortal = %s /* %s */;', node.id, path.getname(node.path)) _p(3,'proxyType = 1;') _p(3,'remoteGlobalIDString = %s;', node.project.xcode.projectnode.targetid) _p(3,'remoteInfo = "%s";', node.project.xcode.projectnode.name) _p(2,'};') end _p('/* End PBXContainerItemProxy section */') _p('') end end function xcode.PBXFileReference(tr) _p('/* Begin PBXFileReference section */') tree.traverse(tr, { onleaf = function(node) if not node.path then return end if node.kind == "product" then _p(2,'%s /* %s */ = {isa = PBXFileReference; explicitFileType = %s; includeInIndex = 0; name = "%s"; path = "%s"; sourceTree = BUILT_PRODUCTS_DIR; };', node.id, node.name, xcode.gettargettype(node), node.name, path.getname(node.cfg.buildtarget.bundlepath)) elseif node.parent.parent == tr.projects then local relpath = path.getrelative(tr.project.location, node.parent.project.location) _p(2,'%s /* %s */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = "%s"; path = "%s"; sourceTree = SOURCE_ROOT; };', node.parent.id, node.parent.name, node.parent.name, path.join(relpath, node.parent.name)) else local pth, src if xcode.isframework(node.path) then if string.find(node.path,'/') then if string.find(node.path,'^%.')then error('relative paths are not currently supported for frameworks') end pth = node.path else pth = "/System/Library/Frameworks/" .. node.path end src = "absolute" else src = "group" if node.parent.isvpath then pth = node.cfg.name else pth = tree.getlocalpath(node) end end _p(2,'%s /* %s */ = {isa = PBXFileReference; lastKnownFileType = %s; name = "%s"; path = "%s"; sourceTree = "<%s>"; };', node.id, node.name, xcode.getfiletype(node), node.name, pth, src) end end }) _p('/* End PBXFileReference section */') _p('') end function xcode.PBXFrameworksBuildPhase(tr) _p('/* Begin PBXFrameworksBuildPhase section */') _p(2,'%s /* Frameworks */ = {', tr.products.children[1].fxstageid) _p(3,'isa = PBXFrameworksBuildPhase;') _p(3,'buildActionMask = 2147483647;') _p(3,'files = (') tree.traverse(tr.frameworks, { onleaf = function(node) _p(4,'%s /* %s in Frameworks */,', node.buildid, node.name) end }) tree.traverse(tr.projects, { onleaf = function(node) _p(4,'%s /* %s in Frameworks */,', node.buildid, node.name) end }) _p(3,');') _p(3,'runOnlyForDeploymentPostprocessing = 0;') _p(2,'};') _p('/* End PBXFrameworksBuildPhase section */') _p('') end function xcode.PBXGroup(tr) _p('/* Begin PBXGroup section */') tree.traverse(tr, { onnode = function(node) if (node.path and #node.children == 0) or node.kind == "vgroup" then return end if node.parent == tr.projects then _p(2,'%s /* Products */ = {', node.productgroupid) else _p(2,'%s /* %s */ = {', node.id, node.name) end _p(3,'isa = PBXGroup;') _p(3,'children = (') for _, childnode in ipairs(node.children) do _p(4,'%s /* %s */,', childnode.id, childnode.name) end _p(3,');') if node.parent == tr.projects then _p(3,'name = Products;') else _p(3,'name = "%s";', node.name) if node.path and not node.isvpath then local p = node.path if node.parent.path then p = path.getrelative(node.parent.path, node.path) end _p(3,'path = "%s";', p) end end _p(3,'sourceTree = "";') _p(2,'};') end }, true) _p('/* End PBXGroup section */') _p('') end function xcode.PBXNativeTarget(tr) _p('/* Begin PBXNativeTarget section */') for _, node in ipairs(tr.products.children) do local name = tr.project.name _p(2,'%s /* %s */ = {', node.targetid, name) _p(3,'isa = PBXNativeTarget;') _p(3,'buildConfigurationList = %s /* Build configuration list for PBXNativeTarget "%s" */;', node.cfgsection, name) _p(3,'buildPhases = (') if #tr.project.prebuildcommands > 0 then _p(4,'9607AE1010C857E500CD1376 /* Prebuild */,') end _p(4,'%s /* Resources */,', node.resstageid) _p(4,'%s /* Sources */,', node.sourcesid) if #tr.project.prelinkcommands > 0 then _p(4,'9607AE3510C85E7E00CD1376 /* Prelink */,') end _p(4,'%s /* Frameworks */,', node.fxstageid) if #tr.project.postbuildcommands > 0 then _p(4,'9607AE3710C85E8F00CD1376 /* Postbuild */,') end _p(3,');') _p(3,'buildRules = (') _p(3,');') _p(3,'dependencies = (') for _, node in ipairs(tr.projects.children) do _p(4,'%s /* PBXTargetDependency */,', node.targetdependid) end _p(3,');') _p(3,'name = "%s";', name) local p if node.cfg.kind == "ConsoleApp" then p = "$(HOME)/bin" elseif node.cfg.kind == "WindowedApp" then p = "$(HOME)/Applications" end if p then _p(3,'productInstallPath = "%s";', p) end _p(3,'productName = "%s";', name) _p(3,'productReference = %s /* %s */;', node.id, node.name) _p(3,'productType = "%s";', xcode.getproducttype(node)) _p(2,'};') end _p('/* End PBXNativeTarget section */') _p('') end function xcode.PBXProject(tr) _p('/* Begin PBXProject section */') _p(2,'08FB7793FE84155DC02AAC07 /* Project object */ = {') _p(3,'isa = PBXProject;') _p(3,'buildConfigurationList = 1DEB928908733DD80010E9CD /* Build configuration list for PBXProject "%s" */;', tr.name) _p(3,'compatibilityVersion = "Xcode 3.1";') _p(3,'hasScannedForEncodings = 1;') _p(3,'mainGroup = %s /* %s */;', tr.id, tr.name) _p(3,'projectDirPath = "";') if #tr.projects.children > 0 then _p(3,'projectReferences = (') for _, node in ipairs(tr.projects.children) do _p(4,'{') _p(5,'ProductGroup = %s /* Products */;', node.productgroupid) _p(5,'ProjectRef = %s /* %s */;', node.id, path.getname(node.path)) _p(4,'},') end _p(3,');') end _p(3,'projectRoot = "";') _p(3,'targets = (') for _, node in ipairs(tr.products.children) do _p(4,'%s /* %s */,', node.targetid, node.name) end _p(3,');') _p(2,'};') _p('/* End PBXProject section */') _p('') end function xcode.PBXReferenceProxy(tr) if #tr.projects.children > 0 then _p('/* Begin PBXReferenceProxy section */') tree.traverse(tr.projects, { onleaf = function(node) _p(2,'%s /* %s */ = {', node.id, node.name) _p(3,'isa = PBXReferenceProxy;') _p(3,'fileType = %s;', xcode.gettargettype(node)) _p(3,'path = "%s";', node.path) _p(3,'remoteRef = %s /* PBXContainerItemProxy */;', node.parent.productproxyid) _p(3,'sourceTree = BUILT_PRODUCTS_DIR;') _p(2,'};') end }) _p('/* End PBXReferenceProxy section */') _p('') end end function xcode.PBXResourcesBuildPhase(tr) _p('/* Begin PBXResourcesBuildPhase section */') for _, target in ipairs(tr.products.children) do _p(2,'%s /* Resources */ = {', target.resstageid) _p(3,'isa = PBXResourcesBuildPhase;') _p(3,'buildActionMask = 2147483647;') _p(3,'files = (') tree.traverse(tr, { onnode = function(node) if xcode.getbuildcategory(node) == "Resources" then _p(4,'%s /* %s in Resources */,', node.buildid, node.name) end end }) _p(3,');') _p(3,'runOnlyForDeploymentPostprocessing = 0;') _p(2,'};') end _p('/* End PBXResourcesBuildPhase section */') _p('') end function xcode.PBXShellScriptBuildPhase(tr) local wrapperWritten = false local function doblock(id, name, which) local prjcmds = tr.project[which] local commands = table.join(prjcmds, {}) for _, cfg in ipairs(tr.configs) do local cfgcmds = cfg[which] if #cfgcmds > #prjcmds then table.insert(commands, 'if [ "${CONFIGURATION}" = "' .. xcode.getconfigname(cfg) .. '" ]; then') for i = #prjcmds + 1, #cfgcmds do table.insert(commands, cfgcmds[i]) end table.insert(commands, 'fi') end end if #commands > 0 then if not wrapperWritten then _p('/* Begin PBXShellScriptBuildPhase section */') wrapperWritten = true end _p(2,'%s /* %s */ = {', id, name) _p(3,'isa = PBXShellScriptBuildPhase;') _p(3,'buildActionMask = 2147483647;') _p(3,'files = (') _p(3,');') _p(3,'inputPaths = ('); _p(3,');'); _p(3,'name = %s;', name); _p(3,'outputPaths = ('); _p(3,');'); _p(3,'runOnlyForDeploymentPostprocessing = 0;'); _p(3,'shellPath = /bin/sh;'); _p(3,'shellScript = "%s";', table.concat(commands, "\\n"):gsub('"', '\\"')) _p(2,'};') end end doblock("9607AE1010C857E500CD1376", "Prebuild", "prebuildcommands") doblock("9607AE3510C85E7E00CD1376", "Prelink", "prelinkcommands") doblock("9607AE3710C85E8F00CD1376", "Postbuild", "postbuildcommands") if wrapperWritten then _p('/* End PBXShellScriptBuildPhase section */') end end function xcode.PBXSourcesBuildPhase(tr) _p('/* Begin PBXSourcesBuildPhase section */') for _, target in ipairs(tr.products.children) do _p(2,'%s /* Sources */ = {', target.sourcesid) _p(3,'isa = PBXSourcesBuildPhase;') _p(3,'buildActionMask = 2147483647;') _p(3,'files = (') tree.traverse(tr, { onleaf = function(node) if xcode.getbuildcategory(node) == "Sources" then _p(4,'%s /* %s in Sources */,', node.buildid, node.name) end end }) _p(3,');') _p(3,'runOnlyForDeploymentPostprocessing = 0;') _p(2,'};') end _p('/* End PBXSourcesBuildPhase section */') _p('') end function xcode.PBXVariantGroup(tr) _p('/* Begin PBXVariantGroup section */') tree.traverse(tr, { onbranch = function(node) if node.kind == "vgroup" then _p(2,'%s /* %s */ = {', node.id, node.name) _p(3,'isa = PBXVariantGroup;') _p(3,'children = (') for _, lang in ipairs(node.children) do _p(4,'%s /* %s */,', lang.id, lang.name) end _p(3,');') _p(3,'name = %s;', node.name) _p(3,'sourceTree = "";') _p(2,'};') end end }) _p('/* End PBXVariantGroup section */') _p('') end function xcode.PBXTargetDependency(tr) if #tr.projects.children > 0 then _p('/* Begin PBXTargetDependency section */') tree.traverse(tr.projects, { onleaf = function(node) _p(2,'%s /* PBXTargetDependency */ = {', node.parent.targetdependid) _p(3,'isa = PBXTargetDependency;') _p(3,'name = "%s";', node.name) _p(3,'targetProxy = %s /* PBXContainerItemProxy */;', node.parent.targetproxyid) _p(2,'};') end }) _p('/* End PBXTargetDependency section */') _p('') end end function xcode.XCBuildConfiguration_Target(tr, target, cfg) local cfgname = xcode.getconfigname(cfg) _p(2,'%s /* %s */ = {', cfg.xcode.targetid, cfgname) _p(3,'isa = XCBuildConfiguration;') _p(3,'buildSettings = {') _p(4,'ALWAYS_SEARCH_USER_PATHS = NO;') if not cfg.flags.Symbols then _p(4,'DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";') end if cfg.kind ~= "StaticLib" and cfg.buildtarget.prefix ~= "" then _p(4,'EXECUTABLE_PREFIX = %s;', cfg.buildtarget.prefix) end local outdir = path.getdirectory(cfg.buildtarget.bundlepath) if outdir ~= "." then _p(4,'CONFIGURATION_BUILD_DIR = %s;', outdir) end _p(4,'GCC_DYNAMIC_NO_PIC = NO;') _p(4,'GCC_MODEL_TUNING = G5;') if tr.infoplist then _p(4,'INFOPLIST_FILE = "%s";', tr.infoplist.path) end installpaths = { ConsoleApp = '/usr/local/bin', WindowedApp = '"$(HOME)/Applications"', SharedLib = '/usr/local/lib', StaticLib = '/usr/local/lib', } _p(4,'INSTALL_PATH = %s;', installpaths[cfg.kind]) _p(4,'PRODUCT_NAME = "%s";', cfg.buildtarget.basename) _p(3,'};') _p(3,'name = "%s";', cfgname) _p(2,'};') end function xcode.XCBuildConfiguration_Project(tr, cfg) local cfgname = xcode.getconfigname(cfg) _p(2,'%s /* %s */ = {', cfg.xcode.projectid, cfgname) _p(3,'isa = XCBuildConfiguration;') _p(3,'buildSettings = {') local archs = { Native = "$(NATIVE_ARCH_ACTUAL)", x32 = "i386", x64 = "x86_64", Universal32 = "$(ARCHS_STANDARD_32_BIT)", Universal64 = "$(ARCHS_STANDARD_64_BIT)", Universal = "$(ARCHS_STANDARD_32_64_BIT)", } _p(4,'ARCHS = "%s";', archs[cfg.platform]) local targetdir = path.getdirectory(cfg.buildtarget.bundlepath) if targetdir ~= "." then _p(4,'CONFIGURATION_BUILD_DIR = "$(SYMROOT)";'); end _p(4,'CONFIGURATION_TEMP_DIR = "$(OBJROOT)";') if cfg.flags.Symbols then _p(4,'COPY_PHASE_STRIP = NO;') end _p(4,'GCC_C_LANGUAGE_STANDARD = gnu99;') if cfg.flags.NoExceptions then _p(4,'GCC_ENABLE_CPP_EXCEPTIONS = NO;') end if cfg.flags.NoRTTI then _p(4,'GCC_ENABLE_CPP_RTTI = NO;') end if cfg.flags.Symbols and not cfg.flags.NoEditAndContinue then _p(4,'GCC_ENABLE_FIX_AND_CONTINUE = YES;') end if cfg.flags.NoExceptions then _p(4,'GCC_ENABLE_OBJC_EXCEPTIONS = NO;') end if cfg.flags.Optimize or cfg.flags.OptimizeSize then _p(4,'GCC_OPTIMIZATION_LEVEL = s;') elseif cfg.flags.OptimizeSpeed then _p(4,'GCC_OPTIMIZATION_LEVEL = 3;') else _p(4,'GCC_OPTIMIZATION_LEVEL = 0;') end if cfg.pchheader and not cfg.flags.NoPCH then _p(4,'GCC_PRECOMPILE_PREFIX_HEADER = YES;') _p(4,'GCC_PREFIX_HEADER = "%s";', cfg.pchheader) end xcode.printlist(cfg.defines, 'GCC_PREPROCESSOR_DEFINITIONS') _p(4,'GCC_SYMBOLS_PRIVATE_EXTERN = NO;') if cfg.flags.FatalWarnings then _p(4,'GCC_TREAT_WARNINGS_AS_ERRORS = YES;') end _p(4,'GCC_WARN_ABOUT_RETURN_TYPE = YES;') _p(4,'GCC_WARN_UNUSED_VARIABLE = YES;') xcode.printlist(cfg.includedirs, 'HEADER_SEARCH_PATHS') xcode.printlist(cfg.libdirs, 'LIBRARY_SEARCH_PATHS') _p(4,'OBJROOT = "%s";', cfg.objectsdir) _p(4,'ONLY_ACTIVE_ARCH = %s;',iif(premake.config.isdebugbuild(cfg),'YES','NO')) local checks = { ["-ffast-math"] = cfg.flags.FloatFast, ["-ffloat-store"] = cfg.flags.FloatStrict, ["-fomit-frame-pointer"] = cfg.flags.NoFramePointer, } local flags = { } for flag, check in pairs(checks) do if check then table.insert(flags, flag) end end xcode.printlist(table.join(flags, cfg.buildoptions), 'OTHER_CFLAGS') flags = { } for _, lib in ipairs(premake.getlinks(cfg, "system")) do if not xcode.isframework(lib) then table.insert(flags, "-l" .. lib) end end flags = table.join(flags, cfg.linkoptions) xcode.printlist(flags, 'OTHER_LDFLAGS') _p(4,'PREBINDING = NO;') if cfg.flags.StaticRuntime then _p(4,'STANDARD_C_PLUS_PLUS_LIBRARY_TYPE = static;') end if targetdir ~= "." then _p(4,'SYMROOT = "%s";', targetdir) end if cfg.flags.ExtraWarnings then _p(4,'WARNING_CFLAGS = "-Wall";') end _p(3,'};') _p(3,'name = "%s";', cfgname) _p(2,'};') end function xcode.XCBuildConfiguration(tr) _p('/* Begin XCBuildConfiguration section */') for _, target in ipairs(tr.products.children) do for _, cfg in ipairs(tr.configs) do xcode.XCBuildConfiguration_Target(tr, target, cfg) end end for _, cfg in ipairs(tr.configs) do xcode.XCBuildConfiguration_Project(tr, cfg) end _p('/* End XCBuildConfiguration section */') _p('') end function xcode.XCBuildConfigurationList(tr) local sln = tr.project.solution _p('/* Begin XCConfigurationList section */') for _, target in ipairs(tr.products.children) do _p(2,'%s /* Build configuration list for PBXNativeTarget "%s" */ = {', target.cfgsection, target.name) _p(3,'isa = XCConfigurationList;') _p(3,'buildConfigurations = (') for _, cfg in ipairs(tr.configs) do _p(4,'%s /* %s */,', cfg.xcode.targetid, xcode.getconfigname(cfg)) end _p(3,');') _p(3,'defaultConfigurationIsVisible = 0;') _p(3,'defaultConfigurationName = "%s";', xcode.getconfigname(tr.configs[1])) _p(2,'};') end _p(2,'1DEB928908733DD80010E9CD /* Build configuration list for PBXProject "%s" */ = {', tr.name) _p(3,'isa = XCConfigurationList;') _p(3,'buildConfigurations = (') for _, cfg in ipairs(tr.configs) do _p(4,'%s /* %s */,', cfg.xcode.projectid, xcode.getconfigname(cfg)) end _p(3,');') _p(3,'defaultConfigurationIsVisible = 0;') _p(3,'defaultConfigurationName = "%s";', xcode.getconfigname(tr.configs[1])) _p(2,'};') _p('/* End XCConfigurationList section */') _p('') end function xcode.Footer() _p(1,'};') _p('\trootObject = 08FB7793FE84155DC02AAC07 /* Project object */;') _p('}') end local xcode = premake.xcode local tree = premake.tree function xcode.buildprjtree(prj) local tr = premake.project.buildsourcetree(prj) tr.configs = {} for _, cfgname in ipairs(prj.solution.configurations) do for _, platform in ipairs(prj.solution.xcode.platforms) do local cfg = premake.getconfig(prj, cfgname, platform) cfg.xcode = {} cfg.xcode.targetid = xcode.newid(prj.xcode.projectnode, cfgname) cfg.xcode.projectid = xcode.newid(tr, cfgname) table.insert(tr.configs, cfg) end end tree.traverse(tr, { onbranch = function(node) if path.getextension(node.name) == ".lproj" then local lang = path.getbasename(node.name) -- "English", "French", etc. for _, filenode in ipairs(node.children) do local grpnode = node.parent.children[filenode.name] if not grpnode then grpnode = tree.insert(node.parent, tree.new(filenode.name)) grpnode.kind = "vgroup" end filenode.name = path.getbasename(lang) tree.insert(grpnode, filenode) end tree.remove(node) end end }) tr.frameworks = tree.new("Frameworks") for cfg in premake.eachconfig(prj) do for _, link in ipairs(premake.getlinks(cfg, "system", "fullpath")) do local name = path.getname(link) if xcode.isframework(name) and not tr.frameworks.children[name] then node = tree.insert(tr.frameworks, tree.new(name)) node.path = link end end end if #tr.frameworks.children > 0 then tree.insert(tr, tr.frameworks) end tr.products = tree.insert(tr, tree.new("Products")) tr.projects = tree.new("Projects") for _, dep in ipairs(premake.getdependencies(prj, "sibling", "object")) do local xcpath = xcode.getxcodeprojname(dep) local xcnode = tree.insert(tr.projects, tree.new(path.getname(xcpath))) xcnode.path = xcpath xcnode.project = dep xcnode.productgroupid = xcode.newid(xcnode, "prodgrp") xcnode.productproxyid = xcode.newid(xcnode, "prodprox") xcnode.targetproxyid = xcode.newid(xcnode, "targprox") xcnode.targetdependid = xcode.newid(xcnode, "targdep") local cfg = premake.getconfig(dep, prj.configurations[1]) node = tree.insert(xcnode, tree.new(cfg.linktarget.name)) node.path = cfg.linktarget.fullpath node.cfg = cfg end if #tr.projects.children > 0 then tree.insert(tr, tr.projects) end tree.traverse(tr, { onnode = function(node) node.id = xcode.newid(node) if xcode.getbuildcategory(node) then node.buildid = xcode.newid(node, "build") end if string.endswith(node.name, "Info.plist") then tr.infoplist = node end end }, true) node = tree.insert(tr.products, prj.xcode.projectnode) node.kind = "product" node.path = node.cfg.buildtarget.fullpath node.cfgsection = xcode.newid(node, "cfg") node.resstageid = xcode.newid(node, "rez") node.sourcesid = xcode.newid(node, "src") node.fxstageid = xcode.newid(node, "fxs") return tr end function premake.xcode.project(prj) local tr = xcode.buildprjtree(prj) xcode.Header(tr) xcode.PBXBuildFile(tr) xcode.PBXContainerItemProxy(tr) xcode.PBXFileReference(tr) xcode.PBXFrameworksBuildPhase(tr) xcode.PBXGroup(tr) xcode.PBXNativeTarget(tr) xcode.PBXProject(tr) xcode.PBXReferenceProxy(tr) xcode.PBXResourcesBuildPhase(tr) xcode.PBXShellScriptBuildPhase(tr) xcode.PBXSourcesBuildPhase(tr) xcode.PBXVariantGroup(tr) xcode.PBXTargetDependency(tr) xcode.XCBuildConfiguration(tr) xcode.XCBuildConfigurationList(tr) xcode.Footer(tr) end premake.xcode4 = {} local xcode4 = premake.xcode4 function xcode4.workspace_head() _p('') _p('') end function xcode4.workspace_tail() _p('') end function xcode4.workspace_file_ref(prj) local projpath = path.getrelative(prj.solution.location, prj.location) if projpath == '.' then projpath = '' else projpath = projpath ..'/' end _p(1,'',projpath .. prj.name .. '.xcodeproj') _p(1,'') end function xcode4.workspace_generate(sln) premake.xcode.preparesolution(sln) xcode4.workspace_head() for prj in premake.solution.eachproject(sln) do xcode4.workspace_file_ref(prj) end xcode4.workspace_tail() end premake.clean = { } function premake.clean.directory(obj, pattern) local fname = premake.project.getfilename(obj, pattern) os.rmdir(fname) end function premake.clean.file(obj, pattern) local fname = premake.project.getfilename(obj, pattern) os.remove(fname) end newaction { trigger = "clean", description = "Remove all binaries and generated files", onsolution = function(sln) for action in premake.action.each() do if action.oncleansolution then action.oncleansolution(sln) end end end, onproject = function(prj) for action in premake.action.each() do if action.oncleanproject then action.oncleanproject(prj) end end if (prj.objectsdir) then premake.clean.directory(prj, prj.objectsdir) end local platforms = prj.solution.platforms or { } if not table.contains(platforms, "Native") then platforms = table.join(platforms, { "Native" }) end for _, platform in ipairs(platforms) do for cfg in premake.eachconfig(prj, platform) do premake.clean.directory(prj, cfg.objectsdir) premake.clean.file(prj, premake.gettarget(cfg, "build", "posix", "windows", "windows").fullpath) premake.clean.file(prj, premake.gettarget(cfg, "build", "posix", "posix", "linux").fullpath) premake.clean.file(prj, premake.gettarget(cfg, "build", "posix", "posix", "macosx").fullpath) premake.clean.file(prj, premake.gettarget(cfg, "build", "posix", "PS3", "windows").fullpath) if cfg.kind == "WindowedApp" then premake.clean.directory(prj, premake.gettarget(cfg, "build", "posix", "posix", "linux").fullpath .. ".app") end premake.clean.file(prj, premake.gettarget(cfg, "link", "windows", "windows", "windows").fullpath) premake.clean.file(prj, premake.gettarget(cfg, "link", "posix", "posix", "linux").fullpath) local target = path.join(premake.project.getfilename(prj, cfg.buildtarget.directory), cfg.buildtarget.basename) for action in premake.action.each() do if action.oncleantarget then action.oncleantarget(target) end end end end end } local scriptfile = "premake4.lua" local shorthelp = "Type 'premake4 --help' for help" local versionhelp = "premake4 (Premake Build Script Generator) %s" local function injectplatform(platform) if not platform then return true end platform = premake.checkvalue(platform, premake.fields.platforms.allowed) for sln in premake.solution.each() do local platforms = sln.platforms or { } if #platforms == 0 then table.insert(platforms, "Native") end 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 if not table.contains(platforms, platform) then table.insert(platforms, platform) end sln.platforms = platforms end return true end function _premake_main(scriptpath) if (scriptpath) then local scripts = dofile(scriptpath .. "/_manifest.lua") for _,v in ipairs(scripts) do dofile(scriptpath .. "/" .. v) end end premake.action.set(_ACTION) math.randomseed(os.time()) local fname = _OPTIONS["file"] or scriptfile if (os.isfile(fname)) then dofile(fname) end if (_OPTIONS["version"]) then printf(versionhelp, _PREMAKE_VERSION) return 1 end if (_OPTIONS["help"]) then premake.showhelp() return 1 end if (not _ACTION) then print(shorthelp) return 1 end if (not os.isfile(fname)) then error("No Premake script ("..scriptfile..") found!", 2) end action = premake.action.current() if (not action) then error("Error: no such action '" .. _ACTION .. "'", 0) end ok, err = premake.option.validate(_OPTIONS) if (not ok) then error("Error: " .. err, 0) end ok, err = premake.checktools() if (not ok) then error("Error: " .. err, 0) end ok, err = injectplatform(_OPTIONS["platform"]) if (not ok) then error("Error: " .. err, 0) end print("Building configurations...") premake.bake.buildconfigs() ok, err = premake.checkprojects() if (not ok) then error("Error: " .. err, 0) end printf("Running action '%s'...", action.trigger) premake.action.call(action.trigger) print("Done.") return 0 end $Lua: Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio $ $Authors: R. Ierusalimschy, L. H. de Figueiredo & W. Celes $ $URL: www.lua.org $ no calling environmentno valueY%@%@%@%@%@%@%@?F.@O.@W.@`.@h.@s.@.@.@Sl%s:%d: bad argument #%d (%s)nmethodcalling '%s' on bad self (%s)?bad argument #%d to '%s' (%s)%s expected, got %sstack overflow (%s)value expectedinvalid option '%s'_LOADEDname conflict for module '%s' cannot %s %s: %s=stdin@%sropenrbreopenreadPANIC: unprotected error in call to Lua API (%s) createresumerunningstatuswrapyield 3D/N@'3DPM@.3DN@63DXL@=3DN@B3DN@suspendednormaldead.3D3D3D3Dassertcollectgarbagedofileerrorgcinfogetfenvgetmetatableloadfileloadloadstringnextpcallprintrawequalrawgetrawsetselectsetfenvsetmetatabletonumbertostringtypeunpackxpcall3DgH@3DD@3DH@3DA@3DD@3DRC@3DA@3DG@4DG@ 4DF@4DE@4DI@#4D?@)4D)D@24D^D@94DD@@4DOI@G4DC@O4D&B@\4D@@e4DlJ@n4DE@s4DH@z4DJ@'tostring' must return a string to 'print'base out of range__metatablenil or table expectedcannot change a protected metatablelevel must be non-negativeinvalid levelfno function environment for tail call at level %d'setfenv' cannot change environment of given objectstoprestartcollectcountstepsetpausesetstepmul|6D6D6D6D6D6D6D:too many nested functionsreader function must return a string=(load)assertion failed!%stoo many results to unpackindex out of range__tostringtruefalsenil%s: %pboolean or proxy expectedcoroutine expectedtoo many arguments to resumecannot resume %s coroutinetoo many results to resumeLua function expected_GLua 5.1_VERSIONipairspairskv__modenewproxycoroutinecontrol structure too longfunction or expression too complexconstant table overflowcode size overflowW@ W@W@2W@uW@uW@uW@dW@dW@GX@UX@UX@eX@jX@X@X@X@X@X@X@X@Y@Y@Y@Y@Y@Y@Y@Y@Y@q\@\@u\@y\@\@\@\@\@\@]@^@]@^@^@A^@A^@A^@A^@ ^@^@^@_@_@_@_@`@`@f_@<`@-`@P`@_`@n`@`@'_@6_@Ma@Ma@Ma@Ma@Ma@Ma@:DXj@F:Dd@N:Df@W:Dc@c:Dc@p:DBh@{:Dc@:DTi@:D:g@:DFc@:DPh@:Dk@hnil or table expected'setfenv' cannot change environment of given objectflnSu>%sfunction or level expectedinvalid optionsourceshort_srclinedefinedlastlinedefinedwhatcurrentlinenupsnamenamewhatactivelinesfunclevel out of rangecallreturnlinecounttail return< cont =(debug command) stack traceback: ... Snl%s:%d: in function '%s' in main chunk ? in function <%s:%d>(*temporary) s@Os@ss@~s@tu@~s@ss@tu@tu@s@tu@tu@tu@tu@tu@tu@tu@tu@tu@s@t@tu@tu@tu@tu@tu@7t@7t@t@s@s@s@t@tu@t@6u@?localglobalfieldupvaluemethodv@v@v@v@v@dv@v@v@v@v@v@v@tail=(tail call)=[C]CmainLua%s:%d: %sattempt to compare two %s valuesattempt to compare %s with %sattempt to %s %s '%s' (a %s value)attempt to %s a %s valueperform arithmetic onconcatenatenot enough memoryerror in error handlingstack overflowcallnC stack overflowcannot resume non-suspended coroutineattempt to yield across metamethod/C-call boundary @@@@@@ŏ@@@@ @@@@O@\@@F@@packagetableioosstringmathdebug?DO@?D@?D)A?D@?Ds@?DpA?DT@?Dm@closeflushinputlinesopenoutputpopenreadtmpfiletypewritep@D@v@D@|@D>@@D@@Da@@DV@@DǠ@@DK@@D-@@D@@D@|@D@Dseeksetvbuf__gc__tostringp@D@v@D:@@D@@Dp@8AD0@=AD@@D@EAD@JAD@%s: %s%sFILE*closed filefileattempt to use a closed filecannot close standard file__closefile (closed)file (%p)rstandard %s file is closedwtoo many argumentsinvalid option%lfinvalid formatfile is already closed%.14gsetcurendBDBDBD@nofulllineBDBDBD__indexiostdinstdoutstderrandbreakdoelseelseifendfalseforfunctionifinlocalnilnotorrepeatreturnthentrueuntilwhile.....==>=<=~=0CD4CD:CD=CDBCDICDMCDSCDWCD`CDcCDfCDlCDpCDtCDwCD~CDCDCDCDCDCDCDCDCDCDCDCDCDCDCDchar(%d)%c%s:%d: %s%s near '%s'lexical element too longchunk has too many linesEe+-malformed numberunfinished long stringunfinished long commentnesting of [[...]] is deprecatedinvalid long string delimiterunfinished stringescape sequence too large.absacosasinatan2atanceilcoshcosdegexpfloorfmodfrexpldexplog10logmaxminmodfpowradrandomrandomseedsinhsinsqrttanhtanpED@tEDZ@yED0@~ED@ED@ED@ED@ED@ED@ED@ED@ED9@ED@ED7@EDZ@ED0@ED;@EDm@EDp@ED@EDֽ@ED1@ED;@ED^@ED4@ED@ED@EDܺ@9RFߑ?9RFߑ?interval is emptywrong number of argumentsF?mathpihugemodmemory allocation error: block too bigmodulerequireGD@GD@@@@@loadlibseeallGDD@GD@system error %d _LOADLIBLOADLIB: %s%sopeninit\.'package.%s' must be a string?r no file '%s'error loading module '%s' from file '%s': %spath_luaopen_%scpath no module '%s' in file '%s'preload'package.preload' must be a table no field package.preload['%s']_LOADEDloop or previous error loading module '%s'loaders'package.loaders' must be a tablemodule '%s' not found:%sname conflict for module '%s'_NAME_M_PACKAGEf'module' not called from a Lua function__index;;;;unable to get ModuleFileName!__gcpackage.\?.lua;!\lua\?.lua;!\lua\?\init.lua;!\?.lua;!\?\init.luaLUA_PATH.\?.dll;!\?.dll;!\loadall.dllLUA_CPATH\ ; ? ! -configloaded%(null)%p... "]`qT`Pql1 or '...' expectedconstant table overflowcannot use '...' outside a vararg functionitems in a constructorambiguous syntax (function call x new statement)function arguments expectedunexpected symbolsyntax errorvariables in assignmentnot enough memorybytechardumpfindformatgfindgmatchgsublenlowermatchrepreversesubupper0RDA5RDA:RD}A?RD ADRDAKRDF AQRD AXRDX A]RD@@aRD@gRD AmRD@qRD@yRD}@}RD@string slice too longinvalid valueunable to dump given functionmalformed pattern (ends with '%%')malformed pattern (missing ']')oAAAAAAAAAAAAAAAAAA(AAFAAdAAAAinvalid pattern captureunbalanced patternmissing '[' after '%%f' in patterninvalid capture indextoo many capturesunfinished capture^$*+?.([%-'string.gfind' was renamed to 'string.gmatch'string/function/table expectedinvalid replacement value (a %s)-+ #0invalid format (repeated flags)invalid format (width or precision too long)\r\000invalid option '%%%c' to 'format'string__indexYinvalid key to 'next'table overflowYtable index is niltable index is NaNconcatforeachforeachigetnmaxninsertremovesetnsortVD%AVD"AVDp"A(VD#A-VDq#A2VDL$A9VD$A@VD$AEVDQ)A'setn' is obsoletewrong number of arguments to 'insert'invalid value (%s) at index %d in table for 'concat'invalid order function for sortingtablenilbooleanuserdatanumberstringtablefunctionthreadprotoupvalPWDTWD\WDeWDlWDsWDyWD\WDWDWDWD__index__newindex__gc__mode__eq__add__sub__mul__div__mod__pow__unm__len__lt__le__concat__callWDWDWDWDWDXDXD XDXDXDXD$XD*XD0XD5XD:XDCXD%s: %s in precompiled chunkunexpected endbad integercode too deepbad constantbad codebinary stringbad header=?%.14gindexloop in gettableloop in settable6A6A6A6A6A6A6A6Astring length overflow,9AY9A09A49A89A]9A|9Aget length of'for' initial value must be a number'for' limit must be a number'for' step must be a number:A;A;A=;A[;A};A;AA|>A>AW?A?A]@A@A@AYAAAAAAOBABACACA9DADAEAEA=FAFAGANHA^HAIA-LIBGCCW32-EH-2-SJLJ-GTHR-MINGW32w32_sharedptr->size == sizeof(W32_EH_SHARED)%s:%u: failed assertion `%s' ../../gcc/gcc/config/i386/w32-shared-ptr.cGetAtomNameA (atom, s, sizeof(s)) != 0hpz|rpzrp|rpr|tttttttttuu(u8uPudutuuuuuuuuv0v8vHvXvhvxvvvvvvvvvvvw www$w,w4w@wHwTw\wdwlwxwwwwwwwwwwwwwwwx xxx(x4x@xHxXxdxlxtxxxxxxxxxxxxxy yy$y0y8y@yLyTy\yhytyyyyyyyyyyyyzzz$z,z4z@zLzXzdzpzttttttttuu(u8uPudutuuuuuuuuv0v8vHvXvhvxvvvvvvvvvvvw www$w,w4w@wHwTw\wdwlwxwwwwwwwwwwwwwwwx xxx(x4x@xHxXxdxlxtxxxxxxxxxxxxxy yy$y0y8y@yLyTy\yhytyyyyyyyyyyyyzzz$z,z4z@zLzXzdzpzAddAtomA5CopyFileA<CreateDirectoryAExitProcessFindAtomAFindCloseFindFirstFileAFindNextFileAFormatMessageAFreeLibraryGetAtomNameAGetCurrentDirectoryAGetCurrentProcessCGetLastErrorMGetModuleFileNameAOGetModuleHandleAjGetProcAddressGetSystemInfoGetVersionExA LoadLibraryAtRemoveDirectoryASetCurrentDirectoryASetUnhandledExceptionFilterO_stat'__getmainargs0__mb_cur_max<__p__environ>__p__fmodeP__set_app_typey_cexit_errno_filbuf_iob_isctype^_onexitf_pcloseg_pctypej_popen_setjmp_setmodeabortacosasinatanatan2atexit"ceil#clearerr$clock%cos&cosh(difftime*exit+exp-fclose0fflush3fgets6floor7fmod8fopen9fprintf:fputc;fputs>fread?free@freopenAfrexpBfscanfCfseekEftellGfwriteKgetenvOgmtimekldexpmlocaleconvnlocaltimeologplog10qlongjmprmallocvmemchrwmemcmpxmemcpyzmemset{mktime|modf~powputsrandreallocremoverenamesetlocalesetvbufsignalsinsinhsprintfsqrtsrandstrcatstrchrstrcmpstrcollstrcpystrcspnstrerrorstrftimestrncatstrncpystrpbrkstrrchrstrstrstrtodstrtoulsystemtantanhtimetmpfiletmpnamtolowertoupperungetcEGetSystemMetricspppppppppppppppppppppppKERNEL32.dllpmsvcrt.dll(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(pmsvcrt.dll