Merge pull request #1072 from minus7/new-bam-file

rewrote bam.lua to be cleaner
This commit is contained in:
oy 2014-06-21 19:59:28 +02:00
commit 27da041e00
39 changed files with 464 additions and 406 deletions

17
.gitignore vendored
View file

@ -1,26 +1,11 @@
/bam
/.bam
/config.lua
/objs
/build
__pycache__/
*.pyc
*.pyo
scripts/work/
src/game/generated/
other/icons/*.res
/SDL.dll
/freetype.dll
/autoexec.cfg
/crapnet*
/dilate*
/fake_server*
/map_resave*
/map_version*
/mastersrv*
/packetgen*
/teeworlds*
/teeworlds_srv*
/serverlaunch*
/tileset_border*
/versionsrv*

730
bam.lua
View file

@ -9,15 +9,19 @@ config = NewConfig()
config:Add(OptCCompiler("compiler"))
config:Add(OptTestCompileC("stackprotector", "int main(){return 0;}", "-fstack-protector -fstack-protector-all"))
config:Add(OptTestCompileC("minmacosxsdk", "int main(){return 0;}", "-mmacosx-version-min=10.5 -isysroot /Developer/SDKs/MacOSX10.5.sdk"))
config:Add(OptTestCompileC("macosxppc", "int main(){return 0;}", "-arch ppc"))
config:Add(OptLibrary("zlib", "zlib.h", false))
config:Add(SDL.OptFind("sdl", true))
config:Add(FreeType.OptFind("freetype", true))
config:Finalize("config.lua")
generated_src_dir = "build/src"
generated_icon_dir = "build/icons"
builddir = "build/%(arch)s/%(conf)s"
-- data compiler
function Script(name)
function Python(name)
if family == "windows" then
-- Python is usually registered for .py files in Windows
return str_replace(name, "/", "\\")
end
return "python " .. name
@ -26,10 +30,10 @@ end
function CHash(output, ...)
local inputs = TableFlatten({...})
output = Path(output)
output = PathJoin(generated_src_dir, Path(output))
-- compile all the files
local cmd = Script("scripts/cmd5.py") .. " "
local cmd = Python("scripts/cmd5.py") .. " "
for index, inname in ipairs(inputs) do
cmd = cmd .. Path(inname) .. " "
end
@ -44,370 +48,430 @@ function CHash(output, ...)
return output
end
--[[
function DuplicateDirectoryStructure(orgpath, srcpath, dstpath)
for _,v in pairs(CollectDirs(srcpath .. "/")) do
MakeDirectory(dstpath .. "/" .. string.sub(v, string.len(orgpath)+2))
DuplicateDirectoryStructure(orgpath, v, dstpath)
end
end
DuplicateDirectoryStructure("src", "src", "objs")
]]
function ResCompile(scriptfile)
scriptfile = Path(scriptfile)
local output = nil
if config.compiler.driver == "cl" then
output = PathBase(scriptfile) .. ".res"
output = PathJoin(generated_icon_dir, PathBase(PathFilename(scriptfile)) .. ".res")
AddJob(output, "rc " .. scriptfile, "rc /fo " .. output .. " " .. scriptfile)
elseif config.compiler.driver == "gcc" then
output = PathBase(scriptfile) .. ".coff"
elseif config.compiler.driver == "gcc" or config.compiler.driver == "clang" then
output = PathJoin(generated_icon_dir, PathBase(PathFilename(scriptfile)) .. ".coff")
AddJob(output, "windres " .. scriptfile, "windres -i " .. scriptfile .. " -o " .. output)
end
AddDependency(output, scriptfile)
return output
end
function Dat2c(datafile, sourcefile, arrayname)
datafile = Path(datafile)
sourcefile = Path(sourcefile)
AddJob(
sourcefile,
"dat2c " .. PathFilename(sourcefile) .. " = " .. PathFilename(datafile),
Script("scripts/dat2c.py").. "\" " .. sourcefile .. " " .. datafile .. " " .. arrayname
)
AddDependency(sourcefile, datafile)
return sourcefile
end
function ContentCompile(action, output)
output = Path(output)
output = PathJoin(generated_src_dir, Path(output))
AddJob(
output,
action .. " > " .. output,
--Script("datasrc/compile.py") .. "\" ".. Path(output) .. " " .. action
Script("datasrc/compile.py") .. " " .. action .. " > " .. Path(output)
Python("datasrc/compile.py") .. " " .. action .. " > " .. output
)
AddDependency(output, Path("datasrc/content.py")) -- do this more proper
AddDependency(output, Path("datasrc/network.py"))
AddDependency(output, Path("datasrc/compile.py"))
AddDependency(output, Path("datasrc/datatypes.py"))
AddDependency(output, "datasrc/compile.py")
AddDependency("datasrc/compile.py", "datasrc/content.py", "datasrc/network.py", "datasrc/datatypes.py")
return output
end
-- Content Compile
network_source = ContentCompile("network_source", "src/game/generated/protocol.cpp")
network_header = ContentCompile("network_header", "src/game/generated/protocol.h")
client_content_source = ContentCompile("client_content_source", "src/game/generated/client_data.cpp")
client_content_header = ContentCompile("client_content_header", "src/game/generated/client_data.h")
server_content_source = ContentCompile("server_content_source", "src/game/generated/server_data.cpp")
server_content_header = ContentCompile("server_content_header", "src/game/generated/server_data.h")
AddDependency(network_source, network_header)
AddDependency(client_content_source, client_content_header)
AddDependency(server_content_source, server_content_header)
nethash = CHash("src/game/generated/nethash.cpp", "src/engine/shared/protocol.h", "src/game/generated/protocol.h", "src/game/tuning.h", "src/game/gamecore.cpp", network_header)
client_link_other = {}
client_depends = {}
server_link_other = {}
if family == "windows" then
if platform == "win32" then
table.insert(client_depends, CopyToDirectory(".", "other\\freetype\\lib32\\freetype.dll"))
table.insert(client_depends, CopyToDirectory(".", "other\\sdl\\lib32\\SDL.dll"))
else
table.insert(client_depends, CopyToDirectory(".", "other\\freetype\\lib64\\freetype.dll"))
table.insert(client_depends, CopyToDirectory(".", "other\\sdl\\lib64\\SDL.dll"))
end
if config.compiler.driver == "cl" then
client_link_other = {ResCompile("other/icons/teeworlds_cl.rc")}
server_link_other = {ResCompile("other/icons/teeworlds_srv_cl.rc")}
elseif config.compiler.driver == "gcc" then
client_link_other = {ResCompile("other/icons/teeworlds_gcc.rc")}
server_link_other = {ResCompile("other/icons/teeworlds_srv_gcc.rc")}
end
end
function Intermediate_Output(settings, input)
return "objs/" .. string.sub(PathBase(input), string.len("src/")+1) .. settings.config_ext
end
function build(settings)
-- apply compiler settings
config.compiler:Apply(settings)
--settings.objdir = Path("objs")
settings.cc.Output = Intermediate_Output
if config.compiler.driver == "cl" then
settings.cc.flags:Add("/wd4244")
else
function GenerateCommonSettings(settings)
if compiler == "gcc" or compiler == "clang" then
settings.cc.flags:Add("-Wall", "-fno-exceptions")
if family == "windows" then
-- disable visibility attribute support for gcc on windows
settings.cc.defines:Add("NO_VIZ")
settings.cc.defines:Add("_WIN32_WINNT=0x0501")
elseif platform == "macosx" then
settings.cc.flags:Add("-mmacosx-version-min=10.5")
settings.link.flags:Add("-mmacosx-version-min=10.5")
if config.minmacosxsdk.value == 1 then
settings.cc.flags:Add("-isysroot /Developer/SDKs/MacOSX10.5.sdk")
settings.link.flags:Add("-isysroot /Developer/SDKs/MacOSX10.5.sdk")
end
elseif config.stackprotector.value == 1 then
settings.cc.flags:Add("-fstack-protector", "-fstack-protector-all")
settings.link.flags:Add("-fstack-protector", "-fstack-protector-all")
end
end
-- set some platform specific settings
settings.cc.includes:Add("src")
if family == "unix" then
if platform == "macosx" then
settings.link.frameworks:Add("Carbon")
settings.link.frameworks:Add("AppKit")
else
settings.link.libs:Add("pthread")
end
if platform == "solaris" then
settings.link.flags:Add("-lsocket")
settings.link.flags:Add("-lnsl")
end
elseif family == "windows" then
settings.link.libs:Add("gdi32")
settings.link.libs:Add("user32")
settings.link.libs:Add("ws2_32")
settings.link.libs:Add("ole32")
settings.link.libs:Add("shell32")
end
-- compile zlib if needed
-- Compile zlib if needed
local zlib = nil
if config.zlib.value == 1 then
settings.link.libs:Add("z")
if config.zlib.include_path then
settings.cc.includes:Add(config.zlib.include_path)
end
zlib = {}
else
zlib = Compile(settings, Collect("src/engine/external/zlib/*.c"))
settings.cc.includes:Add("src/engine/external/zlib")
zlib = Compile(settings, Collect("src/engine/external/zlib/*.c"))
end
-- build the small libraries
wavpack = Compile(settings, Collect("src/engine/external/wavpack/*.c"))
pnglite = Compile(settings, Collect("src/engine/external/pnglite/*.c"))
jsonparser = Compile(settings, Collect("src/engine/external/json-parser/*.c"))
local wavpack = Compile(settings, Collect("src/engine/external/wavpack/*.c"))
local png = Compile(settings, Collect("src/engine/external/pnglite/*.c"))
local json = Compile(settings, Collect("src/engine/external/json-parser/*.c"))
-- build game components
engine_settings = settings:Copy()
server_settings = engine_settings:Copy()
client_settings = engine_settings:Copy()
launcher_settings = engine_settings:Copy()
if family == "unix" then
if platform == "macosx" then
client_settings.link.frameworks:Add("OpenGL")
client_settings.link.frameworks:Add("AGL")
client_settings.link.frameworks:Add("Carbon")
client_settings.link.frameworks:Add("Cocoa")
launcher_settings.link.frameworks:Add("Cocoa")
else
client_settings.link.libs:Add("X11")
client_settings.link.libs:Add("GL")
client_settings.link.libs:Add("GLU")
end
elseif family == "windows" then
client_settings.link.libs:Add("opengl32")
client_settings.link.libs:Add("glu32")
client_settings.link.libs:Add("winmm")
end
-- apply sdl settings
config.sdl:Apply(client_settings)
-- apply freetype settings
config.freetype:Apply(client_settings)
engine = Compile(engine_settings, Collect("src/engine/shared/*.cpp", "src/base/*.c"))
client = Compile(client_settings, Collect("src/engine/client/*.cpp"))
server = Compile(server_settings, Collect("src/engine/server/*.cpp"))
versionserver = Compile(settings, Collect("src/versionsrv/*.cpp"))
masterserver = Compile(settings, Collect("src/mastersrv/*.cpp"))
game_shared = Compile(settings, Collect("src/game/*.cpp"), nethash, network_source)
game_client = Compile(settings, CollectRecursive("src/game/client/*.cpp"), client_content_source)
game_server = Compile(settings, CollectRecursive("src/game/server/*.cpp"), server_content_source)
game_editor = Compile(settings, Collect("src/game/editor/*.cpp"))
-- build tools (TODO: fix this so we don't get double _d_d stuff)
tools_src = Collect("src/tools/*.cpp", "src/tools/*.c")
client_osxlaunch = {}
server_osxlaunch = {}
if platform == "macosx" then
client_osxlaunch = Compile(client_settings, "src/osxlaunch/client.m")
server_osxlaunch = Compile(launcher_settings, "src/osxlaunch/server.m")
end
tools = {}
for i,v in ipairs(tools_src) do
toolname = PathFilename(PathBase(v))
tools[i] = Link(settings, toolname, Compile(settings, v), engine, zlib, pnglite)
end
-- build client, server, version server and master server
client_exe = Link(client_settings, "teeworlds", game_shared, game_client,
engine, client, game_editor, zlib, pnglite, wavpack, jsonparser,
client_link_other, client_osxlaunch)
server_exe = Link(server_settings, "teeworlds_srv", engine, server,
game_shared, game_server, zlib, server_link_other)
serverlaunch = {}
if platform == "macosx" then
serverlaunch = Link(launcher_settings, "serverlaunch", server_osxlaunch)
end
versionserver_exe = Link(server_settings, "versionsrv", versionserver,
engine, zlib)
masterserver_exe = Link(server_settings, "mastersrv", masterserver,
engine, zlib)
-- make targets
c = PseudoTarget("client".."_"..settings.config_name, client_exe, client_depends)
s = PseudoTarget("server".."_"..settings.config_name, server_exe, serverlaunch)
g = PseudoTarget("game".."_"..settings.config_name, client_exe, server_exe)
v = PseudoTarget("versionserver".."_"..settings.config_name, versionserver_exe)
m = PseudoTarget("masterserver".."_"..settings.config_name, masterserver_exe)
t = PseudoTarget("tools".."_"..settings.config_name, tools)
all = PseudoTarget(settings.config_name, c, s, v, m, t)
return all
-- globally available libs
libs = {zlib=zlib, wavpack=wavpack, png=png, json=json}
end
debug_settings = NewSettings()
debug_settings.config_name = "debug"
debug_settings.config_ext = "_d"
debug_settings.debug = 1
debug_settings.optimize = 0
debug_settings.cc.defines:Add("CONF_DEBUG")
release_settings = NewSettings()
release_settings.config_name = "release"
release_settings.config_ext = ""
release_settings.debug = 0
release_settings.optimize = 1
release_settings.cc.defines:Add("CONF_RELEASE")
if platform == "macosx" then
debug_settings_ppc = debug_settings:Copy()
debug_settings_ppc.config_name = "debug_ppc"
debug_settings_ppc.config_ext = "_ppc_d"
debug_settings_ppc.cc.flags:Add("-arch ppc")
debug_settings_ppc.link.flags:Add("-arch ppc")
debug_settings_ppc.cc.defines:Add("CONF_DEBUG")
release_settings_ppc = release_settings:Copy()
release_settings_ppc.config_name = "release_ppc"
release_settings_ppc.config_ext = "_ppc"
release_settings_ppc.cc.flags:Add("-arch ppc")
release_settings_ppc.link.flags:Add("-arch ppc")
release_settings_ppc.cc.defines:Add("CONF_RELEASE")
ppc_d = build(debug_settings_ppc)
ppc_r = build(release_settings_ppc)
if arch == "ia32" or arch == "amd64" then
debug_settings_x86 = debug_settings:Copy()
debug_settings_x86.config_name = "debug_x86"
debug_settings_x86.config_ext = "_x86_d"
debug_settings_x86.cc.flags:Add("-arch i386")
debug_settings_x86.link.flags:Add("-arch i386")
debug_settings_x86.cc.defines:Add("CONF_DEBUG")
release_settings_x86 = release_settings:Copy()
release_settings_x86.config_name = "release_x86"
release_settings_x86.config_ext = "_x86"
release_settings_x86.cc.flags:Add("-arch i386")
release_settings_x86.link.flags:Add("-arch i386")
release_settings_x86.cc.defines:Add("CONF_RELEASE")
x86_d = build(debug_settings_x86)
x86_r = build(release_settings_x86)
end
if arch == "amd64" then
debug_settings_x86_64 = debug_settings:Copy()
debug_settings_x86_64.config_name = "debug_x86_64"
debug_settings_x86_64.config_ext = "_x86_64_d"
debug_settings_x86_64.cc.flags:Add("-arch x86_64")
debug_settings_x86_64.link.flags:Add("-arch x86_64")
debug_settings_x86_64.cc.defines:Add("CONF_DEBUG")
release_settings_x86_64 = release_settings:Copy()
release_settings_x86_64.config_name = "release_x86_64"
release_settings_x86_64.config_ext = "_x86_64"
release_settings_x86_64.cc.flags:Add("-arch x86_64")
release_settings_x86_64.link.flags:Add("-arch x86_64")
release_settings_x86_64.cc.defines:Add("CONF_RELEASE")
x86_64_d = build(debug_settings_x86_64)
x86_64_r = build(release_settings_x86_64)
end
DefaultTarget("game_debug_x86")
if config.macosxppc.value == 1 then
if arch == "ia32" then
PseudoTarget("release", ppc_r, x86_r)
PseudoTarget("debug", ppc_d, x86_d)
PseudoTarget("server_release", "server_release_ppc", "server_release_x86")
PseudoTarget("server_debug", "server_debug_ppc", "server_debug_x86")
PseudoTarget("client_release", "client_release_ppc", "client_release_x86")
PseudoTarget("client_debug", "client_debug_ppc", "client_debug_x86")
elseif arch == "amd64" then
PseudoTarget("release", ppc_r, x86_r, x86_64_r)
PseudoTarget("debug", ppc_d, x86_d, x86_64_d)
PseudoTarget("server_release", "server_release_ppc", "server_release_x86", "server_release_x86_64")
PseudoTarget("server_debug", "server_debug_ppc", "server_debug_x86", "server_debug_x86_64")
PseudoTarget("client_release", "client_release_ppc", "client_release_x86", "client_release_x86_64")
PseudoTarget("client_debug", "client_debug_ppc", "client_debug_x86", "client_debug_x86_64")
else
PseudoTarget("release", ppc_r)
PseudoTarget("debug", ppc_d)
PseudoTarget("server_release", "server_release_ppc")
PseudoTarget("server_debug", "server_debug_ppc")
PseudoTarget("client_release", "client_release_ppc")
PseudoTarget("client_debug", "client_debug_ppc")
end
function GenerateMacOSXSettings(settings, conf, arch)
if arch == "x86" then
settings.cc.flags:Add("-arch i386")
settings.link.flags:Add("-arch i386")
elseif arch == "x86_64" then
settings.cc.flags:Add("-arch x86_64")
settings.link.flags:Add("-arch x86_64")
elseif arch == "ppc" then
settings.cc.flags:Add("-arch ppc")
settings.link.flags:Add("-arch ppc")
elseif arch == "ppc64" then
settings.cc.flags:Add("-arch ppc64")
settings.link.flags:Add("-arch ppc64")
else
if arch == "ia32" then
PseudoTarget("release", x86_r)
PseudoTarget("debug", x86_d)
PseudoTarget("server_release", "server_release_x86")
PseudoTarget("server_debug", "server_debug_x86")
PseudoTarget("client_release", "client_release_x86")
PseudoTarget("client_debug", "client_debug_x86")
elseif arch == "amd64" then
PseudoTarget("release", x86_r, x86_64_r)
PseudoTarget("debug", x86_d, x86_64_d)
PseudoTarget("server_release", "server_release_x86", "server_release_x86_64")
PseudoTarget("server_debug", "server_debug_x86", "server_debug_x86_64")
PseudoTarget("client_release", "client_release_x86", "client_release_x86_64")
PseudoTarget("client_debug", "client_debug_x86", "client_debug_x86_64")
print("Unknown Architecture '" .. arch .. "'. Supported: x86, x86_64, ppc, ppc64")
os.exit(1)
end
settings.cc.flags:Add("-mmacosx-version-min=10.5")
settings.link.flags:Add("-mmacosx-version-min=10.5")
if config.minmacosxsdk.value == 1 then
settings.cc.flags:Add("-isysroot /Developer/SDKs/MacOSX10.5.sdk")
settings.link.flags:Add("-isysroot /Developer/SDKs/MacOSX10.5.sdk")
end
settings.link.frameworks:Add("Carbon")
settings.link.frameworks:Add("AppKit")
GenerateCommonSettings(settings, conf, arch)
-- Build server launcher before adding game stuff
local serverlaunch = Link(settings, "serverlaunch", Compile(settings, "src/osxlaunch/server.m"))
-- Master server, version server and tools
BuildEngineCommon(settings)
BuildMasterserver(settings)
BuildVersionserver(settings)
BuildTools(settings)
-- Add requirements for Server & Client
BuildGameCommon(settings)
-- Server
settings.link.frameworks:Add("Cocoa")
local server_exe = BuildServer(settings)
AddDependency(server_exe, serverlaunch)
-- Client
settings.link.frameworks:Add("OpenGL")
settings.link.frameworks:Add("AGL")
-- FIXME: the SDL config is applied in BuildClient too but is needed here before so the launcher will compile
config.sdl:Apply(settings)
settings.link.extrafiles:Merge(Compile(settings, "src/osxlaunch/client.m"))
BuildClient(settings)
end
function GenerateLinuxSettings(settings, conf, arch)
if arch == "x86" then
settings.cc.flags:Add("-m32")
settings.link.flags:Add("-m32")
elseif arch == "x86_64" then
settings.cc.flags:Add("-m64")
settings.link.flags:Add("-m64")
else
print("Unknown Architecture '" .. arch .. "'. Supported: x86, x86_64")
os.exit(1)
end
settings.link.libs:Add("pthread")
GenerateCommonSettings(settings, conf, arch)
-- Master server, version server and tools
BuildEngineCommon(settings)
BuildTools(settings)
BuildMasterserver(settings)
BuildVersionserver(settings)
-- Add requirements for Server & Client
BuildGameCommon(settings)
-- Server
BuildServer(settings)
-- Client
settings.link.libs:Add("X11")
settings.link.libs:Add("GL")
settings.link.libs:Add("GLU")
BuildClient(settings)
end
function GenerateSolarisSettings(settings, conf, arch)
settings.link.libs:Add("socket")
settings.link.libs:Add("nsl")
GenerateLinuxSettings(settings, conf, arch)
end
function GenerateWindowsSettings(settings, conf, target_arch, compiler)
if compiler == "cl" then
if (target_arch == "x86" and arch ~= "ia32") or
(target_arch == "x86_64" and arch ~= "x64" and arch ~= "x86_64") then
print("Cross compiling is unsupported on Windows.")
os.exit(1)
end
settings.cc.flags:Add("/wd4244")
elseif compiler == "gcc" or config.compiler.driver == "clang" then
if target_arch == "x86" then
settings.cc.flags:Add("-m32")
settings.link.flags:Add("-m32")
elseif target_arch == "x86_64" then
settings.cc.flags:Add("-m64")
settings.link.flags:Add("-m64")
else
print("Unknown Architecture '" .. arch .. "'. Supported: x86, x86_64")
os.exit(1)
end
-- disable visibility attribute support for gcc on windows
settings.cc.defines:Add("NO_VIZ")
settings.cc.defines:Add("_WIN32_WINNT=0x0501")
end
local icons = SharedIcons(compiler)
-- Required libs
settings.link.libs:Add("gdi32")
settings.link.libs:Add("user32")
settings.link.libs:Add("ws2_32")
settings.link.libs:Add("ole32")
settings.link.libs:Add("shell32")
GenerateCommonSettings(settings, conf, target_arch)
-- Master server, version server and tools
BuildEngineCommon(settings)
BuildMasterserver(settings)
BuildVersionserver(settings)
BuildTools(settings)
-- Add requirements for Server & Client
BuildGameCommon(settings)
-- Server
local server_settings = settings:Copy()
server_settings.link.extrafiles:Add(icons.server)
BuildServer(server_settings)
-- Client
settings.link.extrafiles:Add(icons.client)
settings.link.libs:Add("opengl32")
settings.link.libs:Add("glu32")
settings.link.libs:Add("winmm")
BuildClient(settings)
end
function SharedCommonFiles()
-- Shared game files, generate only once
if not shared_common_files then
local network_source = ContentCompile("network_source", "generated/protocol.cpp")
local network_header = ContentCompile("network_header", "generated/protocol.h")
AddDependency(network_source, network_header)
local nethash = CHash("generated/nethash.cpp", "src/engine/shared/protocol.h", "src/game/tuning.h", "src/game/gamecore.cpp", network_header)
shared_common_files = {network_source, nethash}
end
return shared_common_files
end
function SharedServerFiles()
-- Shared server files, generate only once
if not shared_server_files then
local server_content_source = ContentCompile("server_content_source", "generated/server_data.cpp")
local server_content_header = ContentCompile("server_content_header", "generated/server_data.h")
AddDependency(server_content_source, server_content_header)
shared_server_files = {server_content_source}
end
return shared_server_files
end
function SharedClientFiles()
-- Shared client files, generate only once
if not shared_client_files then
local client_content_source = ContentCompile("client_content_source", "generated/client_data.cpp")
local client_content_header = ContentCompile("client_content_header", "generated/client_data.h")
AddDependency(client_content_source, client_content_header)
shared_client_files = {client_content_source}
end
return shared_client_files
end
shared_icons = {}
function SharedIcons(compiler)
if not shared_icons[compiler] then
local server_icon = ResCompile("other/icons/teeworlds_srv_" .. compiler .. ".rc")
local client_icon = ResCompile("other/icons/teeworlds_" .. compiler .. ".rc")
shared_icons[compiler] = {server=server_icon, client=client_icon}
end
return shared_icons[compiler]
end
function BuildEngineCommon(settings)
settings.link.extrafiles:Merge(Compile(settings, Collect("src/engine/shared/*.cpp", "src/base/*.c")))
end
function BuildGameCommon(settings)
settings.link.extrafiles:Merge(Compile(settings, Collect("src/game/*.cpp"), SharedCommonFiles()))
end
function BuildClient(settings, family, platform)
config.sdl:Apply(settings)
config.freetype:Apply(settings)
local client = Compile(settings, Collect("src/engine/client/*.cpp"))
local game_client = Compile(settings, CollectRecursive("src/game/client/*.cpp"), SharedClientFiles())
local game_editor = Compile(settings, Collect("src/game/editor/*.cpp"))
Link(settings, "teeworlds", libs["zlib"], libs["wavpack"], libs["png"], libs["json"], client, game_client, game_editor)
end
function BuildServer(settings, family, platform)
local server = Compile(settings, Collect("src/engine/server/*.cpp"))
local game_server = Compile(settings, CollectRecursive("src/game/server/*.cpp"), SharedServerFiles())
return Link(settings, "teeworlds_srv", libs["zlib"], server, game_server)
end
function BuildTools(settings)
local tools = {}
for i,v in ipairs(Collect("src/tools/*.cpp", "src/tools/*.c")) do
local toolname = PathFilename(PathBase(v))
tools[i] = Link(settings, toolname, Compile(settings, v), libs["zlib"], libs["wavpack"], libs["png"])
end
PseudoTarget(settings.link.Output(settings, "pseudo_tools") .. settings.link.extension, tools)
end
function BuildMasterserver(settings)
return Link(settings, "mastersrv", Compile(settings, Collect("src/mastersrv/*.cpp")), libs["zlib"])
end
function BuildVersionserver(settings)
return Link(settings, "versionsrv", Compile(settings, Collect("src/versionsrv/*.cpp")), libs["zlib"])
end
-- create all targets for specified configuration & architecture
function GenerateSettings(conf, arch, builddir, compiler)
local settings = NewSettings()
-- Set compiler if explicitly requested
if compiler == "gcc" then
SetDriversGCC(settings)
elseif compiler == "clang" then
SetDriversClang(settings)
elseif compiler == "cl" then
SetDriversCL(settings)
else
compiler = config.compiler.driver
end
if conf == "debug" then
settings.debug = 1
settings.optimize = 0
settings.cc.defines:Add("CONF_DEBUG")
else
settings.debug = 0
settings.optimize = 1
settings.cc.defines:Add("CONF_RELEASE")
end
-- Generate object files in {builddir}/objs/
settings.cc.Output = function (settings_, input)
-- strip
input = input:gsub("^src/", "")
input = input:gsub("^" .. generated_src_dir .. "/", "")
return PathJoin(PathJoin(builddir, "objs"), PathBase(input))
end
-- Build output files in {builddir}
settings.link.Output = function (settings_, input)
return PathJoin(builddir, PathBase(input) .. settings_.config_ext)
end
settings.cc.includes:Add("src")
settings.cc.includes:Add(generated_src_dir)
if family == "windows" then
GenerateWindowsSettings(settings, conf, arch, compiler)
elseif family == "unix" then
if platform == "macosx" then
GenerateMacOSXSettings(settings, conf, arch)
elseif platform == "linux" then
GenerateLinuxSettings(settings, conf, arch)
elseif platform == "solaris" then
GenerateSolarisSettings(settings, conf, arch)
end
end
else
build(debug_settings)
build(release_settings)
DefaultTarget("game_debug")
return settings
end
-- String formatting wth named parameters, by RiciLake http://lua-users.org/wiki/StringInterpolation
function interp(s, tab)
return (s:gsub('%%%((%a%w*)%)([-0-9%.]*[cdeEfgGiouxXsq])',
function(k, fmt)
return tab[k] and ("%"..fmt):format(tab[k]) or '%('..k..')'..fmt
end))
end
function split(str, sep)
local vals = {}
str:gsub("([^,]+)", function(val) table.insert(vals, val) end)
return vals
end
-- Supported archtitectures: x86, amd64, ppc, ppc64
if ScriptArgs['arch'] then
archs = split(ScriptArgs['arch'])
else
if arch == "ia32" then
archs = {"x86"}
elseif arch == "x64" or arch == "amd64" then
archs = {"x86_64"}
else
archs = {arch}
end
end
if ScriptArgs['conf'] then
confs = split(ScriptArgs['conf'])
else
confs = {"debug"}
end
if ScriptArgs['compiler'] then
compiler = ScriptArgs['compiler']
else
compiler = nil
end
if ScriptArgs['builddir'] then
builddir = ScriptArgs['builddir']
end
targets = {client="teeworlds", server="teeworlds_srv",
versionserver="versionsrv", masterserver="mastersrv",
tools="pseudo_tools"}
subtargets = {}
for t, cur_target in pairs(targets) do
subtargets[cur_target] = {}
end
for a, cur_arch in ipairs(archs) do
for c, cur_conf in ipairs(confs) do
cur_builddir = interp(builddir, {platform=family, arch=cur_arch, target=cur_target, conf=cur_conf, compiler=compiler})
local settings = GenerateSettings(cur_conf, cur_arch, cur_builddir, compiler)
for t, cur_target in pairs(targets) do
table.insert(subtargets[cur_target], PathJoin(cur_builddir, cur_target .. settings.link.extension))
end
end
end
for cur_name, cur_target in pairs(targets) do
-- Supertarget for all configurations and architectures of that target
PseudoTarget(cur_name, subtargets[cur_target])
end
PseudoTarget("game", "client", "server")
DefaultTarget("game")

View file

View file

@ -4,11 +4,15 @@ SDL = {
OptFind = function (name, required)
local check = function(option, settings)
option.value = false
option.use_pkgconfig = false
option.use_sdlconfig = false
option.use_winlib = 0
option.lib_path = nil
if ExecuteSilent("sdl-config") > 0 and ExecuteSilent("sdl-config --cflags") == 0 then
if ExecuteSilent("pkg-config sdl") == 0 then
option.value = true
option.use_pkgconfig = true
elseif ExecuteSilent("sdl-config") > 0 and ExecuteSilent("sdl-config --cflags") == 0 then
option.value = true
option.use_sdlconfig = true
end
@ -23,7 +27,10 @@ SDL = {
end
local apply = function(option, settings)
if option.use_sdlconfig == true then
if option.use_pkgconfig == true then
settings.cc.flags:Add("`pkg-config --cflags sdl`")
settings.link.flags:Add("`pkg-config --libs sdl`")
elseif option.use_sdlconfig == true then
settings.cc.flags:Add("`sdl-config --cflags`")
settings.link.flags:Add("`sdl-config --libs`")
elseif option.use_winlib > 0 then
@ -40,12 +47,14 @@ SDL = {
local save = function(option, output)
output:option(option, "value")
output:option(option, "use_pkgconfig")
output:option(option, "use_sdlconfig")
output:option(option, "use_winlib")
end
local display = function(option)
if option.value == true then
if option.use_pkgconfig == true then return "using pkg-config" end
if option.use_sdlconfig == true then return "using sdl-config" end
if option.use_winlib == 32 then return "using supplied win32 libraries" end
if option.use_winlib == 64 then return "using supplied win64 libraries" end

View file

@ -2,8 +2,8 @@
/* If you are missing that file, acquire a complete release at teeworlds.com. */
#include <base/math.h>
#include <game/generated/protocol.h>
#include <game/generated/client_data.h>
#include <generated/protocol.h>
#include <generated/client_data.h>
#include "animstate.h"

