diff --git a/.bam/compilers.lua b/.bam/compilers.lua deleted file mode 100644 index 8545c8b..0000000 --- a/.bam/compilers.lua +++ /dev/null @@ -1,33 +0,0 @@ - -Import("path.lua") - -function CustomCompileC(settings, input) - local cc = settings.cc - local outname = cc.Output(settings, input) .. cc.extension - cc.DriverC(settings.labelprefix .. "c " .. ModuleRelative(input), outname, input, settings) - AddDependency(outname, input) - if not IsOutput(input) then - bam_add_dependency_cpp(input) - end - return outname -end - -function CustomCompileCXX(settings, input) - local cc = settings.cc - local outname = cc.Output(settings, input) .. cc.extension - cc.DriverCXX(settings.labelprefix .. "c++ " .. ModuleRelative(input), outname, input, settings) - AddDependency(outname, input) - if not IsOutput(input) then - bam_add_dependency_cpp(input) - end - return outname -end - -function SetCompilers(settings) - settings.compile.mappings["c"] = CustomCompileC - - settings.compile.mappings["cpp"] = CustomCompileCXX - settings.compile.mappings["cxx"] = CustomCompileCXX - settings.compile.mappings["c++"] = CustomCompileCXX - settings.compile.mappings["cc"] = CustomCompileCXX -end diff --git a/.bam/functions.lua b/.bam/functions.lua deleted file mode 100644 index 3159891..0000000 --- a/.bam/functions.lua +++ /dev/null @@ -1,83 +0,0 @@ - -Import("path.lua") -Import("utils.lua") - -local _systems = { - "Win32", - "Unix" -} - - --- Returns a string of all supported systems -function supported_systems() - return table.concat(_systems, ', ') -end - - --- Return True if 'value' is a supported system. False otherwise. -function valid_system(value) - return contains(_systems, value) -end - - --- Find what host system we are on. --- Returns nil if system could not be determined. -function host_system() - - -- Check "platform" variable set by bam first. - if platform == "win32" or platform == "win64" then - return _systems[1] - end - if platform == "linux" then - return _systems[2] - end - - -- next, check if we are on windows by checking - -- the 'OS' environment variable - local win = os.getenv('OS') - if win ~= nil and win:lower():match('windows') then - return _systems[1] - end - - return nil -end - -function SetSettingsPrefix(settings, prefix) - settings.labelprefix = string.format("[%s] ", prefix) -end - --- Copy settings with a optional label prefix. -function CopySettings(settings, prefix) - local n = TableDeepCopy(settings) - if prefix ~= nil then - SetSettingsPrefix(n, prefix) - end - return n -end - --- Defines a module --- path: base path to source files. --- src: table of source files. -function Module(path, src) - path = RelPath(path) - local r = {} - for k, v in pairs(src) do - r[k] = PathJoin(path, v) - end - return r -end - --- Copy a directory src to dst --- src = "path/to/a", dest = "path/to/b" -> the whole content --- of "a" will be copied to "path/to/b" -function CopyDir(dst, src) - local r = {} - local base = PathDir(src) - local files = CollectRecursive(Path(src) .. "/*") - - for k, v in pairs(files) do - local rdir = PathDir(v:sub(base:len() + 1)) - r[k] = CopyToDirectory(PathJoin(dst, rdir), v) - end - return r -end diff --git a/.bam/path.lua b/.bam/path.lua deleted file mode 100644 index bcfd657..0000000 --- a/.bam/path.lua +++ /dev/null @@ -1,16 +0,0 @@ - --- Like ModuleFilename but only return the directory path -function ModuleDir() - return PathDir(ModuleFilename()) -end - --- Strip ModuleDir() of the beginning of path -function ModuleRelative(path) - return string.gsub(path, "^" .. ModuleDir() .. "/", "") -end - --- Make the path relative to the current working directory --- and ModuleDir() -function RelPath(path) - return PathJoin(ModuleDir(), path) -end diff --git a/.bam/utils.lua b/.bam/utils.lua deleted file mode 100644 index be68000..0000000 --- a/.bam/utils.lua +++ /dev/null @@ -1,22 +0,0 @@ - --- Returns True if 'table' contains the value 'val'. False otherwise. -function contains(table, val) - for i=1, #table do - if table[i] == val then - return true - end - end - return false -end - -function TableMerge(a, b) - local r = TableDeepCopy(a) - for k,v in pairs(b) do - if IsTable(v) then - r[k] = TableMerge(r[k] or {}, v) - else - r[k] = v - end - end - return r -end diff --git a/.gitignore b/.gitignore index d8f3ddd..3ff3458 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,6 @@ # Build system related files build/ -.bam/* -!.bam/*.lua # Thumbnail databases (Windows) Thumbs.db diff --git a/bam.lua b/bam.lua deleted file mode 100644 index 3f6a260..0000000 --- a/bam.lua +++ /dev/null @@ -1,98 +0,0 @@ --------------------------------- --- -- --- Spectre build config -- --- -- --------------------------------- -Import(".bam/path.lua") -Import(".bam/utils.lua") -Import(".bam/functions.lua") -Import(".bam/compilers.lua") -CheckVersion("0.5") - --------------------------------- --- -- --- Environment Setup -- --- -- --------------------------------- - --- Target specified on command line or get host system. -TARGET_OS = ScriptArgs.target or host_system() - -if not valid_system(TARGET_OS) then - print ("System not supported" ) - print ("Supported systems are: " .. supported_systems() ) - return 1 -end - --- paths used when building. -paths = { - -- Root build directory. - build = ScriptArgs.build_dir or "build", - - -- Directory where internal object/libs files are - -- stored to produce the final library. - intermediate = PathJoin("spectre", TARGET_OS), - - object = "obj", - examples = "examples_" .. TARGET_OS -} - --------------------------------- --- -- --- 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 - - --- Compilers --------------------------------- -SetCompilers(global_settings) - --- Output configuration --------------------------------- - --- Output path for static libraries. -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) - local path = PathJoin(paths.build, paths.intermediate) - return Path(PathJoin(PathJoin(path, 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 - --------------------------------- --- -- --- Build Targets -- --- -- --------------------------------- - -Import("engine.build.lua") -Import("examples/build.lua") - --- Set engine library as default target -DefaultTarget(libspectre) diff --git a/engine.build.lua b/engine.build.lua deleted file mode 100644 index 7c052de..0000000 --- a/engine.build.lua +++ /dev/null @@ -1,215 +0,0 @@ ------------------------------------------------------------ --- -- --- 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", - "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", - - "GL/glad.c", - "GL/CheckError.cpp", - - "Graphics.cpp", -}) - -local gfxdrv_module = Module("source/GfxDriver", { - "ShaderProgram.cpp", -}) - -local gfxdrv_opengl_module = Module("source/GfxDriver/OpenGL", { - "OpenGLDrv.cpp", - "OpenGLShaderProgram.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, - gfxdrv_module, - gfxdrv_opengl_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 diff --git a/examples/build.lua b/examples/build.lua deleted file mode 100644 index 546e0f4..0000000 --- a/examples/build.lua +++ /dev/null @@ -1,26 +0,0 @@ --------------------------------- --- -- --- Examples -- --- -- --------------------------------- - - -local settings = TableMerge(libspectre_settings, global_settings) -SetSettingsPrefix(settings, "Examples") - --- Link with spectre. -settings.link.extrafiles:Add(libspectre) - --- For now, to get examples working --- we copy the whole assets directory. -assets = CopyDir(PathJoin(paths.build, paths.examples), "assets") - -examples = {} -for k, name in pairs(CollectDirs("examples/*")) do - Import(PathJoin(name, "bam.lua")) - exe = Link(settings, PathJoin(paths.examples, PathFilename(name)), Compile(settings, src)) - AddDependency(exe, assets) - table.insert(examples, exe) -end - -PseudoTarget("examples", examples) diff --git a/examples/display/bam.lua b/examples/display/bam.lua deleted file mode 100644 index 8e16b24..0000000 --- a/examples/display/bam.lua +++ /dev/null @@ -1,7 +0,0 @@ - -local base = PathDir(ModuleFilename()) - -src ={ - base .. "/main.cpp", - base .. "/DisplayExample.cpp" -} diff --git a/examples/events/bam.lua b/examples/events/bam.lua deleted file mode 100644 index fa428ca..0000000 --- a/examples/events/bam.lua +++ /dev/null @@ -1,7 +0,0 @@ - -local base = PathDir(ModuleFilename()) - -src ={ - base .. "/main.cpp", - base .. "/EventsExample.cpp" -} diff --git a/examples/input/bam.lua b/examples/input/bam.lua deleted file mode 100644 index 6cf60e3..0000000 --- a/examples/input/bam.lua +++ /dev/null @@ -1,7 +0,0 @@ - -local base = PathDir(ModuleFilename()) - -src ={ - base .. "/main.cpp", - base .. "/InputExample.cpp" -} diff --git a/examples/text/bam.lua b/examples/text/bam.lua deleted file mode 100644 index 20b54a5..0000000 --- a/examples/text/bam.lua +++ /dev/null @@ -1,7 +0,0 @@ - -local base = PathDir(ModuleFilename()) - -src ={ - base .. "/main.cpp", - base .. "/Game.cpp" -} \ No newline at end of file diff --git a/vendor/FreeType2/build.lua b/vendor/FreeType2/build.lua deleted file mode 100644 index 0540587..0000000 --- a/vendor/FreeType2/build.lua +++ /dev/null @@ -1,58 +0,0 @@ ------------------------------------------------------------ --- -- --- FreeType2 build config -- --- -- --- Output variables: -- --- libfreetype = path to .lib file -- ------------------------------------------------------------ - --- Modules --------------------------------- -local ft_modules = { - "base", - "autofit", - "cff", - "psaux", - "pshinter", - "psnames", - "raster", - "sfnt", - "smooth", - "truetype", -} - --- Settings --------------------------------- -local settings = TableDeepCopy(global_settings) -SetSettingsPrefix(settings, "FT2") - --- Compile flags -settings.cc.includes:Add(RelPath("include")) -settings.cc.flags:Add("-DFT2_BUILD_LIBRARY") - --- Build target --------------------------------- - -local obj = {} - --- Compile each module to object files. -for k,name in pairs(ft_modules) do - local mod_base = RelPath("src/" .. name) - local module_file = PathJoin(mod_base, "module.lua") - - -- Check if we have a module.lua file - -- that defines the modules sources - local f = io.open(module_file) - if f then - Import(module_file) - else - -- Otherwise, We assume there is a .c - src = PathJoin(mod_base, string.format("%s.c", name)) - end - - obj[name] = Compile(settings, src) - PseudoTarget("ft2_" .. name, obj[name]) -end - -libfreetype = StaticLibrary(settings, "freetype", obj) -PseudoTarget("ft2", libfreetype) diff --git a/vendor/FreeType2/src/base/module.lua b/vendor/FreeType2/src/base/module.lua deleted file mode 100644 index e6309d5..0000000 --- a/vendor/FreeType2/src/base/module.lua +++ /dev/null @@ -1,10 +0,0 @@ - -src = Module(".", { - "ftbase.c", - "ftinit.c", - "ftsystem.c", - "ftmm.c", - "ftstroke.c", - "ftglyph.c", - "ftbitmap.c" -})