[*] Begin updating build events to work on WIP branch

[*] Improve auFatalMsg logging
This commit is contained in:
Reece Wilson 2022-03-04 17:05:38 +00:00
parent 3a79d9e0df
commit a9588c9d40
7 changed files with 93 additions and 32 deletions

View File

@ -75,6 +75,7 @@ local getPremakeExec = function()
end end
local addBuildCommand = function(when, scriptType, path, cwdRelToProject, args) local addBuildCommand = function(when, scriptType, path, cwdRelToProject, args)
local scriptPath = path local scriptPath = path
local cwd = auGetRoot() local cwd = auGetRoot()
@ -97,20 +98,16 @@ local addBuildCommand = function(when, scriptType, path, cwdRelToProject, args)
command = command .. getPremakeExec() command = command .. getPremakeExec()
local oldBootstrapPrefix = Aurora.Settings.sAbsRepoScripts local oldBootstrapPrefix = Aurora.Settings.sAbsRepoScripts
local bootstrapPrefix = _G.path.getrelative(Aurora.Settings.sAbsCompilerWd .. "/" .. auGetCurrentProjectName(), Aurora.Settings.sAbsRepoScripts)
local bootstrap = bootstrapPrefix .. "/Core/Actions/buildActionBootstrap.lua" local bootstrap = Aurora.Settings.sAbsScripts .. "/Core/Actions/buildActionBootstrap.lua"
command = command .. " --file=\"" .. os.realpath(bootstrap) .. "\""
if (cdAware) then
command = command .. " --file=\"" .. bootstrap .. "\""
else
command = command .. " --file=\"" .. os.realpath(bootstrap) .. "\""
end
--command = command .. " --project_name=\"%{prj.name}\"" --command = command .. " --project_name=\"%{prj.name}\""
command = command .. " --project_name=\"" .. cur.name .. "\"" command = command .. " --project_name=\"" .. cur.name .. "\""
command = command .. " --project_type=\"" .. cur.projectType .. "\"" command = command .. " --project_type=\"" .. cur.projectType .. "\""
command = command .. " --project_config=\"%{cfg.longname}\""
command = command .. " --project_arch=\"%{cfg.architecture}\"" command = command .. " --project_arch=\"%{cfg.architecture}\""
command = command .. " --project_platform=\"%{cfg.system}\"" command = command .. " --project_platform=\"%{cfg.platform}\""
-- Aurora.Settings could take up too much of the win32 max command line buffer (8191 characters) -- Aurora.Settings could take up too much of the win32 max command line buffer (8191 characters)
-- This seems like a lot, but it should be well within the 9k limit -- This seems like a lot, but it should be well within the 9k limit
@ -152,18 +149,31 @@ local addBuildCommand = function(when, scriptType, path, cwdRelToProject, args)
cliArgs = " " .. argsEscaped cliArgs = " " .. argsEscaped
end end
if (args) then
command = command .. " --additional=\"" .. base64.encode(args) .. "\""
end
if (scriptType == "lua") then if (scriptType == "lua") then
if (os.isfile(Aurora.Settings.sAbsRepoScripts .. path)) then if (os.isfile(Aurora.Settings.sAbsRepoScripts .. path)) then
command = command .. " --luascript=\"" .. path .. "\"" command = command .. " --luascript=\"" .. path .. "\""
else else
command = command .. " --luaabsscript=\"" .. _G.path.getrelative(settings.sAbsRoot, path) .. "\"" command = command .. " --luaabsscript=\"" .. _G.path.getrelative(settings.sAbsRoot, path) .. "\""
end end
if (args) then
command = command .. " --additional=\"" .. base64.encode(args) .. "\""
end
elseif (scriptType == "bin") then elseif (scriptType == "bin") then
command = command .. " --binscript=\"" .. _G.path.getrelative(settings.sAbsRoot, path) .. cliArgs .. "\"" command = command .. " --binscript=\"" .. _G.path.getrelative(settings.sAbsRoot, path) .. cliArgs .. "\""
elseif (scriptType == "cmd") then
command = command .. " --cmd=\"" .. base64.encode(path) .. "\""
elseif (scriptType == "project") then
command = command .. " --projectbins_=\"%{cfg.targetdir}\""
command = command .. " --projectname_=" .. path
command = command .. " --projectnameex_=" .. tostring(Aurora.Settings.bDefinePartialABIInTargetName)
end end
if (when == "post") then if (when == "post") then

View File

