205 lines
4.3 KiB
Lua
205 lines
4.3 KiB
Lua
-----------------------------------------------------------
|
|
-- --
|
|
-- Engine configuration --
|
|
-- --
|
|
-- Builds Spectre engine as static library. --
|
|
-- --
|
|
-- Output variables: --
|
|
-- libspectre = path to .lib file --
|
|
-----------------------------------------------------------
|
|
Import(".bam/path.lua")
|
|
|
|
local settings = CopySettings(global_settings, "Spectre")
|
|
|
|
settings.cc.includes:Add(
|
|
RelPath("include/"),
|
|
RelPath("source/"),
|
|
-- STB
|
|
RelPath("vendor/stb/include")
|
|
)
|
|
|
|
if global_settings.debug then
|
|
settings.cc.flags:Add("-DSPECTRE_DEBUG")
|
|
end
|
|
|
|
-- Platform
|
|
if TARGET_OS == "Win32" then
|
|
settings.cc.defines:Add("SPECTRE_PLATFORM_WIN=1")
|
|
elseif TARGET_OS == "Unix" then
|
|
settings.cc.defines:Add("SPECTRE_PLATFORM_UNIX=1")
|
|
end
|
|
|
|
-- FreeType2
|
|
if TARGET_OS == "Win32" then
|
|
settings.cc.includes:Add(RelPath("vendor/FreeType2/include"))
|
|
else
|
|
settings.cc.includes:Add("/usr/include/freetype2")
|
|
end
|
|
|
|
-- Source files
|
|
-----------------------------------------------------------
|
|
|
|
local system_module = Module("source/System", {
|
|
"ByteOrder.cpp",
|
|
"File.cpp",
|
|
"Path.cpp",
|
|
"MessageHandler.cpp",
|
|
"MessageQueue.cpp",
|
|
"Event.cpp",
|
|
"EventListener.cpp",
|
|
"Log.cpp",
|
|
"Stopwatch.cpp"
|
|
})
|
|
|
|
local platform_common_module = Module("source/Platform", {
|
|
"PlatformApplication.cpp",
|
|
"PlatformDisplay.cpp"
|
|
})
|
|
|
|
if TARGET_OS == "Win32" then
|
|
platform_spec_module = Module("source/Platform/Win32", {
|
|
"Win32Application.cpp",
|
|
"Win32Display.cpp",
|
|
"Win32GLContext.cpp",
|
|
"Win32Input.cpp",
|
|
"Win32Internal.cpp",
|
|
"Win32Keyboard.cpp",
|
|
"Win32Misc.cpp",
|
|
"Win32Mouse.cpp",
|
|
"Win32EventQueue.cpp",
|
|
"Win32System.cpp",
|
|
"glad_wgl.c"
|
|
})
|
|
elseif TARGET_OS == "Unix" then
|
|
platform_spec_module = Module("source/Platform/Unix", {
|
|
"Xlib.cpp",
|
|
"UnixApplication.cpp",
|
|
"X11Display.cpp",
|
|
"GLXContext.cpp",
|
|
"X11Input.cpp",
|
|
"X11Keyboard.cpp",
|
|
"X11Mouse.cpp",
|
|
"X11EventQueue.cpp",
|
|
"X11WindowEventHandler.cpp",
|
|
"UnixMisc.cpp",
|
|
"UnixSystem.cpp",
|
|
"glad_glx.c"
|
|
})
|
|
end
|
|
|
|
local input_module = Module("source/Input", {
|
|
"InputDevice.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/FreeTypeEngine.cpp",
|
|
"Font/Engine/FreeTypeError.cpp",
|
|
"Font/Engine/FreeTypeLib.cpp",
|
|
"Font/FontDescription.cpp",
|
|
"Font.cpp",
|
|
"Text.cpp",
|
|
|
|
-- Image
|
|
"Image.cpp",
|
|
"ImageLoader.cpp",
|
|
"Image/IcoFormat.cpp",
|
|
"PixelFormat.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",
|
|
"Time.cpp"
|
|
})
|
|
|
|
local game_module = Module("source", {
|
|
"Game/FPSCounter.cpp",
|
|
"Game/GameTime.cpp",
|
|
"Game.cpp",
|
|
})
|
|
|
|
local scene_module = Module("source/Scene", {
|
|
"Camera2D.cpp"
|
|
})
|
|
|
|
-- Build target
|
|
-----------------------------------------------------------
|
|
|
|
-- Dependancies
|
|
if TARGET_OS == "Win32" then
|
|
Import("vendor/FreeType2/build.lua")
|
|
end
|
|
|
|
-- engine
|
|
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
|
|
})
|
|
|
|
libspectre = StaticLibrary(settings,
|
|
"spectre",
|
|
obj,
|
|
libfreetype
|
|
)
|
|
|
|
-- Export settings
|
|
-----------------------------------------------------------
|
|
local exp = NewSettings()
|
|
|
|
-- Headers
|
|
exp.cc.includes:Add(RelPath("include"))
|
|
|
|
-- Additional libraries.
|
|
if TARGET_OS == "Win32" then
|
|
-- Windows needs to link against these.
|
|
exp.link.libs:Add("opengl32", "gdi32", "user32")
|
|
elseif TARGET_OS == "Unix" then
|
|
-- Unix nees dl and X11 libs and freetype
|
|
exp.link.libs:Add("dl", 'X11', 'Xrandr', 'freetype')
|
|
end
|
|
|
|
libspectre_settings = exp
|