View file

@ -3,8 +3,8 @@
#include <engine/shared/config.h>
#include <engine/graphics.h>
#include <engine/textrender.h>
#include <game/generated/protocol.h>
#include <game/generated/client_data.h>
#include <generated/protocol.h>
#include <generated/client_data.h>
#include <game/client/gameclient.h>

View file

@ -7,8 +7,8 @@
#include <engine/keys.h>
#include <engine/shared/config.h>
#include <game/generated/protocol.h>
#include <game/generated/client_data.h>
#include <generated/protocol.h>
#include <generated/client_data.h>
#include <game/client/gameclient.h>
#include <game/client/localization.h>

View file

@ -2,7 +2,7 @@
/* If you are missing that file, acquire a complete release at teeworlds.com. */
#include <math.h>
#include <game/generated/client_data.h>
#include <generated/client_data.h>
#include <base/system.h>

View file

@ -2,8 +2,8 @@
/* If you are missing that file, acquire a complete release at teeworlds.com. */
#include <engine/demo.h>
#include <engine/graphics.h>
#include <game/generated/protocol.h>
#include <game/generated/client_data.h>
#include <generated/protocol.h>
#include <generated/client_data.h>
#include <game/client/ui.h>
#include <game/client/render.h>

View file

@ -4,8 +4,8 @@
#include <engine/graphics.h>
#include <engine/textrender.h>
#include <game/generated/protocol.h>
#include <game/generated/client_data.h>
#include <generated/protocol.h>
#include <generated/client_data.h>
#include <game/layers.h>