@ -7,6 +7,13 @@ function auFetchGlobal(name)
return ret return ret
end end
local function escapeBinaryPath(path)
if (os.host() == "windows") then
return "\"" .. path .. "\""
end
return path:gsub(" ", "\\ ")
end
require("./../../Utilities/Utilities") require("./../../Utilities/Utilities")
local triggers = local triggers =
@ -22,7 +29,12 @@ local triggers =
"project_root", "project_root",
"additional", "additional",
"project_type", "project_type",
"luaabsscript" "luaabsscript",
"projectname_",
"projectbins_",
"projectnameex_",
"project_config",
"project_name"
} }
auForEach(triggers, function(trigger) auForEach(triggers, function(trigger)
@ -35,19 +47,27 @@ end)
local settings = _OPTIONS["settings"] local settings = _OPTIONS["settings"]
if (settings) then if (settings) then
Aurora.Settings = json.decode(base64.decode(settings)) Aurora.Settings = json.decode(base64.decode(settings))
require("./../../Public/Paths") require("./../../Public/paths")
end end
require("./../Target/platform")
local preconfig = path.join(Aurora.Settings.sAbsRoot, "preconfig.lua") local preconfig = path.join(Aurora.Settings.sAbsRoot, "preconfig.lua")
if (os.isfile(preconfig) then if (os.isfile(preconfig)) then
auRequireAbs(preconfig) auRequireAbs(preconfig)
end end
local projRoot = path.join(Aurora.Settings.sAbsRoot, _OPTIONS["project_root"] or "./") local projRoot = path.join(Aurora.Settings.sAbsRoot, _OPTIONS["project_root"] or "./")
local cwd =_OPTIONS["cwd"] local projectBins = _OPTIONS["projectbins_"]
if (projectBins) then
projectBins = os.realpath(path.join(projRoot, projectBins))
end
local cwd = _OPTIONS["cwd"]
if (cwd) then if (cwd) then
os.chdir(projRoot) os.chdir(projRoot)
else else
@ -61,7 +81,7 @@ end
local binSuffx = "" local binSuffx = ""
if (args) then if (args) then
binSuffx = " " .. binSuffx binSuffx = " " .. args
end end
local binScript = _OPTIONS["binscript"] local binScript = _OPTIONS["binscript"]
@ -69,23 +89,44 @@ if (binScript) then
os.exit(os.execute(path.join(Aurora.Settings.sAbsRoot, binScript) .. binSuffx)) os.exit(os.execute(path.join(Aurora.Settings.sAbsRoot, binScript) .. binSuffx))
end end
local cmd = _OPTIONS["cmd"] local cmd = _OPTIONS["cmd"]
if (cmd) then if (cmd) then
os.exit(os.execute(cmd .. binSuffx)) os.exit(os.execute(base64.decode(cmd)))
end end
local projName = _OPTIONS["project_name"] local projName = _OPTIONS["project_name"]
local projType = _OPTIONS["project_type"] local projType = _OPTIONS["project_type"]
local projPlatform = _OPTIONS["project_platform"] local projPlatform = _OPTIONS["project_platform"]
local projCfg = _OPTIONS["project_config"]
local projArch = _OPTIONS["project_arch"] local projArch = _OPTIONS["project_arch"]
local targetName = projName .. "." .. projPlatform .. "." .. projArch if (string.find(projCfg, "|")) then
projCfg = projCfg:match("([^,]+)|([^,]+)")
end
local targetName = projName .. "." .. projCfg .. "." .. projPlatform .. "." .. projArch
local fileName = targetName local fileName = targetName
local platform = Aurora.Platforms[platformName] local platform = Aurora.Platforms[projPlatform]
if (platform) then if (platform) then
fileName = fileName .. (platform.exts or {})[type] or "" fileName = fileName .. (platform.exts or {})[projType] or ""
end
if (projectBins) then
local projectName = _OPTIONS["projectname_"]
local projectNameEx = _OPTIONS["projectnameex_"] == "true"
local extension = (platform.exts or {})["ConsoleApp"]
local binName = projectName
if (projectNameEx) then
binName = string.format("%s.%s.%s.%s", binName, projCfg, projPlatform, projArch)
end
binName = binName .. extension
local cmd = escapeBinaryPath(path.join(projectBins, binName)) .. binSuffx
os.exit(os.execute(cmd))
end end
auBuild = auBuild =
@ -101,12 +142,10 @@ auBuild =
root = cwd root = cwd
} }
_G["build"] = auBuild
local luaScript = _OPTIONS["luascript"] local luaScript = _OPTIONS["luascript"]
local luaAbsScript = _OPTIONS["luaabsscript"] local luaAbsScript = _OPTIONS["luaabsscript"]
if (luaScript) then if (luaScript) then
auRequireAbs(os.realpath(build.root .. Aurora.Settings.sRelRepoScripts .. "/" .. luaScript)) auRequireAbs(path.join(Aurora.Settings.sAbsRepoScripts, luaScript))
elseif (luaAbsScript) then elseif (luaAbsScript) then
auRequireAbs(path.join(Aurora.Settings.sAbsRoot, luaAbsScript)) auRequireAbs(path.join(Aurora.Settings.sAbsRoot, luaAbsScript))
end end

View File

