[*] Strip even more out of jsonProcessor.lua

This commit is contained in:
Reece Wilson 2022-01-19 23:19:17 +00:00
parent 3e2f123f66
commit 0cd24fbede
3 changed files with 140 additions and 161 deletions

View File

@ -287,12 +287,33 @@ local function auBlockProjectKeyDepends(processor, value)
end, processor, true)
end
local function auBlockProjectKeyDllimport(processor, value)
__pushFilter(value, "value", defines, processor)
end
local function auBlockProjectKeyDllexport(processor, value)
__pushFilter(value, "value", defines, processor)
end
local function auBlockProjectKeySoftDepends(processor, value)
__pushFilter(value, "value", function(obj)
handleDepends(processor, obj, true)
end, processor, true)
end
local function auBlockProjectRefKeyInclSoftDepends(processor, value, taskMap, taskArray, inc, resolve)
__pushFilter(value, "value", function(obj)
resolve(processor:translateDep(obj), false)
end, processor, true)
end
local function auBlockProjectRefKeyInclDepends(processor, value, taskMap, taskArray, inc, resolve)
__pushFilter(value, "value", function(obj)
resolve(processor:translateDep(obj), false)
end, processor, true)
end
local function auBlockProjectRefKeyDepends(processor, value, taskMap, taskArray, inc, resolve)
__pushFilter(value, "value", function(obj)
resolve(processor:translateDep(obj), false)
@ -359,9 +380,21 @@ auProjectBlockHandlers["soft-depends"] = auBlockProjectKeySoftDepends
local auProjectRefHandlers =
{
linkDepends = auHeaderProjectKeyLinkDepends,
eval = auBlockProjectKeyEval
eval = auBlockProjectKeyEval,
events = auBlockProjectKeyBuildEvent,
actions = auBlockProjectKeyBuildAction,
links = auBlockProjectKeyLinks,
defines = auBlockProjectKeyDefines,
include = auBlockProjectKeyIncludes,
includes = auBlockProjectKeyIncludes,
dllimport = auBlockProjectKeyDllimport,
dllexport = auBlockProjectKeyDllimport,
staticImport = auBlockProjectKeyDllimport,
staticImpDefines = auBlockProjectKeyDllimport
}
auProjectRefHandlers["soft-depends"] = auBlockProjectRefKeySoftDepends
auProjectRefHandlers["include-soft-depends"] = auBlockProjectRefKeyInclSoftDepends
auProjectRefHandlers["include-depends"] = auBlockProjectRefKeyInclDepends
auProjectRefHandlers["depends"] = auBlockProjectRefKeyDepends
kGenericTasks = {"sourcePaths", "includes","include", "sources",
@ -372,8 +405,8 @@ auProjectRefHandlers["depends"] = auBlockProjectRefKeyDepends
"links", "soft-depends"
}
local kReferenceTasks = {"eval", "includes", "include"} --, "features"}
local kReferenceTasks = {"eval", "includes", "include", "includes"} --, "features"}
-- , "include-depends", "include-soft-depends"
__pRunTasks = function(processor, object, map, tasks, inc, resolve)
auForEachKV(tasks, function(na, key)
@ -381,13 +414,12 @@ __pRunTasks = function(processor, object, map, tasks, inc, resolve)
if (not value) then
return
end
map[key](processor, value, map, tasks, inc, resolve)
end)
end
local function __pRunLinkTasks(processor, object, resolve)
__pRunTasks(processor, object, auProjectRefHandlers, { "links", "depends", "soft-depends", "eval"}, false, resolve)
__pRunTasks(processor, object, auProjectRefHandlers, { "links", "depends", "soft-depends", "eval", "linkDepends", "defines", "actions"}, false, resolve)
end
local function __pRunIncludeTasks(processor, object, isIncludeLocalProject)
@ -402,10 +434,19 @@ local function __pRunIncludeTasks(processor, object, isIncludeLocalProject)
end
end
local function ___pRunIncludeTasks(processor, object, isIncludeLocalProject)
__pRunIncludeTasks(processor, object, isIncludeLocalProject)
local function ___pRunIncludeTasks(processor, object, resolve)
__pRunIncludeTasks(processor, object, false)
if (not object.noRootInclude) then
_includeDirectoryEx(processor:getMeta().path, isIncludeLocalProject)
_includeDirectoryEx(processor:getMeta().path, false)
end
end
local function ___pRunImportTask(processor, object, mask, resolve)
__pRunIncludeTasks(processor, object, false)
__pRunTasks(processor, object, auProjectRefHandlers, mask, false, resolve)
if (not object.noRootInclude) then
_includeDirectoryEx(processor:getMeta().path, false)
end
end
@ -420,5 +461,6 @@ end
return auCopyTables(auProjectHeaderHandlers, auProjectBlockHandlers, {
runProjectBlock = __pRunMainTasks,
runProjectLink = __pRunLinkTasks,
runProjectImport = ___pRunImportTask,
runProjectRef = ___pRunIncludeTasks
})

