[-] Nuke legacy aurora.lua, minor clean up

This commit is contained in:
Reece Wilson 2022-01-17 22:12:51 +00:00
parent baa55a507f
commit e847e1024f
7 changed files with 142 additions and 189 deletions

View File

@ -93,11 +93,11 @@ local addBuildCommand = function(when, scriptType, path, cwdRelToProject, args)
command = "call " command = "call "
end end
local cur = getProjectInfo(getCurrentProjectName()) local cur = auGetCurrentProjectMeta()
command = command .. getPremakeExec() command = command .. getPremakeExec()
local oldBootstrapPrefix = Aurora.Settings.sAbsRepoScripts local oldBootstrapPrefix = Aurora.Settings.sAbsRepoScripts
local bootstrapPrefix = _G.path.getrelative(Aurora.Settings.sAbsCompilerWd .. "/" .. getCurrentProjectName(), Aurora.Settings.sAbsRepoScripts) local bootstrapPrefix = _G.path.getrelative(Aurora.Settings.sAbsCompilerWd .. "/" .. auGetCurrentProjectName(), Aurora.Settings.sAbsRepoScripts)
local bootstrap = bootstrapPrefix .. "/Core/Actions/buildActionBootstrap.lua" local bootstrap = bootstrapPrefix .. "/Core/Actions/buildActionBootstrap.lua"

View File

@ -274,7 +274,7 @@ local function handleDepends(processor, dep, soft)
dep = processor:translateDep(dep) dep = processor:translateDep(dep)
local macro = ("_auhas_" .. dep):upper():gsub("%-", "_"); local macro = ("_auhas_" .. dep):upper():gsub("%-", "_");
if (isProjectLoaded(dep)) then if (auIsProjectIntialized(dep)) then
defines(macro .. "=1") defines(macro .. "=1")
auLinkAndRefProject(dep, soft) auLinkAndRefProject(dep, soft)
else else

View File

@ -96,8 +96,8 @@ function JsonProcessor(info)
local handleDependsShort = function(dep, this, soft) local handleDependsShort = function(dep, this, soft)
dep = translateDep(this, dep) dep = translateDep(this, dep)
local proj = _G["projectsprocessor"][dep] local processor = auGetProjectProcessor(this:translateDep(dep))
if (not proj) then if (not processor) then
if (soft) then if (soft) then
print("Not including, ", dep) print("Not including, ", dep)
return return
@ -105,9 +105,8 @@ function JsonProcessor(info)
fatal("Missing project", dep) fatal("Missing project", dep)
end end
local iface = proj.processor if (auIsProjectIntialized(dep) and not _G["_linkingcur"][dep]) then
if (isProjectLoaded(dep) and not _G["_linkingcur"][dep]) then processor:handleLink()
iface:handleLink()
end end
end end
@ -201,24 +200,19 @@ function JsonProcessor(info)
end end
local publicDepends = function(name, this, soft) local publicDepends = function(name, this, soft)
name = translateDep(this, name) auIncludeProject(this:translateDep(name), soft) -- evil recursion
includeAuProject(name, soft) -- evil recursion
end end
local handleReference = function(this, circular) local handleReference = function(this, circular)
local type = this.result.type local type = this.result.type
--print("handleReference ", this.info.name)
if ((type:lower() == "utility") or (type:lower() == "blank")) then if ((type:lower() == "utility") or (type:lower() == "blank")) then
return return
end end
--print("handleReference function ", this.info.name, getCurrentProjectName())
local cur = nil local cur = nil
if (circular) then if (circular) then
cur = getProjectInfo(getCurrentProjectName()) cur = auGetCurrentProjectMeta()
else else
cur = this.info cur = this.info
end end
@ -248,7 +242,7 @@ function JsonProcessor(info)
local handleDependsPreemptive = function(dep, this, soft, resolve) local handleDependsPreemptive = function(dep, this, soft, resolve)
dep = translateDep(this, dep) dep = translateDep(this, dep)
if (not isProjectLoaded(dep)) then if (not auIsProjectIntialized(dep)) then
resolve(dep, soft) resolve(dep, soft)
end end
end end
@ -345,10 +339,8 @@ function JsonProcessor(info)
handleInclude(a, true) handleInclude(a, true)
local handleDepends = function(dep, this, soft) local handleDepends = function(dep, this, soft)
dep = translateDep(this, dep) local processor = auGetProjectProcessor(this:translateDep(dep))
if (not processor) then
local proj = _G["projectsprocessor"][dep]
if (not proj) then
if (soft) then if (soft) then
print("Not including, ", dep) print("Not including, ", dep)
return return
@ -356,17 +348,15 @@ function JsonProcessor(info)
fatal("Missing project", dep) fatal("Missing project", dep)
end end
local iface = proj.processor
local macro = ("_auhas_" .. dep):upper():gsub("%-", "_"); local macro = ("_auhas_" .. dep):upper():gsub("%-", "_");
if (isProjectLoaded(dep)) then if (auIsProjectIntialized(dep)) then
defines(macro .. "=1") defines(macro .. "=1")
iface:handleReference(isWeakCircularReference(dep)) processor:handleReference(isWeakCircularReference(dep))
if (not this.info.isStatic) then if (not this.info.isStatic) then
iface:handleLink() processor:handleLink()
end end
else else
defines(macro .. "=0") defines(macro .. "=0")