View file

@ -5,7 +5,7 @@
#include <engine/shared/config.h>
#include <game/generated/client_data.h>
#include <generated/client_data.h>
#include <game/client/components/particles.h>
#include <game/client/components/skins.h>

View file

@ -2,8 +2,8 @@
/* If you are missing that file, acquire a complete release at teeworlds.com. */
#include <engine/graphics.h>
#include <engine/shared/config.h>
#include <game/generated/protocol.h>
#include <game/generated/client_data.h>
#include <generated/protocol.h>
#include <generated/client_data.h>
#include <game/client/ui.h>
#include <game/client/render.h>

View file

@ -4,8 +4,8 @@
#include <engine/textrender.h>
#include <engine/shared/config.h>
#include <game/generated/protocol.h>
#include <game/generated/client_data.h>
#include <generated/protocol.h>
#include <generated/client_data.h>
#include <game/layers.h>
#include <game/client/gameclient.h>
#include <game/client/animstate.h>

View file

@ -2,8 +2,8 @@
/* If you are missing that file, acquire a complete release at teeworlds.com. */
#include <engine/graphics.h>
#include <engine/demo.h>
#include <game/generated/protocol.h>
#include <game/generated/client_data.h>
#include <generated/protocol.h>
#include <generated/client_data.h>
#include <game/client/gameclient.h>
#include <game/client/ui.h>

