149 lines
5.8 KiB
Lua
149 lines
5.8 KiB
Lua
local isUnixPremake = os.host() == "linux" or os.host() == "mac"
|
|
local isCmakeToolChain = false
|
|
local isWin32Make = os.host() == "windows" and _ACTION == "gmake2"
|
|
|
|
local getPremakeExec = function()
|
|
if (isCmakeToolChain) then
|
|
return Aurora.Settings.sDefaultCmakePremakeBin
|
|
end
|
|
|
|
return _PREMAKE_COMMAND
|
|
end
|
|
|
|
local addBuildCommand = function(when, scriptType, path, cwdRelToProject, args)
|
|
|
|
local scriptPath = path
|
|
local cwd = auGetRoot()
|
|
|
|
local host = os.host()
|
|
local cdAware = isUnixPremake
|
|
|
|
local command = ""
|
|
|
|
if (isCmakeToolChain or isWin32Make) then
|
|
command = ""
|
|
elseif (cdAware) then
|
|
command = "cd \"" .. cwd .. "\" && "
|
|
elseif (host == "windows") then
|
|
command = "call "
|
|
end
|
|
|
|
local cur = auGetCurrentProjectMeta()
|
|
command = command .. "\"" .. getPremakeExec() .. "\""
|
|
|
|
local oldBootstrapPrefix = Aurora.Settings.sAbsRepoScripts
|
|
|
|
local bootstrap = Aurora.Settings.sAbsScripts .. "/Core/Actions/buildActionBootstrap.lua"
|
|
command = command .. " --file=\"" .. os.realpath(bootstrap) .. "\""
|
|
|
|
--command = command .. " --project_name=\"%{prj.name}\""
|
|
command = command .. " --project_name=\"" .. cur.name .. "\""
|
|
command = command .. " --project_type=\"" .. cur.projectType .. "\""
|
|
command = command .. " --project_config=\"%{cfg.longname}\""
|
|
command = command .. " --project_arch=\"%{cfg.architecture}\""
|
|
command = command .. " --project_platform=\"%{cfg.platform}\""
|
|
|
|
-- 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 8k limit
|
|
-- Abs can be skipped and i really dont believe we need the other settings
|
|
local settings = {}
|
|
if (Aurora.Settings.bActionsIncludeFull) then
|
|
settings =
|
|
{
|
|
sAbsRoot = Aurora.Settings.sAbsRoot,
|
|
sAbsAuRoot = Aurora.Settings.sAbsAuRoot,
|
|
sAbsScripts = Aurora.Settings.sAbsScripts,
|
|
sAbsRepoScripts = Aurora.Settings.sAbsRepoScripts,
|
|
sAbsDebug = Aurora.Settings.sAbsDebug,
|
|
sAbsStage = Aurora.Settings.sAbsStage,
|
|
sAbsShip = Aurora.Settings.sAbsShip,
|
|
sAbsWd = Aurora.Settings.sAbsWd,
|
|
sAbsSymbols = Aurora.Settings.sAbsSymbols,
|
|
sAbsLinkLibs = Aurora.Settings.sAbsLinkLibs,
|
|
sAbsCompilerWd = Aurora.Settings.sAbsCompilerWd,
|
|
sAbsWin32 = Aurora.Settings.sAbsWin32,
|
|
sAbsUnixBins = Aurora.Settings.sAbsUnixBins,
|
|
sAbsValac = Aurora.Settings.sAbsValac,
|
|
_punchthrough = Aurora.Settings._punchthrough -- for extended user code
|
|
}
|
|
command = command .. " --settings=" .. base64.encode(json.encode(settings))
|
|
else
|
|
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,
|
|
sRelLinkLibs = Aurora.Settings.sRelLinkLibs,
|
|
sRelCompilerWd = Aurora.Settings.sRelCompilerWd,
|
|
sRelWin32 = Aurora.Settings.sRelWin32,
|
|
sRelUnixBins = Aurora.Settings.sRelUnixBins,
|
|
sAbsValac = Aurora.Settings.sAbsValac,
|
|
_punchthrough = Aurora.Settings._punchthrough -- for extended user code
|
|
}
|
|
command = command .. " --settings=" .. base64.encode(json.encode(settings))
|
|
end
|
|
|
|
-- 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
|
|
|
|
local slow = nil
|
|
|
|
if (cur and cur.path) then
|
|
slow = _G.path.join(cur.path, path)
|
|
command = command .. " --project_root=\"" .. _G.path.getrelative(settings.sAbsRoot, cur.path) .. "\""
|
|
end
|
|
|
|
if (args) then
|
|
local buf = json.encode(args)
|
|
local hash = string.sha1(buf)
|
|
io.writefile(_G.path.join(Aurora.Settings.sAbsCompilerWd, hash .. ".args"), buf)
|
|
command = command .. " --additional=\"" .. hash .. "\""
|
|
end
|
|
|
|
if (scriptType == "lua") then
|
|
if (os.isfile(_G.path.join(Aurora.Settings.sAbsRepoScripts, path))) then
|
|
command = command .. " --luascript=\"" .. path .. "\""
|
|
elseif (slow and os.isfile(slow)) then
|
|
command = command .. " --luaabsscript=\"" .. _G.path.getrelative(settings.sAbsRoot, slow) .. "\""
|
|
else
|
|
command = command .. " --luaabsscript=\"" .. _G.path.getrelative(settings.sAbsRoot, path) .. "\""
|
|
end
|
|
|
|
|
|
elseif (scriptType == "bin") then
|
|
command = command .. " --binscript=\"" .. _G.path.getrelative(settings.sAbsRoot, path) .. "\""
|
|
|
|
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
|
|
|
|
if (when == "post") then
|
|
postbuildcommands(command)
|
|
elseif (when == "pre") then
|
|
prebuildcommands(command)
|
|
end
|
|
|
|
end
|
|
|
|
return addBuildCommand |