@ -221,11 +221,15 @@ local function auBlockProjectKeyBuildEvent(processor, value)
type = "lua" type = "lua"
elseif (value.bin) then elseif (value.bin) then
type = "bin" type = "bin"
elseif (value.project) then
type = "project"
elseif (value.cmd) then
type = "cmd"
else else
return return
end end
auAddBuildAction(obj.when, type, value[type], value.isCwdProjRoot) auAddBuildAction(value.when, type, value[type], value.isCwdProjRoot, value.args)
end, processor) end, processor)
end end
@ -381,7 +385,6 @@ local auProjectRefHandlers =
{ {
linkDepends = auHeaderProjectKeyLinkDepends, linkDepends = auHeaderProjectKeyLinkDepends,
eval = auBlockProjectKeyEval, eval = auBlockProjectKeyEval,
events = auBlockProjectKeyBuildEvent,
actions = auBlockProjectKeyBuildAction, actions = auBlockProjectKeyBuildAction,
links = auBlockProjectKeyLinks, links = auBlockProjectKeyLinks,
defines = auBlockProjectKeyDefines, defines = auBlockProjectKeyDefines,

View File

@ -9,6 +9,7 @@ _auNamespacesEmitted = {}
_auResolvedDep = {} _auResolvedDep = {}
_auCurrentProject = {} _auCurrentProject = {}
_auCurrentBaseProject = {} _auCurrentBaseProject = {}
_auFatalMsg = {}
------------------------------------------------------- -------------------------------------------------------
-- utils -- utils
@ -321,6 +322,7 @@ processProject = function(name, required, noNs)
_auFatalMsg = {} _auFatalMsg = {}
_auFatalMsg["processing project"] = a.info.name _auFatalMsg["processing project"] = a.info.name
a.processor:process() a.processor:process()
_auFatalMsg = {}
end) end)
-- cont -- cont
@ -409,10 +411,9 @@ local function includeAuProject(dep, soft)
end end
pushProject(a, function() pushProject(a, function()
_auFatalMsg = {}
_auFatalMsg["processing project ref"] = a.info.name _auFatalMsg["processing project ref"] = a.info.name
processor:handleReference(isWeakCircularReference(dep))
processor:handleReference(isWeakCircularReference(dep)) _auFatalMsg["processing project ref"] = nil
end) end)
return true return true
end end
@ -443,9 +444,9 @@ local function linkAuProject(dep, soft)
--if (not processor:getMeta().isStatic) then --if (not processor:getMeta().isStatic) then
pushProject(a, function() pushProject(a, function()
_auFatalMsg = {}
_auFatalMsg["processing project link"] = a.info.name _auFatalMsg["processing project link"] = a.info.name
processor:handleLink() processor:handleLink()
_auFatalMsg["processing project link"] = nil
end) end)
--end --end
return true return true

View File

@ -8,7 +8,7 @@ function auAddBuildAction(...)
buildAction(...) buildAction(...)
end end
function auAddBuildAction(...) function auAddBuildActionO(...)
local type = { local type = {
-- stage: pre, post -- stage: pre, post
-- filter: ... -- filter: ...

View File

@ -8,7 +8,7 @@ function auBuildActionO()
return { return {
stage = "post", -- pre, post, stage = "post", -- pre, post,
-- filter: ..., -- filter: ...,
-- lua/bin/targetName/command: relative path - lua script; relative path - executable; project name; command line -- lua/bin/project/cmd: relative path - lua script; relative path - executable; project name; command line
-- args: lua private passthrough; binary or target name command args -- args: lua private passthrough; binary or target name command args
cwd = "sln" -- sln, prj cwd = "sln" -- sln, prj
} }

View File

@ -1,3 +1,4 @@
print("hello paths")
if (not Aurora.Settings.sAbsRoot) then if (not Aurora.Settings.sAbsRoot) then
Aurora.Settings.sAbsRoot = os.realpath(os.getcwd() .. "/../..") .. "/" Aurora.Settings.sAbsRoot = os.realpath(os.getcwd() .. "/../..") .. "/"
@ -21,11 +22,17 @@ end
local function resolvePathAbs(key) local function resolvePathAbs(key)
local path = resolvePathAbs2(key, "sAbsRoot") local path = resolvePathAbs2(key, "sAbsRoot")
if (not path) then
return
end
if (not os.isdir(path)) then if (not os.isdir(path)) then
os.mkdir(path) os.mkdir(path)
end end
end end
resolvePathAbs("sRelDebug") resolvePathAbs("sRelDebug")
resolvePathAbs("sRelStage") resolvePathAbs("sRelStage")
resolvePathAbs("sRelShip") resolvePathAbs("sRelShip")
@ -34,6 +41,7 @@ resolvePathAbs("sRelSymbols")
resolvePathAbs("sRelLinkLibs") resolvePathAbs("sRelLinkLibs")
resolvePathAbs("sRelCompilerWd") resolvePathAbs("sRelCompilerWd")
local function resolveAuPathAbs(key) local function resolveAuPathAbs(key)
return resolvePathAbs2(key, "sAbsAuRoot") return resolvePathAbs2(key, "sAbsAuRoot")
end end