View file

@ -2,8 +2,8 @@
/* If you are missing that file, acquire a complete release at teeworlds.com. */
#include <engine/graphics.h>
#include <engine/textrender.h>
#include <game/generated/protocol.h>
#include <game/generated/client_data.h>
#include <generated/protocol.h>
#include <generated/client_data.h>
#include <game/client/gameclient.h>
#include <game/client/animstate.h>

View file

@ -17,9 +17,9 @@
#include <engine/shared/config.h>
#include <game/version.h>
#include <game/generated/protocol.h>
#include <generated/protocol.h>
#include <game/generated/client_data.h>
#include <generated/client_data.h>
#include <game/client/components/camera.h>
#include <game/client/components/sounds.h>
#include <game/client/gameclient.h>

View file

@ -8,8 +8,8 @@
#include <engine/textrender.h>
#include <engine/shared/config.h>
#include <game/generated/client_data.h>
#include <game/generated/protocol.h>
#include <generated/client_data.h>
#include <generated/protocol.h>
#include <game/version.h>
#include <game/client/render.h>

View file

@ -14,7 +14,7 @@
#include <game/client/ui.h>
#include <game/generated/client_data.h>
#include <generated/client_data.h>
#include "maplayers.h"
#include "menus.h"

View file

@ -10,8 +10,8 @@
#include <engine/textrender.h>
#include <engine/shared/config.h>
#include <game/generated/protocol.h>
#include <game/generated/client_data.h>
#include <generated/protocol.h>
#include <generated/client_data.h>
#include <game/client/animstate.h>
#include <game/client/gameclient.h>

