[*] json processor clean up

This commit is contained in:
Reece Wilson 2022-03-07 00:02:49 +00:00
parent 252f239f69
commit 4657a14fe7

View File

@ -1,5 +1,5 @@
local auProject = auRequire("Core/project").startProject
local valaGo = auRequire("Core/Vala")
local projectHandlers = auRequire("Core/JSON/JSON").projectHandlers
function JsonProcessor(info)
local result, err = json.decode(io.readfile(info.jpath))
@ -31,14 +31,17 @@ function JsonProcessor(info)
includeDirEx(prefix .. "/" .. path, inc)
end
local publicDepends = function(name, this, soft)
auIncludeProject(this:translateDep(name), soft) -- evil recursion
end
local handleJSONInclude = function(this, val, incFiles)
auRequire("Core/JSON/JSON").projectHandlers.runProjectImport(this, result, {"include", "includes", "actions"}, function(dep, soft)
projectHandlers.runProjectImport(this, result, {"include", "includes", "actions"}, function(dep, soft)
publicDepends(dep, this, soft)
end)
end
local handleInclude = function(this, incFiles)
local otherREsult = info
local result = this.result
auForEach(result.defines, defines)
@ -56,23 +59,14 @@ function JsonProcessor(info)
end
end
local processSubLinks = function(this)
auRequire("Core/JSON/JSON").projectHandlers.runProjectLink(this, result, function(dep, soft)
auLinkProject(this:translateDep(dep), soft)
end)
end
local handleSourcesRel = function(source, path)
files(path .. "/" .. source)
end
local handleLink = function(this)
dependson(this.info.name)
auForEach(result.linkSources, handleSourcesRel, info.path)
auForEach(result.linkSources, function(source)
files(path.join(this:getMeta().path, source))
end)
local type = this.result.type
if ((type:lower() == "utility") or (type:lower() == "blank")) then
return
end
@ -81,14 +75,9 @@ function JsonProcessor(info)
links(this.info.name)
end
--if (not this.info.isStatic) then
processSubLinks(this)
--end
end
local publicDepends = function(name, this, soft)
auIncludeProject(this:translateDep(name), soft) -- evil recursion
projectHandlers.runProjectLink(this, result, function(dep, soft)
auLinkProject(this:translateDep(dep), soft)
end)
end
local handleReference = function(this, circular)
@ -102,34 +91,34 @@ function JsonProcessor(info)
local staticImport = circular
local pendingOps = {}
local jsonKeys = {}
if (cur and cur.isShared and not circular) then
table.insert(pendingOps, "dllimport")
table.insert(jsonKeys, "dllimport")
elseif (cur and cur.isStatic and not circular) then
table.insert(pendingOps, "dllexport")
table.insert(pendingOps, "staticImport")
table.insert(pendingOps, "staticImpDefines")
table.insert(jsonKeys, "dllexport")
table.insert(jsonKeys, "staticImport")
table.insert(jsonKeys, "staticImpDefines")
elseif (circular) then
table.insert(pendingOps, "staticImport")
table.insert(pendingOps, "staticImpDefines")
table.insert(jsonKeys, "staticImport")
table.insert(jsonKeys, "staticImpDefines")
end
table.insert(pendingOps, "include")
table.insert(pendingOps, "include-depends")
table.insert(pendingOps, "include-soft-depends")
table.insert(jsonKeys, "include")
table.insert(jsonKeys, "include-depends")
table.insert(jsonKeys, "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)
projectHandlers.runProjectImport(this, result, jsonKeys, function(dep, soft)
publicDepends(dep, this, soft)
end)
end
local pokeDeps = function(this, resolve)
auRequire("Core/JSON/JSON").projectHandlers.runProjectLink(this, result, resolve)
local resolveDependencies = function(this, resolve)
projectHandlers.runProjectLink(this, result, resolve)
end
local handleProcess = function (a)
@ -139,7 +128,7 @@ function JsonProcessor(info)
local isUtility = false
local prj_ = {
local project = {
name = info.name,
projectType = info.projectType or result.projectType,
dest = info.out,
@ -148,7 +137,7 @@ function JsonProcessor(info)
if (result.noLink) then
print("noLink is deprecated. Use projectType: none")
prj_.projectType = "none"
project.projectType = "none"
info.projectType = "none"
end
@ -157,25 +146,25 @@ function JsonProcessor(info)
local srcPath = path .. "/Source"
local incPath = path .. "/Include" -- /Source is emitted by design. Use it as a prefix in <> includes; eg, #include <Source/MyLib.hpp>
prj_.src = srcPath
prj_.inc = {incPath, path}
auProject(prj_)
project.src = srcPath
project.inc = {incPath, path}
auProject(project)
elseif (result.type:lower() == "lazy_free") then
prj_.src = path .. "/*.*"
prj_.inc = path .. "/"
auProject(prj_)
project.src = path .. "/*.*"
project.inc = path
auProject(project)
elseif (result.type:lower() == "root") then
prj_.src = path
prj_.inc = path
auProject(prj_)
project.src = path
project.inc = path
auProject(project)
elseif (result.type:lower() == "generic") then
auProject(prj_)
auProject(project)
elseif (result.type:lower() == "utility") then
project(name)
@ -186,14 +175,13 @@ function JsonProcessor(info)
return
else
print "invalid project type"
os.exit()
auFatal("invalid project type", result.type)
end
handleInclude(a, true)
if (not isUtility) then
auRequire("Core/JSON/JSON").projectHandlers.runProjectBlock(a, result)
projectHandlers.runProjectBlock(a, result)
if (a.info.projectType:lower() == "sharedlib") then
auForEach(result.dllexport, defines)
@ -217,7 +205,7 @@ function JsonProcessor(info)
local interface = {}
interface.result = result
interface.info = info
interface.resolveDependencies = pokeDeps
interface.resolveDependencies = resolveDependencies
interface.process = handleProcess
interface.handleLink = handleLink
interface.handleReference = handleReference