1
0
Fork 0
spectre/bam.lua

248 lines
5.1 KiB
Lua

--------------------------------
-- --
-- Spectre build config --
-- --
--------------------------------
Import(".bam/functions.lua")
CheckVersion("0.5")
--------------------------------
-- --
-- Environment Setup --
-- --
--------------------------------
-- OS Detection
TARGET_OS = system()
if TARGET_OS == nil then
print ("System not supported" )
print ("Supported systems are: " .. supported_systems() )
return 1
end
-- paths used when building.
paths = {
build = "build",
object = "obj",
examples = "examples"
}
--------------------------------
-- --
-- Global Build Settings --
-- --
--------------------------------
global_settings = NewSettings();
-- Build type
--------------------------------
global_settings.debug = 1
global_settings.optimize = 0
if ScriptArgs.type ~= nil and ScriptArgs.type:match("^release") then
global_settings.debug = 0
if ScriptArgs.type == "release-fast" then
global_settings.optimize = 1
end
end
-- Output configuration
--------------------------------
global_settings.lib.prefix = Path(paths.build) .. "/"
global_settings.link.Output = function(settings, input)
return Path(PathJoin(paths.build, input))
end
global_settings.cc.Output = function(settings, input)
return Path(PathJoin(PathJoin(paths.build, paths.object), PathBase(input)))
end
-- Compiler configuration
--------------------------------
-- MSVC complains about exception handler without this flag.
if global_settings.cc.exe_cxx == "cl" then
global_settings.cc.flags:Add('/EHsc')
end
--------------------------------
-- --
-- Engine configuration --
-- --
--------------------------------
local settings = global_settings
settings.cc.includes:Add("include/")
settings.cc.includes:Add("source/")
-- FreeType2
if TARGET_OS == "Win32" then
settings.cc.includes:Add("vendor/FreeType2/include")
else
settings.cc.includes:Add("/usr/include/freetype2")
end
-- STB
settings.cc.includes:Add("vendor/stb/include")
-- Source files
--------------------------------
local system_module = Module("source/System", {
"File.cpp",
"MessageHandler.cpp",
"MessageQueue.cpp",
"SystemEvent.cpp",
"Log.cpp"
})
local platform_common_module = Module("source/Platform", {
"PlatformDisplay.cpp"
})
-- if TARGET_OS == "Win32" then -- Needed later for unix.
platform_spec_module = Module("source/Platform/Win32", {
"Win32Application.cpp",
"Win32Display.cpp",
"Win32GLContext.cpp",
"Win32Input.cpp",
"Win32Internal.cpp",
"Win32Keyboard.cpp",
"Win32Misc.cpp",
"Win32Mouse.cpp",
"Win32MsgBuffer.cpp",
"Win32System.cpp",
"glad_wgl.c"
})
--end
local input_module = Module("source/Input", {
"InputDevice.cpp",
"InputEvent.cpp",
"InputListener.cpp",
"InputModule.cpp",
"Keyboard.cpp",
"Mouse.cpp"
})
local display_module = Module("source/Display", {
"Display.cpp",
"DisplayDescription.cpp",
"DisplayMode.cpp",
"GLContext.cpp"
})
local graphics_module = Module("source/Graphics", {
-- Primitives
"Vertex2D.cpp",
"Transformable.cpp",
"Sprite.cpp",
-- Rendering
"BatchRenderer2D.cpp",
"DefaultRenderer2D.cpp",
"Renderable2D.cpp",
"Renderer2D.cpp",
"RenderState.cpp",
"Shader.cpp",
"ShaderProgram.cpp",
"Texture.cpp",
-- Text
"Font/Engine/FontEngine.cpp",
"Font/Engine/FreeTypeEngine.cpp",
"Font/Engine/FreeTypeError.cpp",
"Font.cpp",
"Text.cpp",
-- Image
"Image.cpp",
"ImageLoader.cpp",
"OpenGL.cpp",
"GL/glad.c",
"GL/CheckError.cpp",
})
local core_module = Module("source/Core", {
"String.cpp"
})
local math_module = Module("source/Math", {
"Color.cpp",
"Logarithm.cpp",
"Math.cpp",
"Transform.cpp"
})
local game_module = Module("source", {
"Game/FPSCounter.cpp",
"Game/GameTime.cpp",
"Game.cpp",
})
local scene_module = Module("source/Scene", {
"Camera2D.cpp"
})
-- Build target
--------------------------------
local obj = Compile(settings, {
system_module,
platform_common_module,
platform_spec_module,
input_module,
display_module,
graphics_module,
core_module,
math_module,
game_module,
scene_module
})
local libspectre = StaticLibrary(settings,
"spectre",
obj
)
--------------------------------
-- --
-- Examples --
-- --
--------------------------------
local example_settings = global_settings
-- Include spectre headers.
example_settings.cc.includes:Add("include/")
-- Link with spectre.
example_settings.link.extrafiles:Add(libspectre)
if TARGET_OS == "Win32" then
-- Windows needs to link against these.
example_settings.link.libs:Add("opengl32", "gdi32", "user32")
-- Staticly link freetype on windows.
example_settings.link.libpath:Add("vendor/FreeType2/lib/x86")
if example_settings.debug > 0 then
example_settings.link.libs:Add("freetype-d-s")
else
example_settings.link.libs:Add("freetype-s")
end
end
-- For now, to get examples working
-- we copy the whole assets directory.
assets = CopyDir(PathJoin(paths.build, paths.examples), "assets")
BuildExamples(example_settings, {
"text"
}, assets)