View file

@ -10,8 +10,8 @@
#include <engine/external/json-parser/json.h>
#include <engine/shared/config.h>
#include <game/generated/protocol.h>
#include <game/generated/client_data.h>
#include <generated/protocol.h>
#include <generated/client_data.h>
#include <game/client/components/sounds.h>
#include <game/client/ui.h>

View file

@ -9,7 +9,7 @@
#include <game/client/render.h>
#include <game/client/ui.h>
#include <game/generated/client_data.h>
#include <generated/client_data.h>
#include "menus.h"

View file

@ -5,8 +5,8 @@
#include <engine/textrender.h>
#include <engine/keys.h>
#include <game/generated/protocol.h>
#include <game/generated/client_data.h>
#include <generated/protocol.h>
#include <generated/client_data.h>
#include <game/client/gameclient.h>
#include "motd.h"

View file

@ -2,8 +2,8 @@
/* If you are missing that file, acquire a complete release at teeworlds.com. */
#include <engine/textrender.h>
#include <engine/shared/config.h>
#include <game/generated/protocol.h>
#include <game/generated/client_data.h>
#include <generated/protocol.h>
#include <generated/client_data.h>
#include <game/client/gameclient.h>
#include <game/client/animstate.h>

View file

@ -4,7 +4,7 @@
#include <engine/graphics.h>
#include <engine/demo.h>
#include <game/generated/client_data.h>
#include <generated/client_data.h>
#include <game/client/render.h>
#include "particles.h"

