Implemented debug and release build variants.

This commit is contained in:
Sergey Popov 2008-05-07 11:23:39 +00:00
parent dfa8407141
commit c2abf84dbf
2 changed files with 33 additions and 26 deletions

View file

@ -29,10 +29,10 @@ opts = Options('.scons-option-cache')
opts.AddOptions(
ListOption('default_targets', 'Targets that will be built if no target is specified in command line.',
"wesnoth,wesnothd", Split("wesnoth wesnothd wesnoth_editor campaignd cutter exploder")),
ListOption('build', 'Build variant: debug or release', "release", ["release", "debug"]),
PathOption('bindir', 'Where to install binaries', "bin", PathOption.PathAccept),
('cachedir', 'Directory that contains a cache of derived files.', ''),
PathOption('datadir', 'read-only architecture-independent game data', "share/$datadirname", PathOption.PathAccept),
BoolOption('debug', 'Set to build for debugging', False),
BoolOption('dummy_locales','Set to enable Wesnoth private locales', False),
PathOption('fifodir', 'directory for the wesnothd fifo socket file', "/var/run/wesnothd", PathOption.PathAccept),
BoolOption('fribidi','Clear to disable bidirectional-language support', True),
@ -205,12 +205,6 @@ env.Append(LINKFLAGS = "-Wl,--as-needed")
env.Replace(CPPDEFINES = [])
if env["debug"]:
env.AppendUnique(CXXFLAGS = Split("-O0 -DDEBUG -ggdb3 -W -Wall -ansi"))
else:
if env["PLATFORM"] != "win32":
env.AppendUnique(CXXFLAGS = Split("-O2 -ansi"))
if env['static']:
env.AppendUnique(LINKFLAGS = "-all-static")
@ -288,14 +282,32 @@ if env["PLATFORM"] == 'win32':
if env["PLATFORM"] == 'darwin': # Mac OS X
env.Append(FRAMEWORKS = "Carbon") # Carbon GUI
Export(Split("env have_client_prereqs have_X have_server_prereqs"))
SConscript(dirs = Split("src doc po"))
Import(Split("sources wesnoth wesnoth_editor wesnothd cutter exploder campaignd"))
try:
env["svnrev"] = Popen(Split("svnversion -n ."), stdout=PIPE).communicate()[0]
except:
env["svnrev"] = ""
# Omits the 'test' target
all = env.Alias("all", [wesnoth, wesnoth_editor, wesnothd, campaignd,
cutter, exploder])
env.Default(map(eval, env["default_targets"]))
Export(Split("env have_client_prereqs have_X have_server_prereqs"))
SConscript(dirs = Split("doc po"))
binaries = Split("wesnoth wesnoth_editor wesnothd cutter exploder campaignd")
builds = {
"debug" : Split("-O0 -DDEBUG -ggdb3 -W -Wall -ansi"),
"release" : Split("-O2 -ansi")
}
for build in env["build"]:
build_env = env.Clone()
build_env.AppendUnique(CXXFLAGS = builds[build])
SConscript("src/SConscript", build_dir = os.path.join("build", build), exports = {"env":build_env})
Import(binaries + ["sources"])
binary_nodes = map(eval, binaries)
if build == "release" : build_suffix = ""
else : build_suffix = "-" + build
map(lambda bin, node : Alias(bin, node, Copy("./" + bin + build_suffix, node[0].path)), binaries, binary_nodes)
env.Alias("all", map(env.Alias, binaries))
env.Default(map(env.Alias, env["default_targets"]))
all = env.Alias("all")
#
# Utility productions (Unix-like systems only)

View file

@ -196,7 +196,7 @@ wesnoth_sources = Split("""
#
if have_client_prereqs:
wesnoth = env.Program("../wesnoth", ["game.cpp"] + wesnoth_sources + [libwesnoth_core, libwesnoth_sdl, libwesnoth, libcampaignd])
wesnoth = env.Program("wesnoth", ["game.cpp"] + wesnoth_sources + [libwesnoth_core, libwesnoth_sdl, libwesnoth, libcampaignd])
else:
wesnoth = None
Export("wesnoth")
@ -213,7 +213,7 @@ wesnoth_editor_sources = Split("""
animated_editor.cpp
""")
if have_client_prereqs and have_X:
wesnoth_editor = env.Program("../wesnoth_editor", wesnoth_editor_sources + [libwesnoth_core, libwesnoth_sdl, libwesnoth])
wesnoth_editor = env.Program("wesnoth_editor", wesnoth_editor_sources + [libwesnoth_core, libwesnoth_sdl, libwesnoth])
else:
wesnoth_editor = None
Export("wesnoth_editor")
@ -222,7 +222,7 @@ campaignd_sources = Split("""
campaign_server/campaign_server.cpp
""")
if have_server_prereqs:
campaignd = env.Program("../campaignd", campaignd_sources + [libwesnoth_core, libwesnothd, libcampaignd, libwesnoth])
campaignd = env.Program("campaignd", campaignd_sources + [libwesnoth_core, libwesnothd, libcampaignd, libwesnoth])
else:
campaignd = None
Export("campaignd")
@ -237,7 +237,7 @@ wesnothd_sources = Split("""
server/simple_wml.cpp
""")
if have_server_prereqs:
wesnothd = env.Program("../wesnothd", wesnothd_sources + [libwesnoth_core, libwesnothd])
wesnothd = env.Program("wesnothd", wesnothd_sources + [libwesnoth_core, libwesnothd])
else:
wesnothd = None
Export("wesnothd")
@ -246,7 +246,7 @@ cutter_sources = Split("""
tools/cutter.cpp
""")
if have_client_prereqs:
cutter = env.Program("../cutter", cutter_sources + [libcutter, libwesnoth_core, libwesnoth_sdl, libwesnothd, libwesnoth],
cutter = env.Program("cutter", cutter_sources + [libcutter, libwesnoth_core, libwesnoth_sdl, libwesnothd, libwesnoth],
LIBS = env["LIBS"] + ["png"])
else:
cutter = None
@ -257,7 +257,7 @@ exploder_sources = Split("""
tools/exploder_composer.cpp
""")
if have_client_prereqs:
exploder = env.Program("../exploder", exploder_sources + [libcutter, libwesnoth_core, libwesnoth_sdl, libwesnothd, libwesnoth],
exploder = env.Program("exploder", exploder_sources + [libcutter, libwesnoth_core, libwesnoth_sdl, libwesnothd, libwesnoth],
LIBS = env["LIBS"] + ["png"])
else:
exploder = None
@ -267,15 +267,10 @@ test_sources = Split("""
tests/main.cpp
tests/test_util.cpp
""")
test_env.Program("../test", test_sources + [libwesnoth_core, libwesnoth],
test_env.Program("test", test_sources + [libwesnoth_core, libwesnoth],
CPPPATH = env["CPPPATH"] + ['/usr/include'],
LIBS = env["LIBS"] + ['boost_unit_test_framework'])
try:
env["svnrev"] = Popen(Split("svnversion -n ."), stdout=PIPE).communicate()[0]
except:
env["svnrev"] = ""
if env["svnrev"] != "" and env["svnrev"] != "exported":
revision_define = "#define REVISION \"%s\"\n" % env["svnrev"]
r = env.Command("revision.hpp", [],