Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add some more build options in scons: release/debug, c++0x, strict, b…

…uild directory and extra warnings
  • Loading branch information...
commit ffd85e2e1a176f1bef73de4165b886084a8e22ef 1 parent c70fc9f
@AI0867 AI0867 authored
Showing with 38 additions and 2 deletions.
  1. +37 −1 SConstruct
  2. +1 −1  src/SConscript
View
38 SConstruct
@@ -11,8 +11,13 @@ if os.path.exists('.scons-option-cache'):
opts = Variables('.scons-option-cache')
opts.AddVariables(
+ EnumVariable('build', 'Build variant: debug, release profile', "release", ["release", "debug", "profile"]),
+ PathVariable('build_dir', 'Build all intermediate files(objects, test programs, etc) under this dir', "build", PathVariable.PathAccept),
BoolVariable('ccache', "Use ccache", False),
+ BoolVariable('cxx0x', 'Use C++0x features.', False),
+ BoolVariable('extrawarn', "Use wesnoth-level warnings", False),
BoolVariable('gles2', "Use GLES2", False),
+ BoolVariable('strict', 'Set to strict compilation', False),
('cxxtool', 'Set c++ compiler command if not using standard compiler.'),
('jobs', 'Set the number of parallel compilations', "1", lambda key, value, env: int(value), int),
)
@@ -25,6 +30,37 @@ env.Append(CXXFLAGS= ["-pthread", "-DIMPLEMENT_SAVE_PNG"], LINKFLAGS = ["-pthrea
opts.Save('.scons-option-cache', env)
+builds = {
+ "debug" : dict(CCFLAGS = Split("$DEBUG_FLAGS")),
+ "release" : dict(CCFLAGS = "$OPT_FLAGS"),
+ "profile" : dict(CCFLAGS = "-pg", LINKFLAGS = "-pg")
+ }
+build = env["build"]
+
+env.AppendUnique(**builds[build])
+
+build_dir = os.path.join("$build_dir", build)
+
+if build == "release" : build_suffix = ""
+else : build_suffix = "-" + build
+Export("build_suffix")
+
+if "gcc" in env["TOOLS"]:
+ if env['extrawarn']:
+ env.AppendUnique(CCFLAGS = Split("-W -Wall -Wno-sign-compare -Wno-parentheses"))
+
+ if env['cxx0x']:
+ env.AppendUnique(CXXFLAGS = "-std=c++0x")
+ env.Append(CPPDEFINES = "HAVE_CXX0X")
+ else:
+ env.AppendUnique(CXXFLAGS = "-std=c++98")
+
+ if env['strict']:
+ env.AppendUnique(CCFLAGS = Split("-Werror"))
+
+ env["OPT_FLAGS"] = "-O2"
+ env["DEBUG_FLAGS"] = Split("-O0 -DDEBUG -ggdb3")
+
if env['gles2']:
env.Append(CXXFLAGS= ["-DUSEGLES2"])
if env.get('cxxtool',""):
@@ -59,4 +95,4 @@ if env['jobs'] > 1:
SetOption("num_jobs", env['jobs'])
Export(["env"])
-env.SConscript(dirs=["src"], variant_dir = "build", duplicate = False)
+env.SConscript(dirs=["src"], variant_dir = build_dir, duplicate = False)
View
2  src/SConscript
@@ -168,4 +168,4 @@ utility_object_compiler.cpp
utility_query.cpp
utility_render_level.cpp
""")
-env.Program("#/game", sources)
+env.Program("#/game" + build_suffix, sources)
Please sign in to comment.
Something went wrong with that request. Please try again.