View file

@ -4,8 +4,8 @@
#include <engine/engine.h>
#include <engine/graphics.h>
#include <engine/shared/config.h>
#include <game/generated/protocol.h>
#include <game/generated/client_data.h>
#include <generated/protocol.h>
#include <generated/client_data.h>
#include <game/client/animstate.h>
#include <game/client/gameclient.h>

View file

@ -5,8 +5,8 @@
#include <engine/textrender.h>
#include <engine/shared/config.h>
#include <game/generated/client_data.h>
#include <game/generated/protocol.h>
#include <generated/client_data.h>
#include <generated/protocol.h>
#include <game/client/animstate.h>
#include <game/client/gameclient.h>

View file

@ -3,7 +3,7 @@
#include <engine/engine.h>
#include <engine/sound.h>
#include <engine/shared/config.h>
#include <game/generated/client_data.h>
#include <generated/client_data.h>
#include <game/client/gameclient.h>
#include <game/client/components/camera.h>
#include <game/client/components/menus.h>

View file

@ -5,8 +5,8 @@
#include <engine/textrender.h>
#include <engine/shared/config.h>
#include <game/generated/client_data.h>
#include <game/generated/protocol.h>
#include <generated/client_data.h>
#include <generated/protocol.h>
#include <game/client/animstate.h>
#include <game/client/render.h>

