Unify pre/postbuild json arrays under 'events', improve events cwd selection, update schema

This commit is contained in:
Reece Wilson 2021-05-28 04:36:12 +01:00
parent 3d5cc16ca8
commit 37596a7738
4 changed files with 26 additions and 58 deletions

View File

@ -39,7 +39,7 @@ local getPremakeExec = function()
return premake_exe
end
local addBuildCommand = function(when, scriptType, path)
local addBuildCommand = function(when, scriptType, path, cwdRelToProject)
local scriptPath = path
local cwd = getroot()
@ -51,11 +51,16 @@ local addBuildCommand = function(when, scriptType, path)
command = command .. getPremakeExec()
command = command .. " --file=\"" .. os.realpath(cwd .. "/Build_Scripts/Actions/buildActionBootstrap.lua") .. "\""
command = command .. " --actualcwd=\"" .. os.realpath(cwd) .. "\""
command = command .. " --project_name=\"%{prj.name}\""
command = command .. " --project_arch=\"%{cfg.architecture}\""
command = command .. " --project_platform=\"%{cfg.system}\""
if (cwdRelToProject) then
command = command .. " --actualcwd=\"" .. cur.path .. "\""
else
command = command .. " --actualcwd=\"" .. os.realpath(cwd) .. "\""
end
local cur = getProjectInfo(getCurrentProjectName())
if (cur and cur.path) then
command = command .. " --project_root=\"" .. cur.path .. "\""

View File

@ -48,38 +48,24 @@ newoption
description = ""
}
local binScript = _OPTIONS["binscript"]
if (binScript) then
local command = "";
newoption
{
trigger = "cwd_project_root",
description = ""
}
local cwd =_OPTIONS["actualcwd"]
if (cwd) then
command = command .. string.format("cd \"%s\" && ", cwd:gsub("\\","\\\\"))
end
command = command .. binScript
os.exit(os.execute(command))
local cwd =_OPTIONS["actualcwd"]
if (cwd) then
os.chdir(cwd)
end
local getRoot = function()
local path = os.realpath(os.getcwd())
if (path:ends("/") or path:ends("\\")) then
path = path:sub(1, #path - 1)
end
local binScript = _OPTIONS["binscript"]
if (binScript) then
os.exit(os.execute(binScript))
end
if (path:ends("Actions")) then
path = path:sub(1, #path - #"/Actions")
end
if (path:ends("Build_Scripts")) then
path = path:sub(1, #path - #"/Build_Scripts")
end
return path
end
_G["_overloadRoot"] = getRoot()
_G["_overloadRoot"] = _OPTIONS["actualcwd"]
_G["build"] =
{

View File

@ -55,7 +55,7 @@ function JsonProcessor(info)
tryAddDefine(result.defines)
end
local handlePostBuild = function(obj)
local handleBuildEvent = function(obj)
local type = ""
if ( obj.lua) then
type = "lua"
@ -65,7 +65,7 @@ function JsonProcessor(info)
return
end
addBuildAction(obj.when, type, obj[type])
addBuildAction(obj.when, type, obj[type], obj.isCwdProjRoot)
end
local handleDllImportMaybe = function(this)
@ -264,8 +264,7 @@ function JsonProcessor(info)
end
forEach(result.actions, handleAction, info.path)
forEach(result.postBuild, handlePostBuild, info.path)
forEach(result.preBuild, handlePreBuild, info.path)
forEach(result.events, handleBuildEvent, info.path)
end

View File

@ -120,33 +120,11 @@
}
}
},
"postBuild":
"isCwdProjRoot":
{
"type": "array",
"items":
{
"type": "object",
"properties":
{
"when":
{
"type": "string",
"enum": ["pre", "post"]
},
"lua":
{
"type": "string",
"description": "executes lua script under Build_UserScripts/%s.lua"
},
"bin":
{
"type": "string",
"description": "shell script"
}
}
}
"type": "boolean"
},
"preBuild":
"events":
{
"type": "array",
"items":