2007-05-22 15:05:28 +00:00
|
|
|
|
2007-08-02 08:20:53 +00:00
|
|
|
-- data compiler
|
2007-07-24 22:53:43 +00:00
|
|
|
dc_compiler = "python scripts/compiler.py"
|
2007-07-13 21:20:57 +00:00
|
|
|
if family == "windows" then
|
|
|
|
dc_compiler = "scripts\\compiler.py"
|
|
|
|
end
|
|
|
|
|
2007-07-24 22:53:43 +00:00
|
|
|
dat2c_compiler = "python scripts/dat2c.py"
|
|
|
|
if family == "windows" then
|
|
|
|
dat2c_compiler = "scripts\\dat2c.py"
|
|
|
|
end
|
|
|
|
|
2007-08-07 17:46:04 +00:00
|
|
|
function rc(output, input)
|
|
|
|
print("rc " .. PathFilename(input))
|
|
|
|
return os.execute("rc /fo " .. output .. " " .. input)
|
|
|
|
end
|
|
|
|
|
2007-07-24 22:53:43 +00:00
|
|
|
function dat2c(output, data, name)
|
|
|
|
print("dat2c " .. PathFilename(output) .. " = " .. PathFilename(data))
|
|
|
|
return os.execute(dat2c_compiler .. " " .. data .. " " .. name .. " > " .. output)
|
|
|
|
end
|
|
|
|
|
2007-07-13 13:40:04 +00:00
|
|
|
function dc_header(output, data, script)
|
|
|
|
print("dc_header " .. PathFilename(output) .. " = " .. PathFilename(data) .. " ~ " .. PathFilename(script))
|
2007-07-13 21:20:57 +00:00
|
|
|
return os.execute(dc_compiler .. " " .. data .. " " .. script .. " -h " .. output)
|
2007-07-13 13:40:04 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function dc_source(output, data, script)
|
|
|
|
print("dc_source " .. PathFilename(output) .. " = " .. PathFilename(data) .. " ~ " .. PathFilename(script))
|
2007-07-13 21:20:57 +00:00
|
|
|
return os.execute(dc_compiler .. " " .. data .. " " .. script .. " -s " .. output)
|
2007-07-13 13:40:04 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function dc_data(output, data, script)
|
|
|
|
print("dc_data " .. PathFilename(output) .. " = " .. PathFilename(data) .. " ~ " .. PathFilename(script))
|
2007-07-13 21:20:57 +00:00
|
|
|
return os.execute(dc_compiler .. " " .. data .. " " .. script .. " -d " .. output)
|
2007-07-13 13:40:04 +00:00
|
|
|
end
|
|
|
|
|
2007-07-24 23:46:29 +00:00
|
|
|
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
|
|
|
|
|
2007-08-07 17:46:04 +00:00
|
|
|
function ResCompile(scriptfile)
|
|
|
|
scriptfile = Path(scriptfile)
|
|
|
|
output = PathBase(scriptfile) .. ".res"
|
|
|
|
bam_add_job("rc", output, scriptfile)
|
|
|
|
bam_add_dependency(output, scriptfile)
|
|
|
|
return output
|
|
|
|
end
|
|
|
|
|
2007-07-24 22:53:43 +00:00
|
|
|
function Dat2c(datafile, sourcefile, arrayname)
|
2007-07-13 13:40:04 +00:00
|
|
|
datafile = Path(datafile)
|
2007-07-24 22:53:43 +00:00
|
|
|
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
|
|
|
|
|
|
|
|
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)
|
2007-07-24 23:46:29 +00:00
|
|
|
bam_add_job("dc_cdata", outputdatafile, datafile, scriptfile)
|
2007-07-13 13:40:04 +00:00
|
|
|
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)
|
2007-07-24 23:46:29 +00:00
|
|
|
return {cdata = outputdatafile, header=headerfile, source=sourcefile}
|
2007-07-13 13:40:04 +00:00
|
|
|
end
|
2007-05-22 15:05:28 +00:00
|
|
|
|
2007-07-24 23:46:29 +00:00
|
|
|
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",
|
2007-08-02 08:20:53 +00:00
|
|
|
"src/game/client/data/client_data.cpp",
|
|
|
|
"src/game/client/data/client_internal.cpp")
|
|
|
|
|
2007-08-07 17:46:04 +00:00
|
|
|
client_link_other = {}
|
|
|
|
if family == "windows" then
|
|
|
|
client_link_other = {ResCompile("other/icons/teewars.rc")}
|
|
|
|
end
|
|
|
|
|
2007-08-02 08:20:53 +00:00
|
|
|
function build(settings)
|
|
|
|
settings.objdir = Path("objs")
|
|
|
|
|
|
|
|
if family == "windows" then
|
|
|
|
settings.cc.flags = "/wd4244"
|
|
|
|
else
|
|
|
|
settings.cc.flags = "-Wall"
|
|
|
|
settings.linker.flags = ""
|
|
|
|
end
|
2007-07-24 23:46:29 +00:00
|
|
|
|
2007-08-02 08:20:53 +00:00
|
|
|
server_settings = settings:copy()
|
|
|
|
|
2007-08-22 07:52:33 +00:00
|
|
|
-- set some platform specific settings
|
2007-08-02 08:20:53 +00:00
|
|
|
settings.cc.includes:add("src")
|
2007-08-22 07:52:33 +00:00
|
|
|
settings.cc.includes:add("src/external/zlib")
|
|
|
|
settings.cc.includes:add("src/external/glfw/include")
|
|
|
|
|
|
|
|
if family == "unix" then
|
|
|
|
if platform == "macosx" then
|
|
|
|
glfw_platform = "macosx"
|
|
|
|
settings.linker.frameworks:add("OpenGL")
|
|
|
|
settings.linker.frameworks:add("AGL")
|
|
|
|
settings.linker.frameworks:add("Carbon")
|
|
|
|
settings.linker.frameworks:add("CoreAudio")
|
|
|
|
settings.linker.frameworks:add("AudioToolbox")
|
|
|
|
settings.linker.frameworks:add("AudioUnit")
|
|
|
|
else
|
|
|
|
glfw_platform = "x11"
|
|
|
|
settings.linker.libs:add("pthread")
|
|
|
|
settings.linker.libs:add("asound")
|
|
|
|
settings.linker.libs:add("X11")
|
|
|
|
settings.linker.libs:add("GL")
|
|
|
|
settings.linker.libs:add("GLU")
|
|
|
|
end
|
|
|
|
elseif family == "windows" then
|
|
|
|
glfw_platform = "win32"
|
|
|
|
settings.linker.libs:add("gdi32.lib")
|
|
|
|
settings.linker.libs:add("user32.lib")
|
|
|
|
settings.linker.libs:add("opengl32.lib")
|
|
|
|
settings.linker.libs:add("glu32.lib")
|
|
|
|
settings.linker.libs:add("ws2_32.lib")
|
|
|
|
settings.linker.libs:add("dsound.lib")
|
|
|
|
settings.linker.libs:add("ole32.lib")
|
|
|
|
end
|
|
|
|
|
|
|
|
-- build glfw
|
|
|
|
glfw_settings = settings:copy()
|
|
|
|
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"))
|
2007-07-21 18:07:27 +00:00
|
|
|
|
2007-08-22 07:52:33 +00:00
|
|
|
-- build teewars components
|
|
|
|
engine_settings = settings:copy()
|
|
|
|
|
|
|
|
if family == "windows" then
|
|
|
|
engine_settings.cc.flags = "/wd4244 /TP"
|
|
|
|
else
|
|
|
|
engine_settings.cc.flags = "-Wall"
|
|
|
|
engine_settings.linker.flags = ""
|
|
|
|
end
|
|
|
|
|
|
|
|
engine = Compile(engine_settings, Collect(
|
|
|
|
"src/engine/*.c",
|
|
|
|
"src/engine/external/zlib/*.c"))
|
|
|
|
|
|
|
|
client = Compile(engine_settings, Collect(
|
|
|
|
"src/engine/client/*.c",
|
|
|
|
"src/engine/external/pnglite/*.c",
|
|
|
|
"src/engine/external/pa.c",
|
|
|
|
"src/engine/external/wavpack/*.c"))
|
|
|
|
|
|
|
|
server = Compile(engine_settings, Collect("src/engine/server/*.c"))
|
|
|
|
|
2007-07-21 18:07:27 +00:00
|
|
|
masterserver = Compile(settings, Collect("src/mastersrv/*.cpp"))
|
|
|
|
game_shared = Compile(settings, Collect("src/game/*.cpp"))
|
2007-07-24 23:46:29 +00:00
|
|
|
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)
|
2007-07-21 18:07:27 +00:00
|
|
|
editor = Compile(settings, Collect("src/editor/*.cpp"))
|
|
|
|
|
2007-07-24 22:53:43 +00:00
|
|
|
-- 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))
|
2007-08-22 07:52:33 +00:00
|
|
|
tools[i] = Link(settings, toolname, v, engine)
|
2007-07-24 22:53:43 +00:00
|
|
|
end
|
|
|
|
|
2007-08-02 20:17:18 +00:00
|
|
|
-- build client, server and master server
|
2007-08-22 07:52:33 +00:00
|
|
|
client_exe = Link(settings, "teewars", game_shared, game_client, engine, client, editor, glfw, pa, client_link_other)
|
2007-08-02 08:20:53 +00:00
|
|
|
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
|
2007-07-21 18:07:27 +00:00
|
|
|
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)
|