ddnet/default.bam

472 lines
14 KiB
Plaintext
Raw Normal View History

--- 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(OptFindLibrary("glfw", "glfw.h", false))
config:add(OptFindLibrary("portaudio", "portaudio.h_FAIL", false))
config:add(OptFindLibrary("coreaudio", "AudioUnit/AudioUnit.h", false))
config:add(OptFindLibrary("alsa", "alsa/asoundlib.h", false))
config:add(OptFindLibrary("oss_sys", "sys/soundcard.h", false))
config:add(OptFindLibrary("oss_linux", "linux/soundcard.h", false))
config:add(OptFindLibrary("oss_machine", "machine/soundcard.h", false))
config:add(OptFindLibrary("dsound", "dsound.h", true))
--- Auto detect ------
if not config:load("config.bam") then
print("--- Auto Configuration ---")
config:autodetect()
config:save("config.bam")
print("--- ")
end
2007-05-22 15:05:28 +00:00
2007-08-02 08:20:53 +00:00
-- data compiler
dc_compiler = "python scripts/compiler.py"
2007-07-13 21:20:57 +00:00
if family == "windows" then
dc_compiler = "scripts\\compiler.py"
end
2008-02-24 16:03:58 +00:00
netobj_compiler = "python scripts/netobj.py"
if family == "windows" then
netobj_compiler = "scripts\\netobj.py"
end
dat2c_compiler = "python scripts/dat2c.py"
if family == "windows" then
dat2c_compiler = "scripts\\dat2c.py"
end
2007-08-22 21:13:33 +00:00
cmd5_tool = "python scripts/cmd5.py"
if family == "windows" then
cmd5_tool = "scripts\\cmd5.py"
end
function rc(output, input)
print("rc " .. PathFilename(input))
return os.execute("rc /fo " .. output .. " " .. input)
end
2008-04-20 22:30:59 +00:00
function cmd5(output, inputs)
cmd = cmd5_tool .. " "
for i,v in inputs do
cmd = cmd .. v .. " "
end
cmd = cmd .. " > " .. output
return {"cmd5 " .. PathFilename(output), cmd}
end
function dat2c(output, data, name)
2008-04-20 22:30:59 +00:00
return {
"dat2c " .. PathFilename(output) .. " = " .. PathFilename(data),
dat2c_compiler .. " " .. data .. " " .. name .. " > " .. output,
}
end
2007-07-13 13:40:04 +00:00
function dc_header(output, data, script)
2008-04-20 22:30:59 +00:00
return {
"dc_header " .. PathFilename(output) .. " = " .. PathFilename(data) .. " ~ " .. PathFilename(script),
dc_compiler .. " " .. data .. " " .. script .. " -h " .. output
}
2007-07-13 13:40:04 +00:00
end
2007-12-15 10:24:49 +00:00
function dc_source(output, data, script, headerfile)
cmd = dc_compiler .. " " .. data .. " " .. script .. " -s " .. output .. " " .. headerfile
2008-04-20 22:30:59 +00:00
return {
"dc_source " .. PathFilename(output) .. "+" .. PathFilename(headerfile) .. " = " .. PathFilename(data) .. " ~ " .. PathFilename(script),
cmd
}
2007-07-13 13:40:04 +00:00
end
function dc_data(output, data, script)
2008-04-20 22:30:59 +00:00
return {
"dc_data " .. PathFilename(output) .. " = " .. PathFilename(data) .. " ~ " .. PathFilename(script),
dc_compiler .. " " .. data .. " " .. script .. " -d " .. output
}
2007-07-13 13:40:04 +00:00
end
function dc_cdata(output, data, script)
2008-04-20 22:30:59 +00:00
return {
"dc_cdata " .. PathFilename(output) .. " = " .. PathFilename(data) .. " ~ " .. PathFilename(script),
dc_compiler .. " " .. data .. " " .. script .. " -c " .. output
}
end
2008-02-24 16:03:58 +00:00
function netobj_source(output, proto)
2008-04-20 22:30:59 +00:00
return {
"netobj source " .. PathFilename(output) .. " = " .. PathFilename(proto),
netobj_compiler .. " source " .. proto .. " " .. output
}
2008-02-24 16:03:58 +00:00
end
function netobj_header(output, proto)
2008-04-20 22:30:59 +00:00
return {
"netobj header " .. PathFilename(output) .. " = " .. PathFilename(proto),
netobj_compiler .. " header " .. proto .. " " .. output
}
2008-02-24 16:03:58 +00:00
end
2007-08-22 21:13:33 +00:00
2008-04-20 22:30:59 +00:00
2007-08-22 21:13:33 +00:00
function CHash(output, ...)
local inputs = {}
local ih = collect_input(arg)
output = Path(output)
-- compile all the files
for index, inname in ih do
table.insert(inputs, Path(inname))
end
bam_add_job("cmd5", output, inputs)
for index, inname in inputs do
bam_add_dependency(output, inname)
end
return output
end
function ResCompile(scriptfile)
scriptfile = Path(scriptfile)
output = PathBase(scriptfile) .. ".res"
bam_add_job("rc", output, scriptfile)
bam_add_dependency(output, scriptfile)
return output
end
function Dat2c(datafile, sourcefile, arrayname)
2007-07-13 13:40:04 +00:00
datafile = Path(datafile)
sourcefile = Path(sourcefile)
bam_add_job("dat2c", sourcefile, datafile, arrayname)
bam_add_dependency(sourcefile, datafile)
return sourcefile
2007-07-13 13:40:04 +00:00
end
2008-02-24 16:03:58 +00:00
function NetObjCompile(protofile, sourcefile, headerfile)
protofile = Path(protofile)
sourcefile = Path(sourcefile)
headerfile = Path(headerfile)
bam_add_job("netobj_source", sourcefile, protofile)
bam_add_job("netobj_header", headerfile, protofile)
bam_add_dependency(sourcefile, protofile)
bam_add_dependency(headerfile, protofile)
2008-04-20 22:30:59 +00:00
bam_dependency_cpp(sourcefile, {"src"})
2008-02-24 16:03:58 +00:00
return {source = sourcefile, header=headerfile}
end
2007-07-13 13:40:04 +00:00
function DataCompile(datafile, scriptfile, headerfile, sourcefile, outputdatafile)
datafile = Path(datafile)
scriptfile = Path(scriptfile)
headerfile = Path(headerfile)
2007-12-15 10:24:49 +00:00
2007-07-13 13:40:04 +00:00
bam_add_job("dc_header", headerfile, datafile, scriptfile)
bam_add_dependency(headerfile, datafile)
bam_add_dependency(headerfile, scriptfile)
2007-08-22 21:13:33 +00:00
if sourcefile then
sourcefile = Path(sourcefile)
2007-12-15 10:24:49 +00:00
bam_add_job("dc_source", sourcefile, datafile, scriptfile, headerfile)
2007-08-22 21:13:33 +00:00
bam_add_dependency(sourcefile, datafile)
bam_add_dependency(sourcefile, scriptfile)
bam_add_dependency(sourcefile, headerfile)
end
if outputdatafile then
outputdatafile = Path(outputdatafile)
bam_add_job("dc_cdata", outputdatafile, datafile, scriptfile)
bam_add_dependency(outputdatafile, datafile)
bam_add_dependency(outputdatafile, scriptfile)
end
return {cdata = outputdatafile, header=headerfile, source=sourcefile}
2007-07-13 13:40:04 +00:00
end
2007-05-22 15:05:28 +00:00
serverdata = DataCompile(
"datasrc/data.ds",
"datasrc/server.dts",
2007-12-15 10:24:49 +00:00
"src/game/generated/gs_data.h",
"src/game/generated/gs_data.cpp",
"src/game/generated/gs_internaldata.cpp")
clientdata = DataCompile(
"datasrc/data.ds",
"datasrc/client.dts",
2007-12-15 10:24:49 +00:00
"src/game/generated/gc_data.h",
"src/game/generated/gc_data.cpp",
"src/game/generated/gc_internaldata.cpp")
2007-08-02 08:20:53 +00:00
2007-08-22 21:13:33 +00:00
networkdata = DataCompile(
"datasrc/data.ds",
2007-08-22 21:13:33 +00:00
"datasrc/network.dts",
2007-12-15 10:24:49 +00:00
"src/game/generated/g_protocol_ids.h",
"src/game/generated/g_protocol_ids.cpp")
2008-02-24 16:03:58 +00:00
netobj = NetObjCompile(
"src/game/g_protocol.def",
"src/game/generated/g_protocol.cpp",
"src/game/generated/g_protocol.h")
2007-08-22 21:13:33 +00:00
2007-12-15 13:36:31 +00:00
nethash = CHash(
"src/game/generated/nethash.c",
"src/engine/e_protocol.h",
2008-02-24 16:03:58 +00:00
"src/game/generated/g_protocol.h",
"src/game/g_tuning.h",
2007-12-15 13:36:31 +00:00
"src/game/g_game.cpp", networkdata.header)
2007-08-22 21:13:33 +00:00
client_link_other = {}
if config.compiler.value == "cl" then
client_link_other = {ResCompile("other/icons/teeworlds.rc")}
end
2007-12-15 10:24:49 +00:00
function intermediate_output_func(dir, input, extension)
if not (dir == "") then
return Path(dir .. "/" .. PathBase(PathFilename(input)) .. extension)
end
return PathBase(input) .. extension
end
2007-08-02 08:20:53 +00:00
function build(settings)
settings.objdir = Path("objs")
2007-12-15 10:24:49 +00:00
settings.cc.output = intermediate_output_func
2007-08-02 08:20:53 +00:00
if config.compiler.value == "cl" then
2007-08-02 08:20:53 +00:00
settings.cc.flags = "/wd4244"
else
settings.cc.flags = "-Wall -fno-exceptions "
if config.stackprotector.value == 1 then
settings.cc.flags = settings.cc.flags .. "-fstack-protector -fstack-protector-all"
2008-03-22 19:51:07 +00:00
end
2007-08-02 08:20:53 +00:00
settings.linker.flags = ""
end
-- set some platform specific settings
2007-08-02 08:20:53 +00:00
settings.cc.includes:add("src")
if family == "unix" then
if platform == "macosx" then
glfw_platform = "macosx"
pa_platform = "mac_osx"
else
glfw_platform = "x11"
pa_platform = "unix"
settings.linker.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")
end
-- build glfw if needed (not tested)
if config.glfw.value == 1 then
settings.linker.libs:add("glfw")
if config.glfw.include_path then
settings.cc.includes:add(config.glfw.include_path)
end
glfw = {}
else
glfw_settings = settings:copy()
glfw_settings.cc.includes:add("src/external/glfw/include")
glfw_settings.cc.includes:add("src/engine/external/glfw/lib")
glfw_settings.cc.includes:add("src/engine/external/glfw/lib/" .. glfw_platform)
glfw = Compile(glfw_settings, Collect(
"src/engine/external/glfw/lib/*.c",
"src/engine/external/glfw/lib/" .. glfw_platform .. "/*.c"))
settings.cc.includes:add("src/engine/external/glfw/include")
end
-- build portaudio
if config.portaudio.value == 1 then
settings.linker.libs:add("portaudio")
if config.portaudio.include_path then
settings.cc.includes:add(config.portaudio.include_path)
end
portaudio = {}
else
pa_settings = settings:copy()
pa_hostapis = {}
if config.alsa.value == 1 then pa_hostapis["alsa"] = 1 end
if config.dsound.value == 1 then
pa_hostapis["dsound"] = 1
else
pa_settings.cc.defines:add("PA_NO_DS")
end
if config.coreaudio.value == 1 then pa_hostapis["coreaudio"] = 1 end
if config.oss_sys.value == 1 then
pa_hostapis["oss"] = 1
pa_settings.cc.defines:add("HAVE_SYS_SOUNDCARD_H")
elseif config.oss_linux.value == 1 then
pa_hostapis["oss"] = 1
pa_settings.cc.defines:add("HAVE_LINUX_SOUNDCARD_H")
elseif config.oss_machine.value == 1 then
pa_hostapis["oss"] = 1
pa_settings.cc.defines:add("HAVE_MACHINE_SOUNDCARD_H")
end
pa_settings.cc.defines:add("PA_NO_WMME")
pa_settings.cc.defines:add("PA_NO_ASIO")
pa_settings.cc.includes:add("src/engine/external/portaudio/include")
pa_settings.cc.includes:add("src/engine/external/portaudio/src/common")
pa_settings.cc.includes:add("src/engine/external/portaudio/src/os/" .. pa_platform)
pa_api_files = {}
for api,v in pa_hostapis do
pa_settings.cc.defines:add("PA_USE_"..string.upper(api))
pa_api_files[api] = Collect("src/engine/external/portaudio/src/hostapi/" .. api .. "/*.c")
end
portaudio = Compile(pa_settings,
Collect("src/engine/external/portaudio/src/common/*.c"),
Collect("src/engine/external/portaudio/src/os/" .. pa_platform .. "/*.c"),
pa_api_files)
settings.cc.includes:add("src/engine/external/portaudio/include")
end
-- compile zlib if needed
if config.zlib.value == 1 then
settings.linker.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")
end
-- build the small libraries
wavpack = Compile(settings, Collect("src/engine/external/wavpack/*.c"))
pnglite = Compile(settings, Collect("src/engine/external/pnglite/*.c"))
-- build game components
engine_settings = settings:copy()
if config.compiler.value == "cl" then
2007-10-06 17:01:06 +00:00
engine_settings.cc.flags = "/wd4244"
else
if platform == "macosx" or family == "windows" then
2007-10-07 20:27:28 +00:00
engine_settings.cc.flags = "-Wall"
else
engine_settings.cc.flags = "-Wall -pedantic-errors"
end
engine_settings.linker.flags = ""
end
2007-10-02 08:26:08 +00:00
-- server
server_settings = engine_settings:copy()
-- client
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")
2007-12-19 18:47:47 +00:00
client_settings.linker.frameworks:add("Cocoa")
if config.coreaudio.value == 1 then
client_settings.linker.frameworks:add("CoreAudio")
client_settings.linker.frameworks:add("AudioToolbox")
client_settings.linker.frameworks:add("AudioUnit")
end
2007-10-02 08:26:08 +00:00
else
if config.alsa.value == 1 then
client_settings.linker.libs:add("asound")
end
2007-10-02 08:26:08 +00:00
client_settings.linker.libs:add("X11")
client_settings.linker.libs:add("GL")
client_settings.linker.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")
2007-10-02 08:26:08 +00:00
if config.dsound.value == 1 then
client_settings.linker.libs:add("dsound")
end
end
2007-10-02 08:26:08 +00:00
engine = Compile(engine_settings, Collect("src/engine/*.c"))
client = Compile(client_settings, Collect("src/engine/client/*.c"))
server = Compile(server_settings, Collect("src/engine/server/*.c"))
masterserver = Compile(settings, Collect("src/mastersrv/*.cpp"))
2008-02-24 16:03:58 +00:00
game_shared = Compile(settings, Collect("src/game/*.cpp"), nethash, netobj.source)
game_client = Compile(settings, Collect("src/game/client/*.cpp"), clientdata.source, clientdata.cdata)
game_server = Compile(settings, Collect("src/game/server/*.cpp"), serverdata.source, serverdata.cdata)
2008-01-12 15:07:57 +00:00
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")
objs = Compile(settings, tools_src)
tools = {}
for i,v in objs do
toolname = PathFilename(PathBase(v))
2007-10-02 08:26:08 +00:00
tools[i] = Link(settings, toolname, v, engine, zlib)
end
2007-08-02 20:17:18 +00:00
-- build client, server and master server
client_exe = Link(client_settings, "teeworlds", game_shared, game_client,
2008-01-12 15:07:57 +00:00
engine, client, game_editor, glfw, portaudio, zlib, pnglite, wavpack,
2007-10-02 08:26:08 +00:00
client_link_other)
server_exe = Link(server_settings, "teeworlds_srv", engine, server,
2007-10-02 08:26:08 +00:00
game_shared, game_server, zlib)
masterserver_exe = Link(server_settings, "mastersrv", masterserver,
engine, zlib)
2007-08-02 08:20:53 +00:00
2007-12-19 18:47:47 +00:00
if platform == "macosx" then
osxlaunch_exe = Link(client_settings, "TeeLaunch", osxlaunch)
end
2007-08-02 08:20:53 +00:00
-- make targets
c = PseudoTarget("client".."_"..settings.config_name, client_exe)
s = PseudoTarget("server".."_"..settings.config_name, server_exe)
m = PseudoTarget("masterserver".."_"..settings.config_name, masterserver_exe)
t = PseudoTarget("tools".."_"..settings.config_name, tools)
2007-12-19 18:47:47 +00:00
2007-12-19 19:45:30 +00:00
Target(c)
Target(s)
Target(m)
Target(t)
2007-12-19 18:47:47 +00:00
if platform == "macosx" then
o = PseudoTarget("TeeLaunch".."_"..settings.config_name, osxlaunch_exe)
2007-12-19 19:45:30 +00:00
all = PseudoTarget(settings.config_name, c, s, m, t, o)
2007-12-19 18:47:47 +00:00
else
2007-12-19 19:45:30 +00:00
all = PseudoTarget(settings.config_name, c, s, m, t)
2007-12-19 18:47:47 +00:00
end
2007-08-02 08:20:53 +00:00
Target(all)
return all
end
2007-05-22 15:05:28 +00:00
2007-08-02 08:20:53 +00:00
debug_settings = NewSettings()
debug_settings.config_name = "debug"
debug_settings.config_ext = "_d"
debug_settings.debug = 1
debug_settings.cc.optimize = 0
release_settings = NewSettings()
release_settings.config_name = "release"
release_settings.config_ext = ""
release_settings.debug = 0
release_settings.cc.optimize = 1
DefaultTarget(build(debug_settings))
build(release_settings)