1
0
Fork 0

Remove bam

This commit is contained in:
Henrik Hautakoski 2022-09-26 22:31:43 +02:00
parent 0406a38895
commit 36af790293
14 changed files with 0 additions and 591 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

2
.gitignore vendored
View file

@ -1,8 +1,6 @@
# Build system related files
build/
.bam/*
!.bam/*.lua
# Thumbnail databases (Windows)
Thumbs.db

98
bam.lua
View file

@ -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)

View file

@ -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

View file

@ -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)

View file

@ -1,7 +0,0 @@
local base = PathDir(ModuleFilename())
src ={
base .. "/main.cpp",
base .. "/DisplayExample.cpp"
}

View file

@ -1,7 +0,0 @@
local base = PathDir(ModuleFilename())
src ={
base .. "/main.cpp",
base .. "/EventsExample.cpp"
}

View file

@ -1,7 +0,0 @@
local base = PathDir(ModuleFilename())
src ={
base .. "/main.cpp",
base .. "/InputExample.cpp"
}

View file

@ -1,7 +0,0 @@
local base = PathDir(ModuleFilename())
src ={
base .. "/main.cpp",
base .. "/Game.cpp"
}

View file

@ -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 <name>.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)

View file

@ -1,10 +0,0 @@
src = Module(".", {
"ftbase.c",
"ftinit.c",
"ftsystem.c",
"ftmm.c",
"ftstroke.c",
"ftglyph.c",
"ftbitmap.c"
})