From 85a130e167e0f23fb062502f22663cdd611ad5be Mon Sep 17 00:00:00 2001 From: Jamie Reece Wilson Date: Tue, 12 Dec 2023 01:39:58 +0000 Subject: [PATCH] [+] auProcessSolutionByJsonDocument [+] auProcessSolutionByPath [+] Core/JSON/jsonSolution --- Core/JSON/JSON.lua | 3 +- Core/JSON/jsonSolution.lua | 83 ++++++++++++++++++++++++++++++++++++++ Public/api.lua | 20 +++++++++ Public/premake5.lua | 9 ++++- Utilities/userRequire.lua | 2 +- 5 files changed, 114 insertions(+), 3 deletions(-) diff --git a/Core/JSON/JSON.lua b/Core/JSON/JSON.lua index b8556d2..483a804 100644 --- a/Core/JSON/JSON.lua +++ b/Core/JSON/JSON.lua @@ -1,4 +1,5 @@ return { projectHandlers = auRequire("Core/JSON/jsonProjectHandlers"), - projectBase = auRequire("Core/JSON/jsonProjectBase") + projectBase = auRequire("Core/JSON/jsonProjectBase"), + jsonSolution = auRequire("Core/JSON/jsonSolution") } \ No newline at end of file diff --git a/Core/JSON/jsonSolution.lua b/Core/JSON/jsonSolution.lua index e69de29..5be623e 100644 --- a/Core/JSON/jsonSolution.lua +++ b/Core/JSON/jsonSolution.lua @@ -0,0 +1,83 @@ +local function processSolution(document) + os.chdir(Aurora.Settings.sAbsRoot) + if (type(document.cppVersion) == "string") then + Aurora.Settings.sCppVersion = document.cppVersion + end + if (type(document.enableLTOUnderShip) == "boolean") then + Aurora.Settings.bUseAuBuildHooks = document.enableLTOUnderShip + end + if (type(document.msvcDefCharset) == "string") then + Aurora.Settings.sMsvcDefCharset = document.msvcDefCharset + end + if (type(document.enableBasicMitigations) == "boolean") then + Aurora.Settings.bBasicMitigations = document.enableBasicMitigations + end + if (type(document.enableLTO) == "boolean") then + Aurora.Settings.bLTO = document.enableLTO + end + if (type(document.enableEditAndContinue) == "boolean") then + Aurora.Settings.bEditAndCont = document.enableEditAndContinue + end + if (type(document.enableStaticRuntime) == "boolean") then + Aurora.Settings.bStaticRuntime = document.enableStaticRuntime + end + if (type(document.enableFullTargetName) == "boolean") then + Aurora.Settings.bDefinePartialABIInTargetName = document.enableFullTargetName + end + local slnName = document.solutionName or "UnnamedSolution" + local noStart = document.noStartSolution or _G.alreadyStartedSlnByScript or false + if (not noStart) then + auStartSolution({name = slnName}) + _G.alreadyStartedSlnByScript = true + end + if (type(document.options) == "table") then + auForEach(document.options, function(opt) + newoption { + trigger = opt.name or opt, + description = opt.description or "" + } + end) + end + auForEach(document.preLuaRequire, function(requireStr) + auUserRequire(requireStr) + end) + auForEachKV(document, function(namespace, documents2) + local namespace2 = documents2.namespace or namespace + if (type(documents2.enableIf) == "string") then + if (not _OPTIONS[documents2.enableIf]) then + return + end + end + if (type(documents2.removeIf) == "string") then + if (_OPTIONS[documents2.removeIf]) then + return + end + end + auForEach(documents2.projects or documents2, function(document2) + if (not document2.name) then return end + if (type(document2.enableIf) == "string") then + if (not _OPTIONS[document2.enableIf]) then + return + end + end + if (type(document2.removeIf) == "string") then + if (_OPTIONS[document2.removeIf]) then + return + end + end + auAddVisit({ + namespace = namespace2, + name = document2.name, + path = document2.path, + type = document2.projectType, + out = document2.out or documents2.out + }) + end) + end) + auForEach(document.luaRequire, function(requireStr) + auUserRequire(requireStr) + end) + auProcessSolution() +end + +return processSolution \ No newline at end of file diff --git a/Public/api.lua b/Public/api.lua index ca55301..acafd24 100644 --- a/Public/api.lua +++ b/Public/api.lua @@ -5,6 +5,7 @@ local main = auRequire("Core/main") local resourceCompiler = auRequire("Core/ResourceCompiler") local protobuf = auRequire("Core/Protobuf") local vala = auRequire("Core/Vala") +local crJSON = auRequire("Core/JSON") -- executes inline under iprocessor::process function auAddBuildAction(...) @@ -40,6 +41,25 @@ function auProcessSolution() main.processSolution() end +function auProcessSolutionByJsonDocument(doc) + crJSON.jsonSolution(doc) +end + +function auProcessSolutionByPath(path) + if (not os.isfile(path)) then + auFatal("Missing solution file", path) + return + end + + local result, err = json.decode(io.readfile(path)) + if (not result) then + auFatal("Solution parse error", err) + return + end + + auProcessSolutionByJsonDocument(result) +end + function auFilterForPlatforms(callback, ...) target.auFilterForPlatforms(callback, ...) end diff --git a/Public/premake5.lua b/Public/premake5.lua index 614d3f0..d9999b5 100644 --- a/Public/premake5.lua +++ b/Public/premake5.lua @@ -51,7 +51,14 @@ local function start() elseif (os.isfile("../../AuroraSolution.lua")) then require("../../AuroraSolution") elseif (os.isfile("../../AuroraSolution.json")) then - -- TODO: ... + local result, err = json.decode(io.readfile("../../AuroraSolution.json")) + + if (not result) then + auFatal("AuroraSolution.json parse error", err) + return + end + + auProcessSolutionByJsonDocument(result) else auFatal("No solution file found in the root") end diff --git a/Utilities/userRequire.lua b/Utilities/userRequire.lua index 597a968..b68e15c 100644 --- a/Utilities/userRequire.lua +++ b/Utilities/userRequire.lua @@ -1,5 +1,5 @@ function auUserRequire(path) - local script = "./" .. path + local script = os.realpath(os.translate(Aurora.Settings.sAbsRoot .. "/" .. path)) if (not script:ends(".lua")) then script = script .. ".lua"