[*] Move ./Legacy to ./Core/Legacy

This commit is contained in:
Reece Wilson 2021-11-16 11:30:51 +00:00
parent 613bff8771
commit 6f77dd5fe0
3 changed files with 1 additions and 482 deletions

View File

@ -14,485 +14,4 @@ function startSolution(name)
end
require("Legacy.aurora")
local tbl =
{
"target-win32",
"target-linux",
"target-switch",
"target-ps5",
"target-x86_64",
"target-arm",
"target-wayland"
}
for i, k in pairs(tbl) do
local key = string.sub(k, 8)
_G[key] = false
if (_OPTIONS[k]) then
_G[key] = true
end
end
-------------------------------------------------------
-- globals
-------------------------------------------------------
_G["projectsprocessor"] = {}
_G["projectsblocked"] = {}
_G["projectsemitted"] = {}
_G["namespacesemitted"] = {}
_G["usingClang"] = false
_G["usingMSVC"] = false
-------------------------------------------------------
-- process command line arguments into global space
-------------------------------------------------------
-------------------------------------------------------
-- API
-------------------------------------------------------
local jsonProcessor = require("jsonProcessor")
local normalizeSourceRoot = function(path)
local backup = path
path = os.realpath(_G.path.join(os.getcwd(), path));
if (not path) then
print("path error, not found?", backup)
return
end
return path
end
local extendInfo = function(this)
local type = this.projectType:lower()
this.isShared = type == "sharedlib"
this.isStatic = type == "staticlib"
this.isExec = type == "consoleapp" or type == 'windowedapp'
this.isConsole = type == "consoleapp"
this.isWindowed = type == "windowedapp"
end
function addVisit(ina)
local args = {
namespace = ina.namespace,
name = ina.name, -- OPT: recommended
path = ina.path,
type = ina.type,
out = ina.out,
translations = ina.translations -- OPT: dictionary of dependency maps
}
local path = normalizeSourceRoot(args.path)
if (not path) then
return
end
local info = {
namespace = args.namespace,
path = path,
projectType = args.type,
out = args.out,
name = args.name,
translations = args.translations
}
extendInfo(info)
local project = {
info = info,
processor = nil,
deps = {}
}
local cwd = auGetRoot()
local remoteLua = path .. "/Aurora.lua"
local remoteJson = path .. "/Aurora.json"
local localJson = cwd .. "/Build_UserScripts/" .. args.name .. ".aurora.json"
local localLua = cwd .. "/Build_UserScripts/" .. args.name .. ".aurora.lua"
if (os.isfile(localLua)) then
project.processor = auRequireAbs(localLua)(info)
elseif (os.isfile(localJson)) then
info.jpath = localJson
project.processor = jsonProcessor(info)
elseif (os.isfile(remoteLua)) then
project.processor = auRequireAbs(remoteLua)(info)
elseif (os.isfile(remoteJson)) then
info.jpath = remoteJson
project.processor = jsonProcessor(info)
else
print("Couldnt find Aurora build script for: ", path)
return
end
projectsprocessor[info.name] = project
end
function addScript(ina)
local args = {
namespace = ina.namespace,
script = ina.script,
path = ina.path,
type = ina.type,
out = ina.out
}
local path = normalizeSourceRoot(args.path)
if (not path) then
return
end
local info = {
namespace = args.namespace,
path = path,
projectType = args.type,
out = args.out
}
extendInfo(info)
local project = {
info = info,
processor = nil,
deps = {}
}
local procesor = userRequire(args.script)
if (not procesor) then
processor = auRequireAbs(args.script)
if (not procesor) then
print("missing project script:", args.script, path)
return
end
end
project.processor = procesor(info)
if (not project.processor) then
print("script error")
return
end
projectsprocessor[info.name] = project
end
-- private
local processLocalProject = function(proj)
processProject(proj.info.name)
end
-- private
local processInit = function(project)
if (not project.isInitialized) then
if (project.processor.init) then
project.processor:init()
end
project.isInitialized = true
end
end
-- private
_G["_resolved_dep_res"] = {}
_G["_resolved_dep"] = {}
function processDepSearch(proj, resolveProject)
local name = proj.info.name
_G["_resolved_dep"][name] = name
if (not proj.resolvedDeps) then
if (proj.processor.resolveDependencies) then
proj.processor:resolveDependencies(function(name, soft)
table.insert(proj.deps, name)
if (_G["_resolved_dep"][name]) then
return
end
local depProj = projectsprocessor[name]
if (not depProj) then
if (not soft) then
auFatal("missing dependency: ", name)
else
return false
end
end
processDepSearch(depProj, true)
end)
end
proj.resolvedDeps = true
end
processInit(proj)
end
-- private
local processNS = function(namespace)
local projs = {}
local projsIdxs = {}
auForEach(projectsprocessor, function(proj)
if (proj.info.namespace ~= namespace) then
return
end
local name = proj.info.name
projs[name] = proj
table.insert(projsIdxs, name)
end)
table.sort(projsIdxs, function(a, b)
return a:upper() < b:upper()
end)
auForEach(projsIdxs, function(idx)
processDepSearch(projs[idx], true)
end)
auForEach(projsIdxs, function(idx)
processLocalProject(projs[idx])
end)
end
function processSolution()
local hack = {}
local hackIdx = {}
auForEach(projectsprocessor, function(proj)
table.insert(hackIdx, proj.info.namespace)
end)
table.sort(hackIdx, function(a, b)
return a:upper() < b:upper()
end)
auForEach(hackIdx, processNS)
end
function attemptNS(ns)
local attemptLoad = false
if (not namespacesemitted[ns]) then
auStartGroup(ns) -- only print the group once
attemptLoad = true
end
group(ns)
return attemptLoad
end
resolved = {}
function processProject(name, required, noNs)
local a = projectsprocessor[name]
if (not a) then
if (required) then
auFatal("missing project: ", name)
else
return false
end
end
-- ensure the project is initializd
processInit(a)
-- legacy recursion
if (projectsblocked[name]) then
return true
end
projectsblocked[name] = name
-- process all within the namespace before processing the actual project
local ns = a.info.namespace
local loadOthers = attemptNS(ns)
-- {
local cwd = os.getcwd()
local old = _G["current_project"]
_G["current_project"] = name
os.chdir(a.info.path)
a.processor:process()
os.chdir(cwd)
_G["current_project"] = old
-- }
projectsemitted[name] = name
-- cont
if (loadOthers) then
namespacesemitted[ns] = "";
processNS(ns)
end
return true
end
function isWeakCircularReference(depName)
local curName = getCurrentProjectName()
local cur = projectsprocessor[curName]
if (not cur) then
return
end
local dep = projectsprocessor[depName]
if (not dep) then
return
end
-- TODO: recursion
for index, value in ipairs(dep.deps) do
if value == curName then
return true
end
end
return false
end
function isProjectLoaded(name)
local a = projectsprocessor[name]
if (not a) then
return false
end
return a.isInitialized
end
function getProjectInfo(name)
if (not name) then
return
end
local scre = projectsprocessor[name]
if (not scre) then
return
end
return scre.info
end
function getProjectProcessor(name)
if (not name) then
return
end
local scre = projectsprocessor[name]
if (not scre) then
return
end
return scre.processor
end
function getCurrentProjectName()
return current_project
end
function importAndLinkProject(dep, soft)
local proj = _G["projectsprocessor"][dep]
if (not proj) then
if (soft) then
return false
end
auFatal("Missing project", dep)
end
local iface = proj.processor
if (not isProjectLoaded(dep)) then
if (soft) then
return false
end
auFatal("missing project: ", dep)
end
iface:handleReference()
iface:handleLink()
return true
end
function includeAuProject(dep, soft)
local proj = _G["projectsprocessor"][dep]
if (not proj) then
if (soft) then
return false
end
auFatal("Missing project", dep)
end
local iface = proj.processor
if (not isProjectLoaded(dep)) then
if (soft) then
return false
end
auFatal("missing project: ", dep)
end
iface:handleReference()
return true
end
function linkAuProject(dep, soft)
local proj = _G["projectsprocessor"][dep]
if (not proj) then
if (soft) then
return false
end
auFatal("Missing project", dep)
end
local iface = proj.processor
if (not isProjectLoaded(dep)) then
if (soft) then
return false
end
auFatal("missing project: ", dep)
end
iface:handleLink()
return true
end
-- executes inline under iprocessor::process
function addFeature(feature)
local script = auGetRoot() .. "/Build_Scripts/Features/" .. feature:lower() .. ".lua"
if (not os.isfile(script)) then
auFatal("missing feature", feature, script)
return
end
auRequireAbs(script)()
end
require("Core.Legacy.aurora")