Build/Core/Target/Target.lua

169 lines
4.9 KiB
Lua
Raw Normal View History

_auCurrentPlatforms = {}
_auCurrentArchs = {}
_auCurrentFlags = {}
_auExtendedConfig = false
_auExtendedArch = false
auRequire("Core/Target/arch")
auRequire("Core/Target/flags")
auRequire("Core/Target/platform")
local function addTarget(prefix, available, flags)
auForEachKV(available, function(key, value)
local option = prefix .. "-" .. key
newoption
{
trigger = option,
description = ""
}
if (_OPTIONS[option]) then
table.insert(flags, key)
end
end)
end
local function start()
addTarget("target", Aurora.Platforms, _auCurrentPlatforms)
addTarget("target", Aurora.Architectures, _auCurrentArchs)
addTarget("flag", Aurora.Flags, _auCurrentFlags)
_auExtendedConfig = #_auCurrentPlatforms > 1
_auExtendedArch = #_auCurrentArchs > 1
end
local function startProject()
auFilterForConfigPlatforms(function(config, platform, architecture)
_G.architecture(Aurora.Architectures[architecture].architecture)
defines(Aurora.Platforms[platform].defines)
end)
end
local function startSolution()
local configs = {}
if (not _auExtendedConfig and not _auExtendedArch) then
auForEach(Aurora.Settings.aNamesOfConfigs, function(config)
table.insert(configs, config)
end)
else
auForEach(_auCurrentPlatforms, function(platform)
auForEach(_auCurrentArchs, function(arch)
auForEach(Aurora.Settings.aNamesOfConfigs, function(config)
table.insert(configs, platform .. arch .. config)
end)
end)
end)
end
configurations(configs)
end
local function auFilterForArchs(callback, ...)
auForEach(_auCurrentArchs, function(arch, ...)
filter(auConcatVararg({"architecture:" .. arch}, ...))
callback(arch)
filter {}
end, ...)
end
local function auFilterForPlatforms(callback, ...)
auFilterForConfigPlatforms(function(config, platform)
callback(platform)
end, extendedFilter)
end
local function auFilterForConfigs(callback, ...)
auFilterForConfigPlatforms(function(config, platform)
callback(config)
end, extendedFilter)
end
local function auFilterForConfigPlatforms(callback, ...)
auForEach(_auCurrentPlatforms, function(platform, ...)
auForEach(_auCurrentArchs, function(arch, ...)
auForEach(Aurora.Settings.aNamesOfConfigs, function(config, ...)
if (not _auExtendedConfig and not _auExtendedArch) then
filter(auConcatVararg({"configurations:" .. config}, ...))
else
filter(auConcatVararg({"configurations:" .. platform .. arch .. config}, ...))
end
callback(config, platform, arch)
filter {}
end, ...)
end, ...)
end, ...)
end
local function auFilterOf(configFilter, ...)
local ret = {}
local test = function(val, orArray, notArray)
if (orArray) then
if (type(orArray) == "string") then
if (orArray ~= val) then
return
end
elseif (#orArray > 0) then
if (not auContains(orArray, val)) then
return
end
end
end
if (notArray) then
if (type(notArray) == "string") then
if (notArray == val) then
return
end
elseif (#notArray > 0) then
if (auContains(notArray, val)) then
return
end
end
end
return true
end
auForEach(_auCurrentPlatforms, function(platform)
auForEach(_auCurrentArchs, function(arch)
auForEach(Aurora.Settings.aNamesOfConfigs, function(config)
if (not test(config, configFilter.configs, configFilter.notConfigs)) then
return
end
if (not test(arch, configFilter.archs, configFilter.notArchs)) then
return
end
if (not test(platform, configFilter.platforms, configFilter.notPlatform)) then
return
end
if (not _auExtendedConfig and not _auExtendedArch) then
table.insert(ret, "configurations:" .. config)
else
table.insert(ret, "configurations:" .. platform .. arch .. config)
end
end)
end)
end)
return auConcatVararg({table.concat(ret, " or ")}, ...)
end
return {
start = start,
startSolution = startSolution,
startProject = startProject,
auFilterForPlatforms = auFilterForPlatforms,
auFilterForConfigs = auFilterForConfigs,
auFilterForConfigPlatforms = auFilterForConfigPlatforms,
auFilterOf = auFilterOf,
auFilterForArchs = auFilterForArchs
}