View File

@ -20,9 +20,9 @@ local function findVala()
local localCMingw = "C:\\msys64\\mingw64\\bin\\valac.exe" local localCMingw = "C:\\msys64\\mingw64\\bin\\valac.exe"
if (os.isfile(localCMingw)) then return localCMingw end if (os.isfile(localCMingw)) then return localCMingw end
else
return "vallac"
end end
return "vallac"
end end
local function addVala(extended) local function addVala(extended)
@ -55,7 +55,7 @@ local function addVala(extended)
local myBrainHurts = false local myBrainHurts = false
local info = getProjectInfo(getCurrentProjectName()) local info = auGetCurrentProjectMeta()
if ((info.projectType:lower() == "sharedlib") or (extended.girFile)) then if ((info.projectType:lower() == "sharedlib") or (extended.girFile)) then
args = args .. " --library=" .. (extended.name or info.name) args = args .. " --library=" .. (extended.name or info.name)
if (usingClang) then if (usingClang) then

View File

@ -1,23 +1,19 @@
local jsonProcessor = auRequire("Core/Legacy/jsonProcessor")
------------------------------------------------------- -------------------------------------------------------
-- globals -- globals
------------------------------------------------------- -------------------------------------------------------
_G["projectsprocessor"] = {} _auProjects = {}
_G["projectsblocked"] = {} _auProjectsBlocked = {}
_G["projectsemitted"] = {} _auNamespacesEmitted = {}
_G["namespacesemitted"] = {} _auResolvedDep = {}
_G["usingClang"] = false _auCurrentProject = {}
_G["usingMSVC"] = false
------------------------------------------------------- -------------------------------------------------------
-- process command line arguments into global space -- utils
------------------------------------------------------- -------------------------------------------------------
------------------------------------------------------- local function normalizeSourceRoot(path)
-- API
-------------------------------------------------------
local jsonProcessor = require("jsonProcessor")
local normalizeSourceRoot = function(path)
local backup = path local backup = path
path = os.realpath(_G.path.join(os.getcwd(), path)); path = os.realpath(_G.path.join(os.getcwd(), path));
if (not path) then if (not path) then
@ -27,7 +23,7 @@ local normalizeSourceRoot = function(path)
return path return path
end end
local extendInfo = function(this) local function extendInfo(this)
local type = this.projectType:lower() local type = this.projectType:lower()
this.isShared = type == "sharedlib" this.isShared = type == "sharedlib"
this.isStatic = type == "staticlib" this.isStatic = type == "staticlib"
@ -36,7 +32,11 @@ local extendInfo = function(this)
this.isWindowed = type == "windowedapp" this.isWindowed = type == "windowedapp"
end end
function addVisit(ina) -------------------------------------------------------
-- project loading
-------------------------------------------------------
local function addVisit(ina)
local args = { local args = {
namespace = ina.namespace, namespace = ina.namespace,
name = ina.name, -- OPT: recommended name = ina.name, -- OPT: recommended
@ -94,10 +94,11 @@ function addVisit(ina)
auRequire("Core").project.expendBaseProcessor(project) auRequire("Core").project.expendBaseProcessor(project)
projectsprocessor[info.name] = project _auProjects[info.name] = project
end end
function addScript(ina)
local function addScript(ina)
local args = { local args = {
namespace = ina.namespace, namespace = ina.namespace,
script = ina.script, script = ina.script,
@ -145,32 +146,26 @@ function addScript(ina)
return return
end end
projectsprocessor[info.name] = project _auProjects[info.name] = project
end end
-- private -- private
local processLocalProject = function(proj) local function processInit(project)
processProject(proj.info.name) if (project.isInitialized) then
end return
end
project.isInitialized = true
-- private if (project.processor.init) then
local processInit = function(project) project.processor:init()
if (not project.isInitialized) then
if (project.processor.init) then
project.processor:init()
end
project.isInitialized = true
end end
end end
-- private -- private
_G["_resolved_dep_res"] = {} local function initializeDependencyTree(proj, resolveProject)
_G["_resolved_dep"] = {}
function processDepSearch(proj, resolveProject)
local name = proj.info.name local name = proj.info.name
_auResolvedDep[name] = name
_G["_resolved_dep"][name] = name
if (not proj.resolvedDeps) then if (not proj.resolvedDeps) then
if (proj.processor.resolveDependencies) then if (proj.processor.resolveDependencies) then
@ -178,11 +173,11 @@ function processDepSearch(proj, resolveProject)
table.insert(proj.deps, name) table.insert(proj.deps, name)
if (_G["_resolved_dep"][name]) then if (_auResolvedDep[name]) then
return return
end end
local depProj = projectsprocessor[name] local depProj = _auProjects[name]
if (not depProj) then if (not depProj) then
if (not soft) then if (not soft) then
auFatal("missing dependency: ", name) auFatal("missing dependency: ", name)
@ -191,7 +186,7 @@ function processDepSearch(proj, resolveProject)
end end
end end
processDepSearch(depProj, true) initializeDependencyTree(depProj, true)
end) end)
end end
proj.resolvedDeps = true proj.resolvedDeps = true
@ -200,12 +195,13 @@ function processDepSearch(proj, resolveProject)
processInit(proj) processInit(proj)
end end
local processProject = {}
-- private -- private
local processNS = function(namespace) local function processNS(namespace)
local projs = {} local projs = {}
local projsIdxs = {} local projsIdxs = {}
auForEach(projectsprocessor, function(proj) auForEach(_auProjects, function(proj)
if (proj.info.namespace ~= namespace) then if (proj.info.namespace ~= namespace) then
return return
end end
@ -221,19 +217,19 @@ local processNS = function(namespace)
end) end)
auForEach(projsIdxs, function(idx) auForEach(projsIdxs, function(idx)
processDepSearch(projs[idx], true) initializeDependencyTree(projs[idx], true)
end) end)
auForEach(projsIdxs, function(idx) auForEach(projsIdxs, function(idx)
processLocalProject(projs[idx]) processProject(projs[idx].info.name)
end) end)
end end
function processSolution() local function processSolution()
local hack = {} local hack = {}
local hackIdx = {} local hackIdx = {}
auForEach(projectsprocessor, function(proj) auForEach(_auProjects, function(proj)
table.insert(hackIdx, proj.info.namespace) table.insert(hackIdx, proj.info.namespace)
end) end)
@ -244,9 +240,9 @@ function processSolution()
auForEach(hackIdx, processNS) auForEach(hackIdx, processNS)
end end
function attemptNS(ns) local function attemptNS(ns)
local attemptLoad = false local attemptLoad = false
if (not namespacesemitted[ns]) then if (not _auNamespacesEmitted[ns]) then
auStartGroup(ns) -- only print the group once auStartGroup(ns) -- only print the group once
attemptLoad = true attemptLoad = true
@ -256,10 +252,8 @@ function attemptNS(ns)
return attemptLoad return attemptLoad
end end
resolved = {} processProject = function(name, required, noNs)
local a = _auProjects[name]
function processProject(name, required, noNs)
local a = projectsprocessor[name]
if (not a) then if (not a) then
if (required) then if (required) then
auFatal("missing project: ", name) auFatal("missing project: ", name)
@ -271,35 +265,32 @@ function processProject(name, required, noNs)
-- ensure the project is initializd -- ensure the project is initializd
processInit(a) processInit(a)
-- legacy recursion -- recursion protection
if (projectsblocked[name]) then if (_auProjectsBlocked[name]) then
return true return true
end end
_auProjectsBlocked[name] = name
projectsblocked[name] = name -- process all within the namespace before processing the requested project
-- process all within the namespace before processing the actual project
local ns = a.info.namespace local ns = a.info.namespace
local loadOthers = attemptNS(ns) local loadOthers = attemptNS(ns)
-- { -- {
local cwd = os.getcwd() local cwd = os.getcwd()
local old = _G["current_project"] local old = _auCurrentProject
_G["current_project"] = name _auCurrentProject = name
os.chdir(a.info.path) os.chdir(a.info.path)
a.processor:process() a.processor:process()
os.chdir(cwd) os.chdir(cwd)
_G["current_project"] = old _auCurrentProject = old
-- } -- }
projectsemitted[name] = name
-- cont -- cont
if (loadOthers) then if (loadOthers) then
namespacesemitted[ns] = ""; _auNamespacesEmitted[ns] = "";
processNS(ns) processNS(ns)
end end
@ -307,16 +298,15 @@ function processProject(name, required, noNs)
end end
function isWeakCircularReference(depName) function isWeakCircularReference(depName)
local curName = getCurrentProjectName() local dep = _auProjects[depName]
local dep = projectsprocessor[depName]
if (not dep) then if (not dep) then
return return
end end
-- TODO: recursion -- TODO: recursion
for index, value in ipairs(dep.deps) do for index, value in ipairs(dep.deps) do
if value == curName then print(value, _auCurrentProject)
if value == _auCurrentProject then
return true return true
end end
end end
@ -324,8 +314,8 @@ function isWeakCircularReference(depName)
return false return false
end end
function isProjectLoaded(name) local function isProjectLoaded(name)
local a = projectsprocessor[name] local a = _auProjects[name]
if (not a) then if (not a) then
return false return false
end end
@ -333,106 +323,58 @@ function isProjectLoaded(name)
return a.isInitialized return a.isInitialized
end end
function getProjectInfo(name) local function getProjectProcessor(name)
if (not name) then if (not name) then
return return
end end
local scre = projectsprocessor[name] local scre = _auProjects[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 if (not scre) then
return return
end end
return scre.processor return scre.processor
end end
function getCurrentProjectName() local function getProjectProcessorOrThrow(name)
return current_project local ret = getProjectProcessor(name)
if (not ret) then
auFatal("Missing project", name)
end
return ret
end end
function importAndLinkProject(dep, soft) local function getCurrentProjectName()
local proj = _G["projectsprocessor"][dep] return _auCurrentProject
if (not proj) then end
if (soft) then
return false
end
auFatal("Missing project", dep)
end
local iface = proj.processor local function importAndLinkProject(dep, soft)
if (not isProjectLoaded(dep)) then local processor = getProjectProcessorOrThrow(dep)
if (soft) then
return false
end
auFatal("missing project: ", dep)
end
local circular = isWeakCircularReference(dep) processor:handleReference(isWeakCircularReference(dep))
iface:handleReference(isWeakCircularReference(dep))
if (getProjectInfo(getCurrentProjectName()).isStatic) then if (auGetCurrentProjectMeta().isStatic) then
return true return true
end end
processor:handleLink()
iface:handleLink()
return true return true
end end
function includeAuProject(dep, soft) local function includeAuProject(dep, soft)
local proj = _G["projectsprocessor"][dep] local processor = getProjectProcessorOrThrow(dep)
processor:handleReference()
if (not proj) then
if (soft) then
return false
end
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 return true
end end
function linkAuProject(dep, soft) local function linkAuProject(dep, soft)
local proj = _G["projectsprocessor"][dep] local processor = getProjectProcessorOrThrow(dep)
if (not proj) then
if (soft) then
return false
end
auFatal("Missing project", dep)
end
local processor = proj.processor
if (not isProjectLoaded(dep)) then
if (soft) then
return false
end
auFatal("missing project: ", dep)
end
if (not processor:getMeta().isStatic) then if (not processor:getMeta().isStatic) then
processor:handleLink() processor:handleLink()
end end
return true return true
end end
local function addFeature(feature)
-- executes inline under iprocessor::process
function addFeature(feature)
print("adding feature ", feature) print("adding feature ", feature)
local script = auGetRoot() .. "/Build_Scripts/Features/" .. feature:lower() .. ".lua" local script = auGetRoot() .. "/Build_Scripts/Features/" .. feature:lower() .. ".lua"
@ -442,4 +384,17 @@ function addFeature(feature)
end end
auRequireAbs(script)() auRequireAbs(script)()
end end
return {
addVisit = addVisit,
addScript = addScript,
addFeature = addFeature,
linkAuProject = linkAuProject,
includeAuProject = includeAuProject,
importAndLinkProject = importAndLinkProject,
getProjectProcessor = getProjectProcessor,
isProjectLoaded = isProjectLoaded,
getCurrentProjectName = getCurrentProjectName,
processSolution = processSolution
}

View File

@ -1,6 +1,7 @@
-- private -- private
local buildAction = auRequire("Core/Actions") local buildAction = auRequire("Core/Actions")
local target = auRequire("Core/Target") local target = auRequire("Core/Target")
local main = auRequire("Core/Main")
-- executes inline under iprocessor::process -- executes inline under iprocessor::process
function auAddBuildAction(...) function auAddBuildAction(...)
@ -33,6 +34,10 @@ function auStartProject(project)
auRequire("Core").project.startProject(project) auRequire("Core").project.startProject(project)
end end
function auProcessSolution()
main.processSolution()
end
function auFilterForPlatforms(callback, ...) function auFilterForPlatforms(callback, ...)
target.auFilterForPlatforms(callback, ...) target.auFilterForPlatforms(callback, ...)
end end
@ -46,7 +51,7 @@ function auFilterForConfigPlatforms(callback, ...)
end end
function auAddVisit(...) function auAddVisit(...)
addVisit(...) main.addVisit(...)
end end
-- Returns an array of filter tables where each optional table is checked against the current combination of config/platform/arch -- Returns an array of filter tables where each optional table is checked against the current combination of config/platform/arch
@ -91,27 +96,39 @@ function auFilter(filter)
end end
function auLinkProject(...) function auLinkProject(...)
linkAuProject(...) main.linkAuProject(...)
end end
function auIncludeProject(...) function auIncludeProject(...)
includeAuProject(...) main.includeAuProject(...)
end end
function auLinkAndRefProject(...) function auLinkAndRefProject(...)
importAndLinkProject(...) main.importAndLinkProject(...)
end end
function auAddFeature(...) function auAddFeature(...)
addFeature(...) main.addFeature(...)
end end
function auGetCurrentProject() function auGetCurrentProject()
return getCurrentProjectName() return main.getCurrentProjectName()
end
function auGetProjectProcessor(name)
return main.getProjectProcessor(name)
end
function auGetProjectMeta(name)
local processor = auGetProjectProcessor(name)
if (not processor) then
return
end
return processor:getMeta()
end end
function auGetCurrentProjectProcessor() function auGetCurrentProjectProcessor()
return getProjectProcessor(auGetCurrentProject()) return main.getProjectProcessor(auGetCurrentProject())
end end
function auGetCurrentProjectMeta() function auGetCurrentProjectMeta()
@ -119,9 +136,5 @@ function auGetCurrentProjectMeta()
end end
function auIsProjectIntialized(name) function auIsProjectIntialized(name)
return isProjectLoaded(name) return main.isProjectLoaded(name)
end end
function auProcessSolution()
processSolution()
end

View File

@ -1,7 +1,5 @@
-- If this is your entrypoint, you should consider starting premake from the public/global directory -- If this is your entrypoint, you should consider starting premake from the public/global directory
-- Developers should look to the public/global directory for the user facing API -- Developers should look to the public/global directory for the user facing API
require("Public.base") require("Public.base")
@ -10,7 +8,4 @@ function startSolution(name)
{ {
name = name name = name
} }
end end
require("Core.Legacy.aurora")