mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
upgraded to bam 0.2.0
This commit is contained in:
parent
581ec394f6
commit
c3b6b87b5a
193
default.bam
193
default.bam
|
@ -1,21 +1,14 @@
|
|||
CheckVersion("0.1")
|
||||
CheckVersion("0.2")
|
||||
|
||||
require("other/sdl/sdl.bam")
|
||||
Import("other/sdl/sdl.bam")
|
||||
|
||||
--- Setup Config --------
|
||||
config = NewConfig()
|
||||
config:add(OptFindCompiler())
|
||||
config:add(OptTestCompileC("stackprotector", "int main(){return 0;}", "-fstack-protector -fstack-protector-all"))
|
||||
config:add(OptFindLibrary("zlib", "zlib.h", false))
|
||||
config:add(SDL.OptFind("sdl", true))
|
||||
|
||||
--- Auto detect ------
|
||||
if not config:load("config.bam") then
|
||||
print("--- Auto Configuration ---")
|
||||
config:autodetect()
|
||||
config:save("config.bam")
|
||||
print("--- ")
|
||||
end
|
||||
config:Add(OptFindCompiler())
|
||||
config:Add(OptTestCompileC("stackprotector", "int main(){return 0;}", "-fstack-protector -fstack-protector-all"))
|
||||
config:Add(OptFindLibrary("zlib", "zlib.h", false))
|
||||
config:Add(SDL.OptFind("sdl", true))
|
||||
config:Finalize("config.bam")
|
||||
|
||||
-- data compiler
|
||||
function Script(name)
|
||||
|
@ -25,28 +18,22 @@ function Script(name)
|
|||
return "python " .. name
|
||||
end
|
||||
|
||||
--dc_compiler = Script("scripts/compiler.py")
|
||||
--netobj_compiler = Script("scripts/netobj.py")
|
||||
dat2c_compiler = Script("scripts/dat2c.py")
|
||||
cmd5_tool = Script("scripts/cmd5.py")
|
||||
content_compiler = Script("datasrc/compile.py")
|
||||
|
||||
function CHash(output, ...)
|
||||
local inputs = collect_input(arg)
|
||||
local inputs = FlatternTable({...})
|
||||
|
||||
output = Path(output)
|
||||
|
||||
-- compile all the files
|
||||
local cmd = cmd5_tool .. " "
|
||||
for index, inname in inputs do
|
||||
local cmd = Script("scripts/cmd5.py") .. " "
|
||||
for index, inname in ipairs(inputs) do
|
||||
cmd = cmd .. Path(inname) .. " "
|
||||
end
|
||||
|
||||
cmd = cmd .. " > " .. output
|
||||
|
||||
bam_add_job(output, "cmd5 " .. output, cmd)
|
||||
for index, inname in inputs do
|
||||
bam_add_dependency(output, inname)
|
||||
AddJob(output, "cmd5 " .. output, cmd)
|
||||
for index, inname in ipairs(inputs) do
|
||||
AddDependency(output, inname)
|
||||
end
|
||||
return output
|
||||
end
|
||||
|
@ -54,8 +41,8 @@ end
|
|||
function ResCompile(scriptfile)
|
||||
scriptfile = Path(scriptfile)
|
||||
output = PathBase(scriptfile) .. ".res"
|
||||
bam_add_job(output, "rc " .. scriptfile, "rc /fo " .. output .. " " .. scriptfile)
|
||||
bam_add_dependency(output, scriptfile)
|
||||
AddJob(output, "rc " .. scriptfile, "rc /fo " .. output .. " " .. scriptfile)
|
||||
AddDependency(output, scriptfile)
|
||||
return output
|
||||
end
|
||||
|
||||
|
@ -63,26 +50,26 @@ function Dat2c(datafile, sourcefile, arrayname)
|
|||
datafile = Path(datafile)
|
||||
sourcefile = Path(sourcefile)
|
||||
|
||||
bam_add_job(
|
||||
AddJob(
|
||||
sourcefile,
|
||||
"dat2c " .. PathFilename(sourcefile) .. " = " .. PathFilename(datafile),
|
||||
dat2c_compiler .. " " .. datafile .. " " .. arrayname .. " > " .. sourcefile
|
||||
Script("scripts/dat2c.py") .. " " .. datafile .. " " .. arrayname .. " > " .. sourcefile
|
||||
)
|
||||
bam_add_dependency(sourcefile, datafile)
|
||||
AddDependency(sourcefile, datafile)
|
||||
return sourcefile
|
||||
end
|
||||
|
||||
function ContentCompile(action, output)
|
||||
output = Path(output)
|
||||
bam_add_job(
|
||||
AddJob(
|
||||
output,
|
||||
action .. " > " .. output,
|
||||
Script("datasrc/compile.py") .. " " .. action .. " > " .. Path(output)
|
||||
)
|
||||
bam_add_dependency(output, Path("datasrc/content.py")) -- do this more proper
|
||||
bam_add_dependency(output, Path("datasrc/network.py"))
|
||||
bam_add_dependency(output, Path("datasrc/compile.py"))
|
||||
bam_add_dependency(output, Path("datasrc/datatypes.py"))
|
||||
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"))
|
||||
return output
|
||||
end
|
||||
|
||||
|
@ -94,82 +81,73 @@ client_content_header = ContentCompile("client_content_header", "src/game/genera
|
|||
server_content_source = ContentCompile("server_content_source", "src/game/generated/gs_data.cpp")
|
||||
server_content_header = ContentCompile("server_content_header", "src/game/generated/gs_data.hpp")
|
||||
|
||||
bam_add_dependency(network_source, network_header)
|
||||
bam_add_dependency(client_content_source, client_content_header)
|
||||
bam_add_dependency(server_content_source, server_content_header)
|
||||
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.c",
|
||||
"src/engine/e_protocol.h",
|
||||
"src/game/generated/g_protocol.hpp",
|
||||
"src/game/tuning.hpp",
|
||||
"src/game/gamecore.cpp", network_header)
|
||||
nethash = CHash("src/game/generated/nethash.c", "src/engine/e_protocol.h", "src/game/generated/g_protocol.hpp", "src/game/tuning.hpp", "src/game/gamecore.cpp", network_header)
|
||||
|
||||
client_link_other = {}
|
||||
|
||||
if config.compiler.value == "cl" then
|
||||
client_link_other = {ResCompile("other/icons/teeworlds.rc")}
|
||||
end
|
||||
|
||||
function intermediate_output_func(dir, input, settings)
|
||||
if not (dir == "") then
|
||||
return Path(dir .. "/" .. PathBase(PathFilename(input)) .. settings.config_ext)
|
||||
end
|
||||
return PathBase(input) .. settings.config_ext
|
||||
function Intermediate_Output(settings, input)
|
||||
return Path("objs/" .. PathBase(PathFilename(input)) .. settings.config_ext)
|
||||
end
|
||||
|
||||
function build(settings)
|
||||
settings.objdir = Path("objs")
|
||||
settings.cc.output = intermediate_output_func
|
||||
|
||||
--settings.objdir = Path("objs")
|
||||
settings.cc.Output = Intermediate_Output
|
||||
|
||||
if config.compiler.value == "cl" then
|
||||
settings.cc.flags = "/wd4244"
|
||||
settings.linker.flags = ""
|
||||
settings.cc.flags:Add("/wd4244")
|
||||
else
|
||||
settings.cc.flags = "-Wall -fno-exceptions "
|
||||
settings.linker.flags = ""
|
||||
settings.cc.flags:Add("-Wall", "-fno-exceptions")
|
||||
if platform == "macosx" then
|
||||
settings.cc.flags = settings.cc.flags .. " -mmacosx-version-min=10.4 -isysroot /Developer/SDKs/MacOSX10.4u.sdk"
|
||||
settings.linker.flags = settings.linker.flags .. " -mmacosx-version-min=10.4 -isysroot /Developer/SDKs/MacOSX10.4u.sdk"
|
||||
settings.cc.flags:Add("-mmacosx-version-min=10.4", "-isysroot /Developer/SDKs/MacOSX10.4u.sdk")
|
||||
settings.link.flags:Add("-mmacosx-version-min=10.4", "-isysroot /Developer/SDKs/MacOSX10.4u.sdk")
|
||||
elseif config.stackprotector.value == 1 then
|
||||
settings.cc.flags = settings.cc.flags .. " -fstack-protector -fstack-protector-all"
|
||||
settings.linker.flags = settings.linker.flags .. " -fstack-protector -fstack-protector-all"
|
||||
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")
|
||||
settings.cc.includes:Add("src")
|
||||
|
||||
if family == "unix" then
|
||||
if platform == "macosx" then
|
||||
glfw_platform = "macosx"
|
||||
pa_platform = "mac_osx"
|
||||
settings.linker.frameworks:add("Carbon")
|
||||
settings.linker.frameworks:add("AppKit")
|
||||
settings.link.frameworks:Add("Carbon")
|
||||
settings.link.frameworks:Add("AppKit")
|
||||
else
|
||||
glfw_platform = "x11"
|
||||
pa_platform = "unix"
|
||||
settings.linker.libs:add("pthread")
|
||||
settings.link.libs:Add("pthread")
|
||||
end
|
||||
elseif family == "windows" then
|
||||
glfw_platform = "win32"
|
||||
pa_platform = "win"
|
||||
settings.linker.libs:add("gdi32")
|
||||
settings.linker.libs:add("user32")
|
||||
settings.linker.libs:add("ws2_32")
|
||||
settings.linker.libs:add("ole32")
|
||||
settings.linker.libs:add("shell32")
|
||||
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
|
||||
if config.zlib.value == 1 then
|
||||
settings.linker.libs:add("z")
|
||||
settings.link.libs:Add("z")
|
||||
if config.zlib.include_path then
|
||||
settings.cc.includes:add(config.zlib.include_path)
|
||||
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")
|
||||
settings.cc.includes:Add("src/engine/external/zlib")
|
||||
end
|
||||
|
||||
-- build the small libraries
|
||||
|
@ -177,51 +155,29 @@ function build(settings)
|
|||
pnglite = Compile(settings, Collect("src/engine/external/pnglite/*.c"))
|
||||
|
||||
-- build game components
|
||||
engine_settings = settings:copy()
|
||||
|
||||
if config.compiler.value == "cl" then
|
||||
engine_settings.cc.flags = "/wd4244"
|
||||
else
|
||||
if platform == "macosx" then
|
||||
engine_settings.cc.flags = "-Wall -mmacosx-version-min=10.4 -isysroot /Developer/SDKs/MacOSX10.4u.sdk"
|
||||
engine_settings.linker.flags = "-mmacosx-version-min=10.4 -isysroot /Developer/SDKs/MacOSX10.4u.sdk"
|
||||
else
|
||||
engine_settings.cc.flags = "-Wall"
|
||||
engine_settings.linker.flags = ""
|
||||
|
||||
if config.stackprotector.value == 1 then
|
||||
engine_settings.cc.flags = settings.cc.flags .. " -fstack-protector -fstack-protector-all"
|
||||
engine_settings.linker.flags = settings.linker.flags .. " -fstack-protector -fstack-protector-all"
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
-- server
|
||||
server_settings = engine_settings:copy()
|
||||
|
||||
-- client
|
||||
client_settings = engine_settings:copy()
|
||||
engine_settings = settings:Copy()
|
||||
server_settings = engine_settings:Copy()
|
||||
client_settings = engine_settings:Copy()
|
||||
|
||||
if family == "unix" then
|
||||
if platform == "macosx" then
|
||||
client_settings.linker.frameworks:add("OpenGL")
|
||||
client_settings.linker.frameworks:add("AGL")
|
||||
client_settings.linker.frameworks:add("Carbon")
|
||||
client_settings.linker.frameworks:add("Cocoa")
|
||||
client_settings.link.frameworks:Add("OpenGL")
|
||||
client_settings.link.frameworks:Add("AGL")
|
||||
client_settings.link.frameworks:Add("Carbon")
|
||||
client_settings.link.frameworks:Add("Cocoa")
|
||||
else
|
||||
client_settings.linker.libs:add("X11")
|
||||
client_settings.linker.libs:add("GL")
|
||||
client_settings.linker.libs:add("GLU")
|
||||
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.linker.libs:add("opengl32")
|
||||
client_settings.linker.libs:add("glu32")
|
||||
client_settings.linker.libs:add("winmm")
|
||||
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)
|
||||
config.sdl:Apply(client_settings)
|
||||
|
||||
engine = Compile(engine_settings, Collect("src/engine/*.c", "src/base/*.c"))
|
||||
client = Compile(client_settings, Collect("src/engine/client/*.c"))
|
||||
|
@ -230,13 +186,8 @@ function build(settings)
|
|||
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, Collect(
|
||||
"src/game/client/*.cpp",
|
||||
"src/game/client/components/*.cpp"), client_content_source)
|
||||
game_server = Compile(settings, Collect(
|
||||
"src/game/server/*.cpp",
|
||||
"src/game/server/entities/*.cpp",
|
||||
"src/game/server/gamemodes/*.cpp"), server_content_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)
|
||||
|
@ -247,11 +198,10 @@ function build(settings)
|
|||
osxlaunch = Compile(client_settings, Collect("src/osxlaunch/*.m"))
|
||||
end
|
||||
|
||||
objs = Compile(settings, tools_src)
|
||||
tools = {}
|
||||
for i,v in objs do
|
||||
for i,v in ipairs(tools_src) do
|
||||
toolname = PathFilename(PathBase(v))
|
||||
tools[i] = Link(settings, toolname, v, engine, zlib)
|
||||
tools[i] = Link(settings, toolname, Compile(settings, v), engine, zlib)
|
||||
end
|
||||
|
||||
-- build client, server, version server and master server
|
||||
|
@ -271,6 +221,8 @@ function build(settings)
|
|||
-- make targets
|
||||
c = PseudoTarget("client".."_"..settings.config_name, client_exe)
|
||||
s = PseudoTarget("server".."_"..settings.config_name, server_exe)
|
||||
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)
|
||||
|
@ -300,5 +252,6 @@ release_settings.config_ext = ""
|
|||
release_settings.debug = 0
|
||||
release_settings.cc.optimize = 1
|
||||
|
||||
DefaultTarget(build(debug_settings))
|
||||
build(debug_settings)
|
||||
build(release_settings)
|
||||
DefaultTarget("game_debug")
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
SDL = {
|
||||
basepath = PathPath(_REQUIREDNAME),
|
||||
basepath = PathPath(ModuleFilename()),
|
||||
|
||||
OptFind = function (name, required)
|
||||
local check = function(option)
|
||||
local check = function(option, settings)
|
||||
option.value = nil
|
||||
option.use_sdlconfig = nil
|
||||
option.use_win32sdl = nil
|
||||
|
@ -27,20 +27,20 @@ SDL = {
|
|||
|
||||
local apply = function(option, settings)
|
||||
if option.use_sdlconfig then
|
||||
settings.cc.flags = settings.cc.flags .. " -I/usr/include/SDL "
|
||||
settings.linker.flags = settings.linker.flags .. " `sdl-config --libs` "
|
||||
settings.cc.flags:Add("`sdl-config --cflags`")
|
||||
settings.link.flags:Add("`sdl-config --libs`")
|
||||
end
|
||||
|
||||
if option.use_osxframework then
|
||||
client_settings.linker.frameworks:add("SDL")
|
||||
client_settings.cc.includes:add("/Library/Frameworks/SDL.framework/Headers")
|
||||
client_settings.link.frameworks:Add("SDL")
|
||||
client_settings.cc.includes:Add("/Library/Frameworks/SDL.framework/Headers")
|
||||
end
|
||||
|
||||
if option.use_win32sdl then
|
||||
settings.cc.includes:add(SDL.basepath .. "/include")
|
||||
settings.linker.libpath:add(SDL.basepath .. "/vc2005libs")
|
||||
settings.linker.libs:add("SDL")
|
||||
settings.linker.libs:add("SDLmain")
|
||||
settings.cc.includes:Add(SDL.basepath .. "/include")
|
||||
settings.link.libpath:Add(SDL.basepath .. "/vc2005libs")
|
||||
settings.link.libs:Add("SDL")
|
||||
settings.link.libs:Add("SDLmain")
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -67,7 +67,7 @@ SDL = {
|
|||
end
|
||||
|
||||
local o = MakeOption(name, 0, check, save, display)
|
||||
o.apply = apply
|
||||
o.Apply = apply
|
||||
o.include_path = nil
|
||||
o.lib_path = nil
|
||||
o.required = required
|
||||
|
|
Loading…
Reference in a new issue