ddnet/default.bam

176 lines
5.8 KiB
Plaintext

-- data compiler
dc_compiler = "python scripts/compiler.py"
if family == "windows" then
dc_compiler = "scripts\\compiler.py"
end
dat2c_compiler = "python scripts/dat2c.py"
if family == "windows" then
dat2c_compiler = "scripts\\dat2c.py"
end
function rc(output, input)
print("rc " .. PathFilename(input))
return os.execute("rc /fo " .. output .. " " .. input)
end
function dat2c(output, data, name)
print("dat2c " .. PathFilename(output) .. " = " .. PathFilename(data))
return os.execute(dat2c_compiler .. " " .. data .. " " .. name .. " > " .. output)
end
function dc_header(output, data, script)
print("dc_header " .. PathFilename(output) .. " = " .. PathFilename(data) .. " ~ " .. PathFilename(script))
return os.execute(dc_compiler .. " " .. data .. " " .. script .. " -h " .. output)
end
function dc_source(output, data, script)
print("dc_source " .. PathFilename(output) .. " = " .. PathFilename(data) .. " ~ " .. PathFilename(script))
return os.execute(dc_compiler .. " " .. data .. " " .. script .. " -s " .. output)
end
function dc_data(output, data, script)
print("dc_data " .. PathFilename(output) .. " = " .. PathFilename(data) .. " ~ " .. PathFilename(script))
return os.execute(dc_compiler .. " " .. data .. " " .. script .. " -d " .. output)
end
function dc_cdata(output, data, script)
print("dc_cdata " .. PathFilename(output) .. " = " .. PathFilename(data) .. " ~ " .. PathFilename(script))
return os.execute(dc_compiler .. " " .. data .. " " .. script .. " -c " .. 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)
datafile = Path(datafile)
sourcefile = Path(sourcefile)
bam_add_job("dat2c", sourcefile, datafile, arrayname)
bam_add_dependency(sourcefile, datafile)
return sourcefile
end
function DataCompile(datafile, scriptfile, headerfile, sourcefile, outputdatafile)
datafile = Path(datafile)
scriptfile = Path(scriptfile)
headerfile = Path(headerfile)
sourcefile = Path(sourcefile)
outputdatafile = Path(outputdatafile)
bam_add_job("dc_source", sourcefile, datafile, scriptfile)
bam_add_job("dc_header", headerfile, datafile, scriptfile)
bam_add_job("dc_cdata", outputdatafile, datafile, scriptfile)
bam_add_dependency(sourcefile, datafile)
bam_add_dependency(sourcefile, scriptfile)
bam_add_dependency(sourcefile, headerfile)
bam_add_dependency(headerfile, datafile)
bam_add_dependency(headerfile, scriptfile)
bam_add_dependency(outputdatafile, datafile)
bam_add_dependency(outputdatafile, scriptfile)
return {cdata = outputdatafile, header=headerfile, source=sourcefile}
end
serverdata = DataCompile(
"datasrc/teewars.ds",
"datasrc/server.dts",
"src/game/server/data.h",
"src/game/server/data/server_data.cpp",
"src/game/server/data/server_internal.cpp")
clientdata = DataCompile(
"datasrc/teewars.ds",
"datasrc/client.dts",
"src/game/client/data.h",
"src/game/client/data/client_data.cpp",
"src/game/client/data/client_internal.cpp")
client_link_other = {}
if family == "windows" then
client_link_other = {ResCompile("other/icons/teewars.rc")}
end
function build(settings)
settings.objdir = Path("objs")
if family == "windows" then
settings.cc.flags = "/wd4244"
else
settings.cc.flags = "-Wall"
settings.linker.flags = ""
end
server_settings = settings:copy()
basepath = Path("objs/baselib")
baselib_options = {}
baselib_options.settings = settings:copy()
baselib_options.settings.objdir = Path("objs/baselib")
baselib_options.settings.libdir = Path("objs/baselib")
baselib = Import("../baselib/baselib.bam", baselib_options)
baselib.apply(settings, "all")
baselib.apply(server_settings, "network")
settings.cc.includes:add("src")
settings.cc.includes:add("../baselib/src/external/zlib")
engine = Compile(settings, Collect("src/engine/*.cpp"))
client = Compile(settings, Collect("src/engine/client/*.cpp", "src/engine/client/pnglite/*.c"))
server = Compile(settings, Collect("src/engine/server/*.cpp"))
masterserver = Compile(settings, Collect("src/mastersrv/*.cpp"))
game_shared = Compile(settings, Collect("src/game/*.cpp"))
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)
editor = Compile(settings, Collect("src/editor/*.cpp"))
-- build tools
tools_src = Collect("src/tools/*.cpp", "src/tools/*.c")
objs = Compile(settings, tools_src)
tools = {}
for i,v in objs do
toolname = PathFilename(file_base(v))
tools[i] = Link(settings, toolname, v)
end
-- build client, server and master server
client_exe = Link(settings, "teewars", engine, client, editor, game_shared, game_client, client_link_other)
server_exe = Link(server_settings, "teewars_srv", engine, server, game_shared, game_server)
masterserver_exe = Link(server_settings, "mastersrv", masterserver, engine)
-- 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)
Target(c)
Target(s)
Target(m)
Target(t)
all = PseudoTarget(settings.config_name, c, s, m, t)
Target(all)
return all
end
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)