From 252f239f69558140c73c29b08538abb27b9eb892 Mon Sep 17 00:00:00 2001 From: Reece Date: Sun, 6 Mar 2022 21:30:06 +0000 Subject: [PATCH] Begin deprecating jsonProcessor.lua [*] Move M4 and unpack [*] Move funcs out of Utilities.lua --- Core/JSON/jsonProjectHandlers.lua | 36 +++++++++++++++++++++-- Core/Legacy/jsonProcessor.lua | 49 ++++--------------------------- Utilities/Utilities.lua | 17 +---------- Utilities/merge.lua | 19 +++++++++++- 4 files changed, 58 insertions(+), 63 deletions(-) diff --git a/Core/JSON/jsonProjectHandlers.lua b/Core/JSON/jsonProjectHandlers.lua index a0c03dd..9f6ee10 100644 --- a/Core/JSON/jsonProjectHandlers.lua +++ b/Core/JSON/jsonProjectHandlers.lua @@ -352,6 +352,31 @@ local function auBlockProjectKeyVala(processor, value) end, false) 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) __pushFilter(value, "value", function(obj) handleDepends(processor, obj, true) @@ -431,7 +456,9 @@ auProjectBlockHandlers = features = auBlockKeyFeature, resourceScript = auBlockProjectKeyResourceScript, protobuf = auBlockProjectKeyProtobuf, - vala = auBlockProjectKeyVala + vala = auBlockProjectKeyVala, + unpack = auBlockProjectKeyUnpack, + m4 = auBlockProjectKeyM4 } auProjectBlockHandlers["soft-depends"] = auBlockProjectKeySoftDepends @@ -460,7 +487,7 @@ auProjectRefHandlers["depends"] = auBlockProjectRefKeyDepends "impInclude", "implInclude", "impIncludes", "implIncludes", "clangIgnore", "msvcIgnore", "excludes", "depends", "require", "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"} @@ -476,6 +503,10 @@ __pRunTasks = function(processor, object, map, tasks, inc, resolve) end) end +local function postRunMain(processor) + -- TODO: m4 +end + local function __pRunLinkTasks(processor, object, resolve) __pRunTasks(processor, object, auProjectRefHandlers, { "links", "depends", "soft-depends", "eval", "linkDepends", "defines", "actions"}, false, resolve) end @@ -514,6 +545,7 @@ local function __pRunMainTasks(processor, object) if (not object.noRootInclude) then _includeDirectoryEx(processor:getMeta().path, isIncludeLocalProject) end + postRunMain(processor) end return auCopyTables(auProjectHeaderHandlers, auProjectBlockHandlers, { diff --git a/Core/Legacy/jsonProcessor.lua b/Core/Legacy/jsonProcessor.lua index 85feb18..549d69e 100644 --- a/Core/Legacy/jsonProcessor.lua +++ b/Core/Legacy/jsonProcessor.lua @@ -139,22 +139,6 @@ function JsonProcessor(info) 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_ = { name = info.name, projectType = info.projectType or result.projectType, @@ -208,29 +192,8 @@ function JsonProcessor(info) 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 - processJsonBlock(result) + auRequire("Core/JSON/JSON").projectHandlers.runProjectBlock(a, result) if (a.info.projectType:lower() == "sharedlib") then auForEach(result.dllexport, defines) @@ -239,18 +202,16 @@ function JsonProcessor(info) end auForEach(result.subprojs, function(subproj) - local subinfo = { namespace = info.namespace, - path = info.path .. "/" .. subproj.path, + path = path.join(info.path, subproj.path), projectType = subproj.projectType, out = info.out, - name = nil, - translations = info.translations + name = subproj.name, + translations = auCopyTables(info.translations, subproj.translations) } - addVist(subinfo) - + auAddVist(subinfo) end) local interface = {} diff --git a/Utilities/Utilities.lua b/Utilities/Utilities.lua index 602b3b7..edc2b46 100644 --- a/Utilities/Utilities.lua +++ b/Utilities/Utilities.lua @@ -11,19 +11,4 @@ require("./base64") require("./requireAbs") require("./merge") require("./settings") -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 \ No newline at end of file +require("./contains") \ No newline at end of file diff --git a/Utilities/merge.lua b/Utilities/merge.lua index 33c4929..0a939f2 100644 --- a/Utilities/merge.lua +++ b/Utilities/merge.lua @@ -12,7 +12,9 @@ function auCopyTables(...) local args = table.pack(...) for i=1, args.n do 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 return dest end @@ -24,4 +26,19 @@ function auMergeArray(dest, src) table.insert(dest, value) end) 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 \ No newline at end of file