Reece
9f5fa6d8e4
-> Consider libraries that require some kind of static initialization -> Used for AuroraRuntime c++ allocator overloads [*] Fix copy by abs
189 lines
5.3 KiB
Lua
189 lines
5.3 KiB
Lua
local defintions = require("preprocessors")
|
|
local projectCopyCmds = require("buildPostProcess")
|
|
|
|
local kPathPrefix = "[BUILD_PATH]"
|
|
|
|
local addDest = function(name, projectType, dest)
|
|
if (dest:starts(kPathPrefix)) then
|
|
local append = dest:sub(#kPathPrefix + 1)
|
|
|
|
filter "configurations:Debug"
|
|
projectCopyCmds(name, projectType, "debug", getroot() .. "/Build_Develop/" .. append)
|
|
|
|
filter "configurations:Release"
|
|
projectCopyCmds(name, projectType, "release", getroot() .. "/Build_Stage/" .. append)
|
|
|
|
filter "configurations:Ship"
|
|
projectCopyCmds(name, projectType, "ship", getroot() .. "/Build_Ship/" .. append)
|
|
|
|
filter {}
|
|
else
|
|
filter "configurations:Debug"
|
|
projectCopyCmds(name, projectType, "debug", dest)
|
|
|
|
filter "configurations:Release"
|
|
projectCopyCmds(name, projectType, "release", dest)
|
|
|
|
filter "configurations:Ship"
|
|
projectCopyCmds(name, projectType, "ship", dest)
|
|
|
|
filter {}
|
|
end
|
|
end
|
|
|
|
local setBestDebugDir = function(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:Debug"
|
|
debugdir(getroot() .. "/Build_Develop/" .. append)
|
|
|
|
filter "configurations:Release"
|
|
debugdir(getroot() .. "/Build_Stage/" .. append)
|
|
|
|
filter "configurations:Ship"
|
|
debugdir(getroot() .. "/Build_Ship/" .. append)
|
|
|
|
filter {}
|
|
else
|
|
local path = getroot() .. dest
|
|
|
|
debugdir(path)
|
|
end
|
|
end
|
|
|
|
local boilerplateProject = function(name, projectType, src, inc, dest, root)
|
|
print("project", name)
|
|
project(name)
|
|
|
|
targetname(name)
|
|
language("C++") -- C and MASM compiler overloads are still available to files requiring different compilers
|
|
cppdialect("C++20")
|
|
|
|
if (usingMSVC) then
|
|
filter {"files:**.cpp or files:**.cc"}
|
|
buildoptions {"/experimental:module-", "/Zc:__cplusplus"}
|
|
filter {}
|
|
end
|
|
|
|
kind(projectType)
|
|
|
|
buildoptions {"-utf-8"}
|
|
targetprefix ""
|
|
|
|
if (not _G.win32) then
|
|
if ((projectType == "SharedLib") or
|
|
(projectType == "StaticLib")) then
|
|
pic "On"
|
|
|
|
if (usingGXX) then
|
|
-- TODO: we dont actually support gxx
|
|
-- We expect clang or msvc
|
|
-- msvcs thread local is fine, windows has always had decent thread in/out callbacks
|
|
-- clang has a cross platform, per variable solution
|
|
-- -> `__thread <type> <name> __attribute__((tls_model("initial-exec")));`
|
|
-- initial-exec is recommended when pic is on. does not work for dynamically loaded modules
|
|
buildoptions{"-ftls-model=initial-exec"}
|
|
end
|
|
end
|
|
end
|
|
|
|
if (_G.win32) then
|
|
characterset("MBCS")
|
|
staticruntime("Off")
|
|
end
|
|
|
|
objdir(getroot() .. "/Build_CompilerWorkingDirectory/" .. name)
|
|
|
|
if (root) then
|
|
location(root)
|
|
else
|
|
location(os.getcwd())
|
|
end
|
|
|
|
-- V8 takes minutes to start up on an i9-9900k, QST/VM tests result in highs of ~30MB/s from 900MB/s
|
|
-- In place of page NX traps and suspending thread contexts like most debug operations,
|
|
-- they perform an expensive check in each functions prologue :vomit:
|
|
-- MSVCs implementation is not fit for use.
|
|
justmycode "Off"
|
|
|
|
-- again, ye no, i would actually like usable debug builds
|
|
defines
|
|
{
|
|
"_ITERATOR_DEBUG_LEVEL=0",
|
|
}
|
|
|
|
-- add defintions
|
|
defines(defintions)
|
|
|
|
local includeCommonBoilerplate = getroot() .. "/Include";
|
|
if (os.isdir(includeCommonBoilerplate)) then
|
|
includedirs(includeCommonBoilerplate)
|
|
files(includeCommonBoilerplate .. "/**.h*")
|
|
end
|
|
|
|
-- add includes, if available
|
|
if inc ~= nil then
|
|
forEach(inc, function(path)
|
|
print("", "include", _G.path.normalize(path))
|
|
includedirs(path)
|
|
|
|
files(path .. "/**.h")
|
|
files(path .. "/**.hpp")
|
|
files(path .. "/**.inl")
|
|
end)
|
|
end
|
|
|
|
-- add sources, if available
|
|
if src ~= nil then
|
|
|
|
annoyingfirst = false
|
|
forEach(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
|
|
|
|
annoyingfirst = true
|
|
|
|
if ((not root) or (root ~= "MAGIC")) then
|
|
includedirs(path)
|
|
end
|
|
|
|
files
|
|
{
|
|
path .. "/**.*pp",
|
|
path .. "/**.inl",
|
|
path .. "/**.c",
|
|
path .. "/**.cc",
|
|
path .. "/**.h",
|
|
path .. "/**.masm"
|
|
}
|
|
end, root)
|
|
end
|
|
|
|
local debugDir = nil
|
|
|
|
if (type(dest) == "string") then debugDir = dest end
|
|
if (type(dest) == "table") then debugDir = dest[1] end
|
|
setBestDebugDir(debugDir)
|
|
|
|
if (dest) then
|
|
forEach(dest, function(v)
|
|
addDest(name, projectType, v)
|
|
end)
|
|
end
|
|
|
|
print()
|
|
end
|
|
|
|
return boilerplateProject |