View file

@ -5,7 +5,7 @@
#include <engine/shared/config.h>
#include <game/client/render.h>
#include <game/generated/protocol.h>
#include <generated/protocol.h>
#include "chat.h"
#include "voting.h"

View file

@ -13,8 +13,8 @@
#include <engine/shared/demo.h>
#include <engine/shared/config.h>
#include <game/generated/protocol.h>
#include <game/generated/client_data.h>
#include <generated/protocol.h>
#include <generated/client_data.h>
#include <game/version.h>
#include "localization.h"

View file

@ -7,8 +7,8 @@
#include <engine/shared/config.h>
#include <engine/graphics.h>
#include <engine/map.h>
#include <game/generated/client_data.h>
#include <game/generated/protocol.h>
#include <generated/client_data.h>
#include <generated/protocol.h>
#include <game/layers.h>
#include "animstate.h"
#include "render.h"

View file

@ -18,7 +18,7 @@
#include <game/client/localization.h>
#include <game/client/render.h>
#include <game/client/ui.h>
#include <game/generated/client_data.h>
#include <generated/client_data.h>
#include "auto_map.h"
#include "editor.h"

View file

@ -6,7 +6,7 @@
#include <engine/graphics.h>
#include "editor.h"
#include <game/generated/client_data.h>
#include <generated/client_data.h>
#include <game/client/localization.h>
#include <game/client/render.h>

