2021-11-13 08:31:32 +00:00
|
|
|
local isUnixPremake = os.host() == "linux" or os.host() == "mac"
|
|
|
|
local isCmakeToolChain = false
|
|
|
|
|
|
|
|
local getPremakeExec = function()
|
|
|
|
if (isCmakeToolChain) then
|
2022-03-06 19:07:32 +00:00
|
|
|
return Aurora.Settings.sDefaultCmakePremakeBin
|
2021-11-13 08:31:32 +00:00
|
|
|
end
|
|
|
|
|
2022-03-06 19:07:32 +00:00
|
|
|
return _PREMAKE_COMMAND
|
2021-11-13 08:31:32 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
local addBuildCommand = function(when, scriptType, path, cwdRelToProject, args)
|
2022-03-04 17:05:38 +00:00
|
|
|
|
2021-11-13 08:31:32 +00:00
|
|
|
local scriptPath = path
|
|
|
|
local cwd = auGetRoot()
|
|
|
|
|
|
|
|
local host = os.host()
|
|
|
|
local cdAware = isUnixPremake
|
|
|
|
|
|
|
|
local command = ""
|
|
|
|
|
|
|
|
if (isCmakeToolChain) then
|
|
|
|
command = ""
|
|
|
|
elseif (cdAware) then
|
|
|
|
command = "cd \"" .. cwd .. "\" && "
|
|
|
|
elseif (host == "windows") then
|
|
|
|
command = "call "
|
|
|
|
end
|
|
|
|
|
2022-01-17 22:12:51 +00:00
|
|
|
local cur = auGetCurrentProjectMeta()
|
2021-11-13 08:31:32 +00:00
|
|
|
command = command .. getPremakeExec()
|
|
|
|
|
|
|
|
local oldBootstrapPrefix = Aurora.Settings.sAbsRepoScripts
|
|
|
|
|
2022-03-04 17:05:38 +00:00
|
|
|
local bootstrap = Aurora.Settings.sAbsScripts .. "/Core/Actions/buildActionBootstrap.lua"
|
|
|
|
command = command .. " --file=\"" .. os.realpath(bootstrap) .. "\""
|
2021-11-13 08:31:32 +00:00
|
|
|
|
|
|
|
--command = command .. " --project_name=\"%{prj.name}\""
|
|
|
|
command = command .. " --project_name=\"" .. cur.name .. "\""
|
|
|
|
command = command .. " --project_type=\"" .. cur.projectType .. "\""
|
2022-03-04 17:05:38 +00:00
|
|
|
command = command .. " --project_config=\"%{cfg.longname}\""
|
2021-11-13 08:31:32 +00:00
|
|
|
command = command .. " --project_arch=\"%{cfg.architecture}\""
|
2022-03-04 17:05:38 +00:00
|
|
|
command = command .. " --project_platform=\"%{cfg.platform}\""
|
2021-11-13 08:31:32 +00:00
|
|
|
|
|
|
|
-- 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
|
|
|
|
-- Abs can be skipped and i really dont believe we need the other settings
|
|
|
|
local settings =
|
|
|
|
{
|
|
|
|
sAbsRoot = Aurora.Settings.sAbsRoot,
|
|
|
|
sRelAuRoot = Aurora.Settings.sRelAuRoot,
|
|
|
|
sRelScripts = Aurora.Settings.sRelScripts,
|
|
|
|
sRelRepoScripts = Aurora.Settings.sRelRepoScripts,
|
|
|
|
sRelDebug = Aurora.Settings.sRelDebug,
|
|
|
|
sRelStage = Aurora.Settings.sRelStage,
|
|
|
|
sRelShip = Aurora.Settings.sRelShip,
|
|
|
|
sRelWd = Aurora.Settings.sRelWd,
|
|
|
|
sRelSymbols = Aurora.Settings.sRelSymbols,
|
2022-03-04 17:27:24 +00:00
|
|
|
sRelLinkLibs = Aurora.Settings.sRelLinkLibs,
|
2022-03-06 15:17:50 +00:00
|
|
|
sRelCompilerWd = Aurora.Settings.sRelCompilerWd,
|
|
|
|
sRelWin32 = Aurora.Settings.sRelWin32,
|
|
|
|
sRelUnixBins = Aurora.Settings.sRelUnixBins,
|
2021-11-13 08:31:32 +00:00
|
|
|
}
|
|
|
|
command = command .. " --settings=" .. base64.encode(json.encode(settings))
|
|
|
|
|
|
|
|
-- the last thing i couldn't port
|
|
|
|
-- we don't need it
|
|
|
|
--if (when == "post") then
|
|
|
|
-- local postBuildSuffix = " --cur_binary=\"%{cfg.buildtarget.abspath}\""
|
|
|
|
-- command = command .. postBuildSuffix
|
|
|
|
--end
|
|
|
|
|
|
|
|
if (cwdRelToProject) then
|
|
|
|
command = command .. " --cwd"
|
|
|
|
end
|
|
|
|
|
2022-03-05 19:34:41 +00:00
|
|
|
local slow = nil
|
|
|
|
|
2021-11-13 08:31:32 +00:00
|
|
|
if (cur and cur.path) then
|
2022-03-05 19:34:41 +00:00
|
|
|
slow = _G.path.join(cur.path, path)
|
2021-11-13 08:31:32 +00:00
|
|
|
command = command .. " --project_root=\"" .. _G.path.getrelative(settings.sAbsRoot, cur.path) .. "\""
|
|
|
|
end
|
|
|
|
|
|
|
|
if (args) then
|
2022-03-05 19:34:41 +00:00
|
|
|
local buf = json.encode(args)
|
2022-03-04 17:27:24 +00:00
|
|
|
local hash = string.sha1(buf)
|
|
|
|
io.writefile(_G.path.join(Aurora.Settings.sAbsCompilerWd, hash .. ".args"), buf)
|
|
|
|
command = command .. " --additional=\"" .. hash .. "\""
|
2022-03-04 17:05:38 +00:00
|
|
|
end
|
|
|
|
|
2021-11-13 08:31:32 +00:00
|
|
|
if (scriptType == "lua") then
|
2022-03-05 19:34:41 +00:00
|
|
|
if (os.isfile(_G.path.join(Aurora.Settings.sAbsRepoScripts, path))) then
|
2021-11-13 08:31:32 +00:00
|
|
|
command = command .. " --luascript=\"" .. path .. "\""
|
2022-03-05 19:34:41 +00:00
|
|
|
elseif (slow and os.isfile(slow)) then
|
|
|
|
command = command .. " --luaabsscript=\"" .. _G.path.getrelative(settings.sAbsRoot, slow) .. "\""
|
2021-11-13 08:31:32 +00:00
|
|
|
else
|
|
|
|
command = command .. " --luaabsscript=\"" .. _G.path.getrelative(settings.sAbsRoot, path) .. "\""
|
|
|
|
end
|
|
|
|
|
2022-03-04 17:05:38 +00:00
|
|
|
|
2021-11-13 08:31:32 +00:00
|
|
|
elseif (scriptType == "bin") then
|
2022-03-05 19:34:41 +00:00
|
|
|
command = command .. " --binscript=\"" .. _G.path.getrelative(settings.sAbsRoot, path) .. "\""
|
2022-03-04 17:05:38 +00:00
|
|
|
|
|
|
|
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)
|
|
|
|
|
2021-11-13 08:31:32 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
if (when == "post") then
|
|
|
|
postbuildcommands(command)
|
|
|
|
elseif (when == "pre") then
|
|
|
|
prebuildcommands(command)
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
return addBuildCommand
|