View File

@ -14,10 +14,6 @@ function JsonProcessor(info)
end
result.name = info.name
local translateDep = function(this, dep)
return this:translateDep(dep)
end
-- ported
local includeDirEx = function(path, incFiles)
includedirs(path)
@ -35,16 +31,10 @@ function JsonProcessor(info)
includeDirEx(prefix .. "/" .. path, inc)
end
local handleJSONInclude = function(result, val, incFiles)
if (not result.include) then
if (val) then
return
end
includeDirEx (info.path, incFiles)
return
end
auForEach(result.include, handleUserJsonInclude, info.path, incFiles)
local handleJSONInclude = function(this, val, incFiles)
auRequire("Core/JSON/JSON").projectHandlers.runProjectImport(this, result, {"include", "includes", "actions"}, function(dep, soft)
publicDepends(dep, this, soft)
end)
end
local handleInclude = function(this, incFiles)
@ -57,64 +47,18 @@ function JsonProcessor(info)
includeDirEx(info.path .. "/Include")
elseif (result.type:lower() == "lazy_free") then
includeDirEx(info.path)
handleJSONInclude(result, false, incFiles)
handleJSONInclude(this, false, incFiles)
elseif (result.type:lower() == "root") then
includeDirEx(info.path)
handleJSONInclude(result, result.noRootInclude, incFiles)
handleJSONInclude(this, result.noRootInclude, incFiles)
elseif (result.type:lower() == "generic") then
handleJSONInclude(result, false, incFiles)
elseif ((result.type:lower() == "utility") or (result.type:lower() == "blank")) then
return
end
end
local handleBuildEvent = function(obj)
local type = ""
if ( obj.lua) then
type = "lua"
elseif (obj.bin) then
type = "bin"
else
return
end
auAddBuildAction(obj.when, type, obj[type], obj.isCwdProjRoot)
end
local handleDllImportMaybe = function(this)
if (this.info.isShared) then
auForEach(this.result.dllimport, defines)
end
end
local handleDllExportMaybe = function(this)
if (this.info.isShared) then
auForEach(this.result.dllexport, defines)
end
end
local handleDependsShort = function(dep, this, soft)
dep = translateDep(this, dep)
local processor = auGetProjectProcessor(this:translateDep(dep))
if (not processor) then
if (soft) then
print("Not including, ", dep)
return
end
fatal("Missing project", dep)
end
if (auIsProjectIntialized(dep) and not _G["_linkingcur"][dep]) then
processor:handleLink()
handleJSONInclude(this, false, incFiles)
end
end
local processSubLinks = function(this)
auRequire("Core/JSON/JSON").projectHandlers.runProjectLink(this, result, function(dep, soft)
print("LINK-> ", dep, soft)
handleDependsShort(dep, this, soft)
auLinkProject(this:translateDep(dep), soft)
end)
end
@ -127,15 +71,6 @@ function JsonProcessor(info)
auForEach(result.linkSources, handleSourcesRel, info.path)
local erase = false;
if (not _G["_linkingcur"]) then
erase = true
_G["_linkingcur"] = {}
end
_G["_linkingcur"][this.info.name] = true
local type = this.result.type
if ((type:lower() == "utility") or (type:lower() == "blank")) then
@ -150,9 +85,6 @@ function JsonProcessor(info)
processSubLinks(this)
--end
if (erase) then
_G["_linkingcur"] = nil
end
end
local publicDepends = function(name, this, soft)
@ -166,33 +98,30 @@ function JsonProcessor(info)
return
end
local cur = nil
if (circular) then
cur = auGetCurrentProjectMeta()
else
cur = this.info
end
local cur = auGetCurrentProjectMeta()
local pendingOps = {}
if (cur and cur.isShared) then
-- shared libraries are only allowed to import other shared libraries
handleDllImportMaybe(this)
table.insert(pendingOps, "dllimport")
elseif (cur and cur.isStatic) then
-- static libs are allowed to reference dllexports in translation units of the parent shared module
handleDllExportMaybe(this)
auForEach(result.staticImport, defines)
table.insert(pendingOps, "dllexport")
table.insert(pendingOps, "staticImport")
end
if (this.info.isStatic) then
auForEach(result.staticImpDefines, defines)
table.insert(pendingOps, "staticImpDefines")
end
auForEach(result["include-depends"], publicDepends, this, false)
auForEach(result["include-soft-depends"], publicDepends, this, true)
table.insert(pendingOps, "include")
table.insert(pendingOps, "include-depends")
table.insert(pendingOps, "include-soft-depends")
handleInclude(this, false)
defines(("_auhas_" .. this.result.name):upper():gsub("%-", "_") .. "=1")
auRequire("Core/JSON/JSON").projectHandlers.runProjectImport(this, result, pendingOps, function(dep, soft)
publicDepends(dep, this, soft)
end)
end
@ -200,11 +129,6 @@ function JsonProcessor(info)
auRequire("Core/JSON/JSON").projectHandlers.runProjectLink(this, result, resolve)
end
local handleParse = function(this)
end
local handleProcess = function (a)
local result = a.result
local name = a.info.name
@ -279,40 +203,8 @@ function JsonProcessor(info)
os.exit()
end
_G["_linkingcur"] = {}
_G["_linkingcur"][name] = true
handleInclude(a, true)
local handleDepends = function(dep, this, soft)
local processor = auGetProjectProcessor(this:translateDep(dep))
if (not processor) then
if (soft) then
print("Not including, ", dep)
return
end
fatal("Missing project", dep)
end
local macro = ("_auhas_" .. dep):upper():gsub("%-", "_");
if (auIsProjectIntialized(dep)) then
defines(macro .. "=1")
processor:handleReference(isWeakCircularReference(dep))
if (not this.info.isStatic) then
processor:handleLink()
end
else
--defines(macro .. "=0")
if (not soft) then
fatal("missing project: ", dep)
end
end
end
info.m4_files = {}
local addM4Defines = function(obj)
@ -330,7 +222,6 @@ function JsonProcessor(info)
local processJsonBlock = function(object)
auRequire("Core/JSON/JSON").projectHandlers.runProjectBlock(a, object)
--auForEach(object["soft-depends"], handleDepends, a, true)
auForEach(object.unpack, runCopies, info.path, info.name)
addM4Defines(object.m4Defines)
end
@ -378,11 +269,6 @@ function JsonProcessor(info)
}
valaGo(extended)
end
auForEach(result.events, handleBuildEvent, info.path)
_G["_linkingcur"] = nil
end
auForEach(result.subprojs, function(subproj)

View File

@ -166,6 +166,8 @@ local function pushProject(project, callback)
pushProjectState(project.info.name, project.info.path, callback)
end
_auLinkGuard = {}
-- private
local function processInit(project)
if (project.isInitialized) then
@ -253,6 +255,8 @@ local function processNS(namespace)
_auFatalMsg = {}
_auFatalMsg["starting projects"] = namespace
auForEach(projsIdxs, function(idx)
_auLinkGuard = {}
_auLinkGuard[projs[idx].info.name]= {}
processProject(projs[idx].info.name)
end)
end
@ -373,32 +377,79 @@ local function getCurrentProjectName()
return _auCurrentProject
end
local function importAndLinkProject(dep, soft)
local processor = getProjectProcessorOrThrow(dep)
local function includeAuProject(dep, soft)
local processor = getProjectProcessor(dep)
if (not processor) then
return false
end
local processor = getProjectProcessor(dep)
if (not processor) then
return false
end
local a = _auProjects[dep]
if (not a) then
if (not soft) then
auFatal("missing project: ", dep)
else
return false
end
end
pushProject(a, function()
_auFatalMsg = {}
_auFatalMsg["processing project ref"] = a.info.name
processor:handleReference(isWeakCircularReference(dep))
if (auGetCurrentProjectMeta().isStatic) then
return true
end
processor:handleLink()
return true
end
local function includeAuProject(dep, soft)
local processor = getProjectProcessorOrThrow(dep)
processor:handleReference()
end)
return true
end
local function linkAuProject(dep, soft)
local processor = getProjectProcessorOrThrow(dep)
if (not processor:getMeta().isStatic) then
processor:handleLink()
local processor = getProjectProcessor(dep)
if (not processor) then
return false
end
local a = _auProjects[dep]
if (not a) then
if (not soft) then
auFatal("missing project: ", dep)
else
return false
end
end
if (_auLinkGuard[dep] ) then
return
end
_auLinkGuard[dep] = dep
--if (not processor:getMeta().isStatic) then
pushProject(a, function()
_auFatalMsg = {}
_auFatalMsg["processing project link"] = a.info.name
processor:handleLink()
end)
--end
return true
end
local function importAndLinkProject(dep, soft)
local processor = getProjectProcessorOrThrow(dep)
includeAuProject(dep, soft)
if (auGetCurrentProjectMeta().isStatic) then
return true
end
linkAuProject(dep, soft)
return true
end
local function addFeature(feature)
--print("adding feature ", feature)