View file

@ -6,7 +6,7 @@
#include <engine/graphics.h>
#include <engine/textrender.h>
#include <game/generated/client_data.h>
#include <generated/client_data.h>
#include <game/client/localization.h>
#include <game/client/render.h>
#include "editor.h"

View file

@ -9,7 +9,7 @@
#include <math.h>
#include "collision.h"
#include <engine/shared/protocol.h>
#include <game/generated/protocol.h>
#include <generated/protocol.h>
class CTuneParam

View file

@ -2,7 +2,7 @@
/* If you are missing that file, acquire a complete release at teeworlds.com. */
#include <engine/shared/config.h>
#include <game/generated/server_data.h>
#include <generated/server_data.h>
#include <game/server/gamecontext.h>
#include <game/server/gamecontroller.h>
#include <game/server/player.h>

View file

@ -1,6 +1,6 @@
/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
/* If you are missing that file, acquire a complete release at teeworlds.com. */
#include <game/generated/server_data.h>
#include <generated/server_data.h>
#include <game/server/gamecontext.h>
#include <game/server/player.h>

View file

@ -5,7 +5,7 @@
#include <base/vmath.h>
#include <game/generated/protocol.h>
#include <generated/protocol.h>
/*
Class: Game Controller

View file

@ -2,7 +2,7 @@
/* If you are missing that file, acquire a complete release at teeworlds.com. */
#ifndef GAME_VERSION_H
#define GAME_VERSION_H
#include "generated/nethash.cpp"
#include <generated/nethash.cpp>
#define GAME_VERSION "0.7 trunk"
#define GAME_NETVERSION "0.7 " GAME_NETVERSION_HASH
static const char GAME_RELEASE_VERSION[8] = {'0', '.', '6', '1', 0};