[+] auProcessSolutionByJsonDocument

[+] auProcessSolutionByPath
[+] Core/JSON/jsonSolution
This commit is contained in:
Reece Wilson 2023-12-12 01:39:58 +00:00
parent 02c1c4d0d8
commit 85a130e167
5 changed files with 114 additions and 3 deletions

View File

@ -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")
}

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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"