2021-11-13 08:31:32 +00:00
|
|
|
local kPathPrefix = "!"
|
|
|
|
|
|
|
|
local function normalizeCpyPath(absPath)
|
|
|
|
return "../../" .. path.getrelative(Aurora.Settings.sAbsRoot, absPath)
|
|
|
|
end
|
|
|
|
|
|
|
|
-- file name, type, directory, extension, is windows, configuration, real name
|
|
|
|
local function formatCpy(name, type, dir, ex, iswin, config, platformName, arch, realName)
|
|
|
|
local pathSuffix = "";
|
|
|
|
|
|
|
|
if (iswin) then
|
|
|
|
pathSuffix = "*\"";
|
|
|
|
else
|
|
|
|
pathSuffix = "\"";
|
|
|
|
end
|
|
|
|
|
|
|
|
if (Aurora.Settings.bDefinePartialABIInTargetName) then
|
|
|
|
name = string.format("%s.%s.%s.%s", name, config, platformName:gsub("^%l", string.upper), arch)
|
|
|
|
end
|
|
|
|
|
|
|
|
local outputPath = string.format("%s/%s%s", dir, name, ex)
|
|
|
|
local outputTarget = string.format("%s/%s", dir, name)
|
|
|
|
local uglyBuildPath = string.format("%%{cfg.targetdir}/%s%s", name, ex)
|
|
|
|
|
|
|
|
return string.format("{COPY} \"%s\" \"%s%s", uglyBuildPath, outputPath, pathSuffix), outputPath, uglyBuildPath
|
|
|
|
end
|
|
|
|
|
|
|
|
local function gnuCoreUtilsMkdirRecursive(dir)
|
|
|
|
return string.format("mkdir -p \"%s\"", dir);
|
|
|
|
end
|
|
|
|
|
|
|
|
local function archiveShipPdb(pdbPath)
|
|
|
|
-- TODO (reece):
|
|
|
|
end
|
|
|
|
|
|
|
|
local function addUserDestCopy(name, type, config, platformName, arch, dir)
|
|
|
|
local isWin = platformName == "win32"
|
|
|
|
local debugSymbolPath = nil
|
|
|
|
|
|
|
|
local platform = Aurora.Platforms[platformName]
|
|
|
|
if (not platform) then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
local ext = (platform.exts or {})[type] or ""
|
|
|
|
|
|
|
|
local copy, outputPath, file = formatCpy(Aurora.Settings.sLibPrefix .. name, type, dir, ext, isWin, config, platformName, arch, name)
|
|
|
|
|
2021-11-14 16:38:07 +00:00
|
|
|
if (platform.devChainCoreUtils) then
|
2021-11-13 08:31:32 +00:00
|
|
|
gnuCoreUtilsMkdirRecursive(dir)
|
|
|
|
end
|
|
|
|
|
2021-11-14 16:38:07 +00:00
|
|
|
if (platform.devChainRequiresElfStrip and
|
|
|
|
platform.devChainSupportsElfStrip and
|
|
|
|
config ~= Aurora.Settings.sNameOfDebug) then
|
2021-11-13 08:31:32 +00:00
|
|
|
local debugSymbolPath = normalizeCpyPath(Aurora.Settings.sAbsSymbols) .. "/" .. name .. ".dwarf"
|
|
|
|
postbuildcommands("objcopy --strip-debug " .. file .. " " .. outputPath)
|
2021-11-14 16:38:07 +00:00
|
|
|
if (Aurora.Settings.bUseAuBuildHooks and config ~= Aurora.Settings.sNameOfShip) then
|
2021-11-13 08:31:32 +00:00
|
|
|
postbuildcommands("objcopy --add-gnu-debuglink=" .. debugSymbolPath .. " " .. outputPath)
|
|
|
|
end
|
|
|
|
else
|
|
|
|
postbuildcommands(copy)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
local function addDest(name, projectType, dest)
|
|
|
|
local lookup = {}
|
|
|
|
local append = ""
|
|
|
|
|
|
|
|
if (dest:starts(kPathPrefix)) then
|
|
|
|
append = dest:sub(#kPathPrefix + 1)
|
|
|
|
local fu = auFilterConfig(Aurora.Settings.sNameOfDebug)
|
|
|
|
|
|
|
|
lookup[Aurora.Settings.sNameOfDebug] = normalizeCpyPath(Aurora.Settings.sAbsDebug)
|
|
|
|
lookup[Aurora.Settings.sNameOfInternal] = normalizeCpyPath(Aurora.Settings.sAbsStage)
|
|
|
|
lookup[Aurora.Settings.sNameOfShip] = normalizeCpyPath(Aurora.Settings.sAbsShip)
|
|
|
|
else
|
|
|
|
lookup[Aurora.Settings.sNameOfDebug] = dest
|
|
|
|
lookup[Aurora.Settings.sNameOfInternal] = dest
|
|
|
|
lookup[Aurora.Settings.sNameOfShip] = dest
|
|
|
|
end
|
|
|
|
|
|
|
|
auFilterForConfigPlatforms(function(config, platform, arch)
|
|
|
|
addUserDestCopy(name, projectType, config, platform, arch, lookup[config] .. append)
|
|
|
|
end)
|
|
|
|
end
|
|
|
|
|
|
|
|
local function postBuildCommands(name, type, config, platformName, arch)
|
2021-11-14 21:13:52 +00:00
|
|
|
local isWin = platformName == "win32"
|
|
|
|
|
2021-11-13 08:31:32 +00:00
|
|
|
if (isWin) then
|
|
|
|
postbuildcommands(formatCpy(Aurora.Settings.sLibPrefix .. name, type, normalizeCpyPath(Aurora.Settings.sAbsSymbols), ".pdb", true, config, platformName, arch, name))
|
|
|
|
|
|
|
|
if (type == "SharedLib" or
|
|
|
|
type == "StaticLib") then
|
|
|
|
postbuildcommands(formatCpy(Aurora.Settings.sLibPrefix .. name, type, normalizeCpyPath(Aurora.Settings.sRelLinkLibs), ".lib", true, config, platformName, arch, name))
|
|
|
|
end
|
|
|
|
else
|
|
|
|
if (type == "SharedLib" or
|
|
|
|
type == "StaticLib") then
|
|
|
|
postbuildcommands(formatCpy(Aurora.Settings.sLibPrefix .. name, type, normalizeCpyPath(Aurora.Settings.sRelLinkLibs), ext, true, config, platformName, arch, name))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-11-14 16:38:07 +00:00
|
|
|
if (config ~= Aurora.Settings.sNameOfDebug) then
|
|
|
|
local platform = Aurora.Platforms[platformName]
|
|
|
|
if (not platform) then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2021-11-13 08:31:32 +00:00
|
|
|
local debugSymbolPath = nil
|
|
|
|
|
2021-11-14 16:38:07 +00:00
|
|
|
if (platform.devChainRequiresElfStrip and
|
|
|
|
platform.devChainSupportsElfStrip) then
|
2021-11-13 08:31:32 +00:00
|
|
|
debugSymbolPath = normalizeCpyPath(Aurora.Settings.sAbsSymbols) .. "/" .. name .. ".dwarf"
|
|
|
|
postbuildcommands("objcopy --only-keep-debug " .. file .. " " .. debugSymbolPath)
|
2021-11-14 16:38:07 +00:00
|
|
|
elseif (isWin) then
|
2021-11-13 08:31:32 +00:00
|
|
|
debugSymbolPath = normalizeCpyPath(Aurora.Settings.sAbsSymbols) .. "/" .. name .. ".pdb"
|
|
|
|
end
|
|
|
|
|
2021-11-14 16:38:07 +00:00
|
|
|
if (debugSymbolPath and
|
|
|
|
config == Aurora.Settings.sNameOfShip) then
|
2021-11-13 08:31:32 +00:00
|
|
|
archiveShipPdb(debugSymbolPath)
|
|
|
|
end
|
|
|
|
else
|
|
|
|
postbuildcommands(copy)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-11-14 21:13:52 +00:00
|
|
|
local function startProject(name, projectType)
|
2021-11-13 08:31:32 +00:00
|
|
|
if (not Aurora.Settings.bUseAuBuildHooks) then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
auFilterForConfigPlatforms(function(config, platform, arch)
|
|
|
|
postBuildCommands(name, projectType, config, platform, arch)
|
|
|
|
end)
|
|
|
|
end
|
|
|
|
|
|
|
|
return {
|
|
|
|
startProject = startProject,
|
|
|
|
addDest = addDest
|
|
|
|
}
|