243 lines
7.0 KiB
Lua
243 lines
7.0 KiB
Lua
_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)
|
|
|
|
auForEach(_auCurrentPlatforms, function(platformName)
|
|
local name = nil
|
|
local alt = Aurora.Platforms[platformName].stylizedName
|
|
|
|
if (alt) then
|
|
name = alt
|
|
else
|
|
name = platformName:gsub("^%l", string.upper)
|
|
end
|
|
|
|
Aurora.Platforms[platformName].outputName = name
|
|
end)
|
|
|
|
_auExtendedArch = #_auCurrentArchs > 1
|
|
end
|
|
|
|
local function startProject()
|
|
auFilterForConfigPlatforms(function(config, platform)
|
|
if (not _auExtendedArch) then
|
|
local architecture = _auCurrentArchs[1]
|
|
auFilter {}
|
|
auFilter ("configurations:" .. config)
|
|
_G.architecture(Aurora.Architectures[architecture].architecture)
|
|
defines(Aurora.Platforms[platform].defines)
|
|
else
|
|
auFilter {}
|
|
auForEach(_auCurrentArchs, function(architecture)
|
|
auFilter ("configurations:" .. config .. architecture)
|
|
_G.architecture(Aurora.Architectures[architecture].architecture)
|
|
defines(Aurora.Platforms[platform].defines)
|
|
auFilter {}
|
|
end)
|
|
auFilter ("platform:none")
|
|
end
|
|
end)
|
|
end
|
|
|
|
local function startSolution()
|
|
local configs = {}
|
|
|
|
if (not _auExtendedArch) then
|
|
auForEach(Aurora.Settings.aNamesOfConfigs, function(config)
|
|
table.insert(configs, config)
|
|
end)
|
|
else
|
|
auForEach(_auCurrentArchs, function(arch)
|
|
auForEach(Aurora.Settings.aNamesOfConfigs, function(config)
|
|
table.insert(configs, config .. arch)
|
|
end)
|
|
end)
|
|
end
|
|
|
|
configurations(configs)
|
|
platforms(_auCurrentPlatforms)
|
|
end
|
|
|
|
local function auFilterForArchs(callback, ...)
|
|
auForEach(_auCurrentArchs, function(arch, ...)
|
|
auFilter(auConcatVararg({"architecture:" .. arch}, ...))
|
|
callback(arch)
|
|
auFilter {}
|
|
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, ...)
|
|
|
|
auFilter(auFilterOf({platforms = platform, configs = config}))
|
|
|
|
callback(config, platform, arch)
|
|
auFilter {}
|
|
end, ...)
|
|
end, ...)
|
|
end, ...)
|
|
end
|
|
|
|
local function auFilterOf(configFilter, ...)
|
|
local ret = {}
|
|
local andOptions = {}
|
|
|
|
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
|
|
|
|
-- TODO: clean up
|
|
local validPlatforms = {}
|
|
local validArchs = {}
|
|
local validConfigs = {}
|
|
|
|
auForEach(Aurora.Settings.aNamesOfConfigs, function(config)
|
|
if (not test(config, configFilter.configs, configFilter.notConfigs)) then
|
|
return
|
|
end
|
|
|
|
if (not _auExtendedArch) then
|
|
table.insert(validConfigs, config)
|
|
else
|
|
auForEach(_auCurrentArchs, function(arch)
|
|
table.insert(validConfigs, config .. arch)
|
|
end)
|
|
end
|
|
end)
|
|
|
|
auForEach(_auCurrentArchs, function(arch)
|
|
if (not test(arch, configFilter.archs, configFilter.notArchs)) then
|
|
return
|
|
end
|
|
|
|
table.insert(validArchs, arch)
|
|
end)
|
|
|
|
auForEach(_auCurrentPlatforms, function(platform)
|
|
if (not test(platform, configFilter.platforms, configFilter.notPlatforms)) then
|
|
return
|
|
end
|
|
|
|
table.insert(validPlatforms, platform)
|
|
end)
|
|
|
|
auForEach(configFilter.options, function(option)
|
|
table.insert(andOptions, "options:" .. option)
|
|
end)
|
|
|
|
auForEach(configFilter.notOptions, function(option)
|
|
table.insert(andOptions, "not options:" .. option)
|
|
end)
|
|
|
|
local supportedArchs = {}
|
|
auForEach(validArchs, function(arch)
|
|
table.insert(supportedArchs, "architecture:" .. auFetchGlobal("Architectures")[arch].architecture)
|
|
end)
|
|
if (#supportedArchs == 0) then
|
|
table.insert(supportedArchs, "platforms:none")
|
|
end
|
|
ret = {table.concat(supportedArchs, " or ")}
|
|
|
|
local supportedPlatforms = {}
|
|
auForEach(validPlatforms, function(platform)
|
|
table.insert(supportedPlatforms, "platforms:" .. platform)
|
|
end)
|
|
if (#supportedPlatforms == 0) then
|
|
table.insert(supportedPlatforms, "platforms:none")
|
|
end
|
|
ret = auMergeArray(ret, {table.concat(supportedPlatforms, " or ")})
|
|
|
|
|
|
local supportedConfigs = {}
|
|
auForEach(validConfigs, function(config)
|
|
table.insert(supportedConfigs, "configurations:" .. config)
|
|
end)
|
|
if (#supportedConfigs == 0) then
|
|
table.insert(supportedConfigs, "platforms:none")
|
|
end
|
|
ret = auMergeArray(ret, {table.concat(supportedConfigs, " or ")})
|
|
|
|
--local ret = {table.concat(ret, " or ")}
|
|
if (#andOptions) then
|
|
ret = auMergeArray(ret, andOptions)
|
|
end
|
|
|
|
--print(json.encode(configFilter), json.encode(ret))
|
|
return auConcatArrays(ret, ...)
|
|
end
|
|
|
|
return {
|
|
start = start,
|
|
startSolution = startSolution,
|
|
startProject = startProject,
|
|
auFilterForPlatforms = auFilterForPlatforms,
|
|
auFilterForConfigs = auFilterForConfigs,
|
|
auFilterForConfigPlatforms = auFilterForConfigPlatforms,
|
|
auFilterOf = auFilterOf,
|
|
auFilterForArchs = auFilterForArchs
|
|
} |