Begin deprecating jsonProcessor.lua

[*] Move M4 and unpack
[*] Move funcs out of Utilities.lua
This commit is contained in:
Reece Wilson 2022-03-06 21:30:06 +00:00
parent 3b4d6cccf2
commit 252f239f69
4 changed files with 58 additions and 63 deletions

View File

@ -352,6 +352,31 @@ local function auBlockProjectKeyVala(processor, value)
end, false) end, false)
end end
local function auBlockProjectKeyUnpack(processor, value)
__pushFilter(value, "files", function(fileName)
local referencePath = path.join(Aurora.Settings.sAbsRepoScripts, fileName)
local destinationPath = path.join(processor:getMeta().path, fileName)
if (not os.isfile(destinationPath)) then
os.copyfile(referencePath, destinationPath)
end
end, true)
end
local function auBlockProjectKeyM4(processor, value)
processor.m4_files = processor.m4_files or {}
__pushFilter(value, nil, function(obj)
for fk, fv in pairs(obj) do
local fileTbl = info.m4_files[fk] or {}
info.m4_files[fk] = fileTbl
for k, v in pairs(fv) do
fileTbl[k] = v
end
end
end, true)
end
local function auBlockProjectKeySoftDepends(processor, value) local function auBlockProjectKeySoftDepends(processor, value)
__pushFilter(value, "value", function(obj) __pushFilter(value, "value", function(obj)
handleDepends(processor, obj, true) handleDepends(processor, obj, true)
@ -431,7 +456,9 @@ auProjectBlockHandlers =
features = auBlockKeyFeature, features = auBlockKeyFeature,
resourceScript = auBlockProjectKeyResourceScript, resourceScript = auBlockProjectKeyResourceScript,
protobuf = auBlockProjectKeyProtobuf, protobuf = auBlockProjectKeyProtobuf,
vala = auBlockProjectKeyVala vala = auBlockProjectKeyVala,
unpack = auBlockProjectKeyUnpack,
m4 = auBlockProjectKeyM4
} }
auProjectBlockHandlers["soft-depends"] = auBlockProjectKeySoftDepends auProjectBlockHandlers["soft-depends"] = auBlockProjectKeySoftDepends
@ -460,7 +487,7 @@ auProjectRefHandlers["depends"] = auBlockProjectRefKeyDepends
"impInclude", "implInclude", "impIncludes", "implIncludes", "clangIgnore", "impInclude", "implInclude", "impIncludes", "implIncludes", "clangIgnore",
"msvcIgnore", "excludes", "depends", "require", "msvcIgnore", "excludes", "depends", "require",
"eval", "lua", "events", "actions", "staticImpDefines", "features", "eval", "lua", "events", "actions", "staticImpDefines", "features",
"links", "soft-depends", "resourceScript", "protobuf", "vala" "links", "soft-depends", "resourceScript", "protobuf", "vala", "unpack", "m4"
} }
local kReferenceTasks = {"eval", "includes", "include", "includes"} --, "features"} local kReferenceTasks = {"eval", "includes", "include", "includes"} --, "features"}
@ -476,6 +503,10 @@ __pRunTasks = function(processor, object, map, tasks, inc, resolve)
end) end)
end end
local function postRunMain(processor)
-- TODO: m4
end
local function __pRunLinkTasks(processor, object, resolve) local function __pRunLinkTasks(processor, object, resolve)
__pRunTasks(processor, object, auProjectRefHandlers, { "links", "depends", "soft-depends", "eval", "linkDepends", "defines", "actions"}, false, resolve) __pRunTasks(processor, object, auProjectRefHandlers, { "links", "depends", "soft-depends", "eval", "linkDepends", "defines", "actions"}, false, resolve)
end end
@ -514,6 +545,7 @@ local function __pRunMainTasks(processor, object)
if (not object.noRootInclude) then if (not object.noRootInclude) then
_includeDirectoryEx(processor:getMeta().path, isIncludeLocalProject) _includeDirectoryEx(processor:getMeta().path, isIncludeLocalProject)
end end
postRunMain(processor)
end end
return auCopyTables(auProjectHeaderHandlers, auProjectBlockHandlers, { return auCopyTables(auProjectHeaderHandlers, auProjectBlockHandlers, {

View File

@ -139,22 +139,6 @@ function JsonProcessor(info)
local isUtility = false local isUtility = false
info.copy_build_files = {}
local function runCopies(prefix, rootPath, name)
local referenceRoot = auGetRoot() .. Aurora.Settings.sRelRepoScripts .. "/" .. name .. "/"
local referencePath = referenceRoot .. prefix
local copyRoot = rootPath .. "/" .. prefix
info.copy_build_files[_G.path.getrelative(referencePath, path)] = prefix
if (not os.isfile(copyRoot)) then
os.copyfile(referencePath, copyRoot)
end
end
auForEach(result.unpack, runCopies, info.path, info.name)
local prj_ = { local prj_ = {
name = info.name, name = info.name,
projectType = info.projectType or result.projectType, projectType = info.projectType or result.projectType,
@ -208,29 +192,8 @@ function JsonProcessor(info)
handleInclude(a, true) handleInclude(a, true)
info.m4_files = {}
local addM4Defines = function(obj)
if (not obj) then return end
for fk, fv in pairs(obj) do
local fileTbl = info.m4_files[fk] or {}
info.m4_files[fk] = fileTbl
for k, v in pairs(fv) do
fileTbl[k] = v
end
end
end
local processJsonBlock = function(object)
auRequire("Core/JSON/JSON").projectHandlers.runProjectBlock(a, object)
auForEach(object.unpack, runCopies, info.path, info.name)
addM4Defines(object.m4Defines)
end
if (not isUtility) then if (not isUtility) then
processJsonBlock(result) auRequire("Core/JSON/JSON").projectHandlers.runProjectBlock(a, result)
if (a.info.projectType:lower() == "sharedlib") then if (a.info.projectType:lower() == "sharedlib") then
auForEach(result.dllexport, defines) auForEach(result.dllexport, defines)
@ -239,18 +202,16 @@ function JsonProcessor(info)
end end
auForEach(result.subprojs, function(subproj) auForEach(result.subprojs, function(subproj)
local subinfo = { local subinfo = {
namespace = info.namespace, namespace = info.namespace,
path = info.path .. "/" .. subproj.path, path = path.join(info.path, subproj.path),
projectType = subproj.projectType, projectType = subproj.projectType,
out = info.out, out = info.out,
name = nil, name = subproj.name,
translations = info.translations translations = auCopyTables(info.translations, subproj.translations)
} }
addVist(subinfo) auAddVist(subinfo)
end) end)
local interface = {} local interface = {}

View File

@ -11,19 +11,4 @@ require("./base64")
require("./requireAbs") require("./requireAbs")
require("./merge") require("./merge")
require("./settings") require("./settings")
require("./contains") require("./contains")
function table.copy(t)
local u = { }
for k, v in pairs(t) do u[k] = v end
--setmetatable(u, getmetatable(t))
return u
end
function auMap(array, func)
local tbl = {}
auForEach(array, function(value)
table.insert(tbl, func(value))
end)
return tbl
end

View File

@ -12,7 +12,9 @@ function auCopyTables(...)
local args = table.pack(...) local args = table.pack(...)
for i=1, args.n do for i=1, args.n do
local tbl = args[i] local tbl = args[i]
auForEachKV(tbl, function(key, value) dest[key] = value end) if (tbl) then
auForEachKV(tbl, function(key, value) dest[key] = value end)
end
end end
return dest return dest
end end
@ -24,4 +26,19 @@ function auMergeArray(dest, src)
table.insert(dest, value) table.insert(dest, value)
end) end)
return dest return dest
end
function table.copy(t)
local u = { }
for k, v in pairs(t) do u[k] = v end
--setmetatable(u, getmetatable(t))
return u
end
function auMap(array, func)
local tbl = {}
auForEach(array, function(value)
table.insert(tbl, func(value))
end)
return tbl
end end