Build/Core/Actions/buildActionBootstrap.lua

153 lines
3.4 KiB
Lua
Raw Normal View History

local aurora = {}
_G["Aurora"] = aurora
function auFetchGlobal(name)
local ret = aurora[name] or {}
aurora[name] = ret
return ret
end
local function escapeBinaryPath(path)
if (os.host() == "windows") then
return "\"" .. path .. "\""
end
return path:gsub(" ", "\\ ")
end
require("./../../Utilities/Utilities")
local triggers =
{
"binscript",
"luascript",
"cwd",
2021-11-21 17:23:31 +00:00
"cmd",
"settings",
"project_name",
"project_arch",
"project_platform",
"project_root",
"additional",
"project_type",
"luaabsscript",
"projectname_",
"projectbins_",
"projectnameex_",
"project_config",
"project_name"
}
auForEach(triggers, function(trigger)
newoption
{
trigger = trigger,
description = ""
}
end)
local settings = _OPTIONS["settings"]
if (settings) then
Aurora.Settings = json.decode(base64.decode(settings))
require("./../../Public/paths")
end
require("./../Target/platform")
local preconfig = path.join(Aurora.Settings.sAbsRoot, "preconfig.lua")
if (os.isfile(preconfig)) then
auRequireAbs(preconfig)
end
local projRoot = path.join(Aurora.Settings.sAbsRoot, _OPTIONS["project_root"] or "./")
local projectBins = _OPTIONS["projectbins_"]
if (projectBins) then
projectBins = os.realpath(path.join(projRoot, projectBins))
end
local cwd = _OPTIONS["cwd"]
if (cwd) then
os.chdir(projRoot)
else
os.chdir(Aurora.Settings.sAbsRoot)
2021-11-21 17:23:31 +00:00
end
local args = _OPTIONS["additional"]
if (args) then
args = base64.decode(args)
end
2021-11-21 17:23:31 +00:00
local binSuffx = ""
if (args) then
binSuffx = " " .. args
2021-11-21 17:23:31 +00:00
end
local binScript = _OPTIONS["binscript"]
if (binScript) then
os.exit(os.execute(path.join(Aurora.Settings.sAbsRoot, binScript) .. binSuffx))
end
local cmd = _OPTIONS["cmd"]
if (cmd) then
os.exit(os.execute(base64.decode(cmd)))
2021-11-21 17:23:31 +00:00
end
local projName = _OPTIONS["project_name"]
local projType = _OPTIONS["project_type"]
local projPlatform = _OPTIONS["project_platform"]
local projCfg = _OPTIONS["project_config"]
local projArch = _OPTIONS["project_arch"]
if (string.find(projCfg, "|")) then
projCfg = projCfg:match("([^,]+)|([^,]+)")
end
local targetName = string.format("%s.%s.%s.%s", projName, projCfg, projPlatform, projArch)
local fileName = targetName
local platform = Aurora.Platforms[projPlatform]
if (platform) then
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
auBuild =
{
platform = projPlatform,
architecture = projArch,
projectName = projName,
projectType = projType,
projectRoot = projRoot,
projectTargetName = targetName,
projectTargetFileName = fileName,
args = args,
root = cwd
}
local luaScript = _OPTIONS["luascript"]
local luaAbsScript = _OPTIONS["luaabsscript"]
if (luaScript) then
auRequireAbs(path.join(Aurora.Settings.sAbsRepoScripts, luaScript))
elseif (luaAbsScript) then
auRequireAbs(path.join(Aurora.Settings.sAbsRoot, luaAbsScript))
end
os.exit()