299 lines
8.5 KiB
Lua
299 lines
8.5 KiB
Lua
local buildHooks = require("Core/BuildHooks")
|
|
local targetingCmake = false
|
|
local targetingWindows = os.host() == "windows"
|
|
local bugHack = targetingCmake or targetingWindows
|
|
|
|
local kPathPrefix = "!"
|
|
|
|
local addDest = function(name, projectType, dest)
|
|
buildHooks.addDest(name, projectType, dest)
|
|
end
|
|
|
|
local function configureProjectForSolution(prj)
|
|
filter(auFilterConfig(Aurora.Settings.sNameOfDebug))
|
|
defines { "DEBUG" }
|
|
targetdir(Aurora.Settings.sAbsCompilerWd .. "/Bin/" .. Aurora.Settings.sNameOfDebug)
|
|
debugdir(Aurora.Settings.sAbsDebug)
|
|
flags "NoIncrementalLink"
|
|
|
|
filter(auFilterConfig({Aurora.Settings.sNameOfInternal, Aurora.Settings.sNameOfShip}))
|
|
defines { "NDEBUG" }
|
|
optimize "Speed"
|
|
|
|
filter(auFilterConfig(Aurora.Settings.sNameOfInternal))
|
|
defines { "STAGING" }
|
|
targetdir(Aurora.Settings.sAbsCompilerWd .. "/Bin/" .. Aurora.Settings.sNameOfInternal)
|
|
debugdir(Aurora.Settings.sAbsStage)
|
|
flags "NoIncrementalLink"
|
|
|
|
filter(auFilterConfig(Aurora.Settings.sNameOfShip))
|
|
defines { "SHIP" }
|
|
targetdir(Aurora.Settings.sAbsCompilerWd .. "/Bin/" .. Aurora.Settings.sNameOfShip)
|
|
debugdir(Aurora.Settings.sAbsShip)
|
|
flags "LinkTimeOptimization"
|
|
filter {}
|
|
|
|
auFilterForConfigPlatforms(function(config, platformName, arch)
|
|
if (Aurora.Settings.bDefinePartialABIInTargetName) then
|
|
targetname(string.format("%s.%s.%s.%s", prj.name, config, platformName:gsub("^%l", string.upper), arch))
|
|
end
|
|
|
|
if (not(config == Aurora.Settings.sNameOfShip)) then return end
|
|
local platform = Aurora.Platforms[platformName]
|
|
|
|
if (platform.requiresElfStrip and not platform.supportsElfStrip) then
|
|
symbols "Off"
|
|
end
|
|
end)
|
|
end
|
|
|
|
local function setBestDebugDir(dest)
|
|
if (not dest or dest:starts(kPathPrefix)) then
|
|
local append = dest and dest:sub(#kPathPrefix + 1)
|
|
if (not append) then append = "" end
|
|
|
|
filter("configurations:" .. Aurora.Settings.sNameOfDebug)
|
|
debugdir(Aurora.Settings.sAbsDebug .. "/" .. append)
|
|
|
|
filter("configurations:" .. Aurora.Settings.sNameOfInternal)
|
|
debugdir(Aurora.Settings.sAbsStage .. "/" .. append)
|
|
|
|
filter("configurations:" .. Aurora.Settings.sNameOfShip)
|
|
debugdir(Aurora.Settings.sAbsShip .. "/" .. append)
|
|
|
|
filter {}
|
|
else
|
|
debugdir(auGetRoot() .. dest)
|
|
end
|
|
end
|
|
|
|
local function configureProjectForCompiler()
|
|
if (targetingCmake) then
|
|
filter {"toolset:msc"}
|
|
end
|
|
|
|
if (bugHack) then
|
|
buildoptions {"-utf-8"}
|
|
end
|
|
|
|
if (targetingCmake) then
|
|
filter {"toolset:msc", "files:**.cpp or files:**.cc or files:**.cxx"}
|
|
elseif (bugHack) then
|
|
filter {"files:**.cpp or files:**.cc or files:**.cxx"}
|
|
end
|
|
|
|
if (bugHack) then
|
|
buildoptions {"/experimental:module-", "/Zc:__cplusplus"}
|
|
end
|
|
|
|
filter {}
|
|
end
|
|
|
|
local function configureProjectForPlatform(platform, projType)
|
|
if (platform == "win32") then
|
|
|
|
characterset(Aurora.Settings.sMsvcDefCharset)
|
|
staticruntime("Off")
|
|
|
|
if (Aurora.Settings.bHotswap) then
|
|
justmycode("On")
|
|
else
|
|
justmycode("Off")
|
|
end
|
|
|
|
defines "_CRT_SECURE_NO_WARNINGS"
|
|
else
|
|
if ((projectType == "SharedLib") or
|
|
(projectType == "StaticLib")) then
|
|
pic "On"
|
|
end
|
|
end
|
|
end
|
|
|
|
local function configureProjectForPlatforms(projType)
|
|
auFilterForPlatforms(function(platformName)
|
|
configureProjectForPlatform(platformName, projType)
|
|
end)
|
|
end
|
|
|
|
local function configureProjectErrors()
|
|
if (not Aurora.Settings.bDisableWarningsThatAnnoyRec) then
|
|
return
|
|
end
|
|
|
|
filter {"toolset:clang"}
|
|
buildoptions {"-fms-extensions"}
|
|
|
|
disablewarnings
|
|
{
|
|
-- we live life on the edge
|
|
"unused-result",
|
|
|
|
-- warning: unused unused enumeration
|
|
"unused-value",
|
|
|
|
-- :(
|
|
"unknown-warning-option"
|
|
}
|
|
|
|
filter{}
|
|
|
|
if (targetingCmake) then
|
|
filter {"toolset:msc"}
|
|
end
|
|
|
|
if (bugHack) then
|
|
disablewarnings
|
|
{
|
|
"4996", -- The whiny C99 is no longer supported nag
|
|
-- please needlessly use '_s' and '_'d functions __error__
|
|
|
|
|
|
"4251", -- MSVC's hurrdurr abis will break if you dynamically link classes
|
|
-- counter: sod off again. we have full control of the build process, and we only link against
|
|
-- dynamic c/stl runtimes. which brainlet thought this was a good idea?
|
|
-- even microsofts own documentation dont state what is guaranteed to be safe.
|
|
-- dont mix optimizations, mitigation flags, and so on.
|
|
-- rtti works; the stl doesn't abuse inline/module specific globals; who cares?
|
|
|
|
"4244" -- conversion from 'double' to 'float', possible loss of data
|
|
-- this warning is extremely important; however, we're developing a game engine and utilities
|
|
-- pragma warning push + disable + pop and/or static_casts to hint we expect floating point precision
|
|
-- loss is extremely annoying and impractical. further, projects including harfbuzz, freetype,
|
|
-- and v8 don't seem to care about this warning either
|
|
}
|
|
end
|
|
|
|
filter {}
|
|
end
|
|
|
|
local function configureProjectForDebug(prj)
|
|
local debugDir = nil
|
|
|
|
if (type(prj.dest) == "string") then
|
|
debugDir = prj.dest
|
|
end
|
|
|
|
if (type(prj.dest) == "table") then
|
|
debugDir = prj.dest[1]
|
|
end
|
|
|
|
setBestDebugDir(debugDir)
|
|
end
|
|
|
|
local function configureProjectForTarget()
|
|
auRequire("Core/Target").startProject()
|
|
end
|
|
|
|
local function setupProject(prj)
|
|
print("project", prj.name)
|
|
|
|
project(prj.name)
|
|
language("C++") -- C and MASM drivers are still available to files requiring different compilers
|
|
|
|
targetname(prj.name) -- TODO (reece): you know what to do
|
|
kind(prj.projectType)
|
|
|
|
cppdialect(Aurora.Settings.sCppVersion)
|
|
targetprefix(Aurora.Settings.sLibPrefix)
|
|
|
|
objdir(Aurora.Settings.sAbsCompilerWd .. "/" .. prj.name)
|
|
|
|
configureProjectForSolution(prj)
|
|
configureProjectErrors()
|
|
configureProjectForCompiler()
|
|
configureProjectForPlatforms(prj.projectType)
|
|
configureProjectForTarget()
|
|
configureProjectForDebug(prj)
|
|
|
|
defines "_AU_HAS_ATOMIC_INTRINS"
|
|
defines("_AU_BUILDING_" .. string.upper(prj.projectType))
|
|
|
|
if (prj.root) then
|
|
location(prj.root)
|
|
else
|
|
location(os.getcwd())
|
|
end
|
|
|
|
defines
|
|
{
|
|
"_ITERATOR_DEBUG_LEVEL=0",
|
|
}
|
|
|
|
if (Aurora.Settings.bIncludeAuIncludeIfExists) then
|
|
local commonInclude = auGetRoot() .. "/Include"
|
|
if (os.isdir(commonInclude)) then
|
|
includedirs(commonInclude)
|
|
files(commonInclude .. "/**.h*")
|
|
end
|
|
end
|
|
|
|
-- add includes, if available
|
|
auForEach(prj.inc, function(path)
|
|
print("", "include", _G.path.normalize(path))
|
|
includedirs(path)
|
|
|
|
files(path .. "/**.h")
|
|
files(path .. "/**.hpp")
|
|
files(path .. "/**.inl")
|
|
end)
|
|
|
|
-- add sources, if available
|
|
auForEach(prj.src, function(path, root)
|
|
print("", "source", _G.path.normalize(path))
|
|
|
|
--if (string.sub(path, -2) == ".*") then
|
|
if (string.find(path, "*")) then
|
|
files {path}
|
|
return
|
|
end
|
|
|
|
if (os.isfile(path)) then
|
|
files {path}
|
|
return
|
|
end
|
|
|
|
if (not root) then
|
|
includedirs(path)
|
|
end
|
|
|
|
files
|
|
{
|
|
path .. "/**.*pp",
|
|
path .. "/**.inl",
|
|
path .. "/**.c",
|
|
path .. "/**.cc",
|
|
path .. "/**.cxx",
|
|
path .. "/**.h",
|
|
path .. "/**.masm" -- required explicitly
|
|
}
|
|
end, root)
|
|
|
|
buildHooks.startProject(prj.name, prj.projectType)
|
|
|
|
auForEach(prj.dest, function(v)
|
|
addDest(prj.name, prj.projectType, v)
|
|
end)
|
|
|
|
print()
|
|
end
|
|
|
|
local function setupProjectCompat(name, projectType, src, inc, dest, root)
|
|
local project =
|
|
{
|
|
name = name,
|
|
projectType = projectType,
|
|
src = src,
|
|
inc = inc,
|
|
dest = dest,
|
|
root = root
|
|
}
|
|
|
|
setupProject(project)
|
|
end
|
|
|
|
return
|
|
{
|
|
setupProjectCompat = setupProjectCompat,
|
|
startProject = setupProject
|
|
} |